Changeset 79563 in webkit


Ignore:
Timestamp:
Feb 24, 2011 7:49:15 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-02-24 Adam Klein <adamk@chromium.org>

Reviewed by Darin Fisher.

[chromium] Add code to WebKit Chromium to allow access to NetworkStateNotifier
https://bugs.webkit.org/show_bug.cgi?id=54516

Give Chromium's NetworkStateNotifier the ability to change the value
of m_isOnLine, rather than making it always true.

No new tests, not sure how to test this. No other LayoutTests seem
to exercise navigator.onLine.

  • WebCore.gypi:
  • platform/network/NetworkStateNotifier.cpp: (WebCore::NetworkStateNotifier::setOnLine): Moved and renamed from NetworkStateNotifierAndroid.
  • platform/network/NetworkStateNotifier.h: (WebCore::NetworkStateNotifier::networkStateChange): Forward to setOnLine.
  • platform/network/android/NetworkStateNotifierAndroid.cpp: Removed.
  • platform/network/chromium/NetworkStateNotifierChromium.cpp: Removed.
  • platform/network/chromium/NetworkStateNotifierPrivate.h: Removed.

2011-02-24 Adam Klein <adamk@chromium.org>

Reviewed by Darin Fisher.

[chromium] Add code to WebKit Chromium to allow access to NetworkStateNotifier
https://bugs.webkit.org/show_bug.cgi?id=54516

Add a new WebNetworkStateNotifier class with a single static method,
setOnLine(), which dispatches to WebCore's singleton NetworkStateNotifier.

  • WebKit.gyp:
  • public/WebNetworkStateNotifier.h: Added.
  • src/WebNetworkStateNotifier.cpp: Added. (WebKit::WebNetworkStateNotifier::setOnLine):
Location:
trunk/Source
Files:
1 deleted
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r79562 r79563  
     12011-02-24  Adam Klein  <adamk@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [chromium] Add code to WebKit Chromium to allow access to NetworkStateNotifier
     6        https://bugs.webkit.org/show_bug.cgi?id=54516
     7
     8        Give Chromium's NetworkStateNotifier the ability to change the value
     9        of m_isOnLine, rather than making it always true.
     10
     11        No new tests, not sure how to test this. No other LayoutTests seem
     12        to exercise navigator.onLine.
     13
     14        * WebCore.gypi:
     15        * platform/network/NetworkStateNotifier.cpp:
     16        (WebCore::NetworkStateNotifier::setOnLine): Moved and renamed from NetworkStateNotifierAndroid.
     17        * platform/network/NetworkStateNotifier.h:
     18        (WebCore::NetworkStateNotifier::networkStateChange): Forward to setOnLine.
     19        * platform/network/android/NetworkStateNotifierAndroid.cpp: Removed.
     20        * platform/network/chromium/NetworkStateNotifierChromium.cpp: Removed.
     21        * platform/network/chromium/NetworkStateNotifierPrivate.h: Removed.
     22
    1232011-02-24  Benjamin Poulain  <benjamin.poulain@nokia.com>
    224
  • trunk/Source/WebCore/WebCore.gypi

    r79426 r79563  
    31673167            'platform/network/chromium/CookieJarChromium.cpp',
    31683168            'platform/network/chromium/DNSChromium.cpp',
    3169             'platform/network/chromium/NetworkStateNotifierChromium.cpp',
    3170             'platform/network/chromium/NetworkStateNotifierPrivate.h',
    31713169            'platform/network/chromium/ResourceError.h',
    31723170            'platform/network/chromium/ResourceRequest.cpp',
  • trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp

    r39138 r79563  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    3636{
    3737    AtomicallyInitializedStatic(NetworkStateNotifier*, networkStateNotifier = new NetworkStateNotifier);
    38    
     38
    3939    return *networkStateNotifier;
    4040}
     
    4343{
    4444    ASSERT(!m_networkStateChangedFunction);
    45    
     45
    4646    m_networkStateChangedFunction = function;
    4747}
    48    
     48
     49#if PLATFORM(ANDROID) || PLATFORM(CHROMIUM)
     50void NetworkStateNotifier::setOnLine(bool onLine)
     51{
     52    if (m_isOnLine == onLine)
     53        return;
     54
     55    m_isOnLine = onLine;
     56
     57    if (m_networkStateChangedFunction)
     58        m_networkStateChangedFunction();
    4959}
     60#endif // PLATFORM(ANDROID) || PLATFORM(CHROMIM)
     61
     62}
  • trunk/Source/WebCore/platform/network/NetworkStateNotifier.h

    r76248 r79563  
    3838typedef const struct __SCDynamicStore * SCDynamicStoreRef;
    3939
    40 #elif PLATFORM(CHROMIUM)
    41 
    42 #include "NetworkStateNotifierPrivate.h"
    43 
    4440#elif PLATFORM(WIN)
    4541
     
    6864    NetworkStateNotifier();
    6965    void setNetworkStateChangedFunction(void (*)());
    70    
     66
    7167    bool onLine() const { return m_isOnLine; }
    7268
    7369#if (PLATFORM(QT) && ENABLE(QT_BEARER))
    7470    void setNetworkAccessAllowed(bool);
     71#elif PLATFORM(ANDROID) || PLATFORM(CHROMIUM)
     72    void setOnLine(bool);
    7573#endif
    7674
    77 private:   
     75#if PLATFORM(ANDROID)
     76    void networkStateChange(bool online) { setOnLine(online); }
     77#endif
     78
     79private:
    7880    bool m_isOnLine;
    7981    void (*m_networkStateChangedFunction)();
     
    9395    static void callAddressChanged(void*);
    9496    void addressChanged();
    95    
     97
    9698    void registerForAddressChange();
    9799    HANDLE m_waitHandle;
    98100    OVERLAPPED m_overlapped;
    99 
    100 #elif PLATFORM(CHROMIUM)
    101     NetworkStateNotifierPrivate p;
    102 
    103 #elif PLATFORM(ANDROID)
    104 public:
    105     void networkStateChange(bool online);
    106101
    107102#elif PLATFORM(QT) && ENABLE(QT_BEARER)
     
    111106};
    112107
    113 #if !PLATFORM(MAC) && !PLATFORM(WIN) && !PLATFORM(CHROMIUM) && !(PLATFORM(QT) && ENABLE(QT_BEARER))
     108#if !PLATFORM(MAC) && !PLATFORM(WIN) && !(PLATFORM(QT) && ENABLE(QT_BEARER))
    114109
    115110inline NetworkStateNotifier::NetworkStateNotifier()
    116111    : m_isOnLine(true)
    117112    , m_networkStateChangedFunction(0)
    118 {   
     113{
    119114}
    120115
     
    124119
    125120NetworkStateNotifier& networkStateNotifier();
    126    
     121
    127122};
    128123
  • trunk/Source/WebKit/chromium/ChangeLog

    r79534 r79563  
     12011-02-24  Adam Klein  <adamk@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [chromium] Add code to WebKit Chromium to allow access to NetworkStateNotifier
     6        https://bugs.webkit.org/show_bug.cgi?id=54516
     7
     8        Add a new WebNetworkStateNotifier class with a single static method,
     9        setOnLine(), which dispatches to WebCore's singleton NetworkStateNotifier.
     10
     11        * WebKit.gyp:
     12        * public/WebNetworkStateNotifier.h: Added.
     13        * src/WebNetworkStateNotifier.cpp: Added.
     14        (WebKit::WebNetworkStateNotifier::setOnLine):
     15
    1162011-02-24  Robert Kroeger <rjkroege@chromium.org>
    217
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r79503 r79563  
    220220                'public/WebNamedNodeMap.h',
    221221                'public/WebNavigationType.h',
     222                'public/WebNetworkStateNotifier.h',
    222223                'public/WebNode.h',
    223224                'public/WebNodeCollection.h',
     
    506507                'src/WebMediaPlayerClientImpl.h',
    507508                'src/WebNamedNodeMap.cpp',
     509                'src/WebNetworkStateNotifier.cpp',
    508510                'src/WebNode.cpp',
    509511                'src/WebNodeCollection.cpp',
  • trunk/Source/WebKit/chromium/public/WebNetworkStateNotifier.h

    r79562 r79563  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
     3 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  * 
     7 *
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    2929 */
    3030
    31 #ifndef NetworkStateNotifierPrivate_h
    32 #define NetworkStateNotifierPrivate_h
     31#ifndef WebNetworkStateNotifier_h
     32#define WebNetworkStateNotifier_h
    3333
    34 namespace WebCore {
     34#include "WebCommon.h"
    3535
    36     struct NetworkStateNotifierPrivate {};
     36namespace WebKit {
    3737
    38 } // namespace WebCore
     38class WebNetworkStateNotifier {
     39public:
     40    WEBKIT_API static void setOnLine(bool);
     41
     42private:
     43    WebNetworkStateNotifier();
     44};
     45
     46} // namespace WebKit
    3947
    4048#endif
  • trunk/Source/WebKit/chromium/src/WebNetworkStateNotifier.cpp

    r79562 r79563  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
     3 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  * 
     7 *
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    3030
    3131#include "config.h"
     32#include "WebNetworkStateNotifier.h"
     33
    3234#include "NetworkStateNotifier.h"
    3335
    34 namespace WebCore {
     36using namespace WebCore;
    3537
    36 // Chromium doesn't currently support network state notifications. This causes
    37 // an extra DLL to get loaded into the renderer which can slow things down a
    38 // bit. We may want an alternate design.
     38namespace WebKit {
    3939
    40 void NetworkStateNotifier::updateState()
     40void WebNetworkStateNotifier::setOnLine(bool onLine)
    4141{
     42    networkStateNotifier().setOnLine(onLine);
    4243}
    4344
    44 NetworkStateNotifier::NetworkStateNotifier()
    45     : m_isOnLine(true)
    46     , m_networkStateChangedFunction(0)
    47 {
    48 }
    49 
    50 } // namespace WebCore
     45} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.