Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: Source/modules/netinfo/NetworkInformation.h

Issue 1308943005: [NetInfo] Add Blink support for connection.change, connection.downlinkMax, and wimax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update test expectations Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NetworkInformation_h 5 #ifndef NetworkInformation_h
6 #define NetworkInformation_h 6 #define NetworkInformation_h
7 7
8 #include "core/dom/ActiveDOMObject.h" 8 #include "core/dom/ActiveDOMObject.h"
9 #include "core/events/EventTarget.h" 9 #include "core/events/EventTarget.h"
10 #include "core/page/NetworkStateNotifier.h" 10 #include "core/page/NetworkStateNotifier.h"
11 #include "public/platform/WebConnectionType.h" 11 #include "public/platform/WebConnectionType.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class ExecutionContext; 15 class ExecutionContext;
16 16
17 class NetworkInformation final 17 class NetworkInformation final
18 : public RefCountedGarbageCollectedEventTargetWithInlineData<NetworkInformat ion> 18 : public RefCountedGarbageCollectedEventTargetWithInlineData<NetworkInformat ion>
19 , public ActiveDOMObject 19 , public ActiveDOMObject
20 , public NetworkStateNotifier::NetworkStateObserver { 20 , public NetworkStateNotifier::NetworkStateObserver {
21 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(NetworkInformation); 21 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(NetworkInformation);
22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NetworkInformation); 22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NetworkInformation);
23 DEFINE_WRAPPERTYPEINFO(); 23 DEFINE_WRAPPERTYPEINFO();
24 public: 24 public:
25 static NetworkInformation* create(ExecutionContext*); 25 static NetworkInformation* create(ExecutionContext*);
26 ~NetworkInformation() override; 26 ~NetworkInformation() override;
27 27
28 String type() const; 28 String type() const;
29 double downlinkMax() const;
29 30
30 void connectionTypeChange(WebConnectionType) override; 31 // NetworkStateObserver overrides.
32 void connectionChange(WebConnectionType, double) override;
adamk 2015/08/28 00:55:31 Same bit here about naming
jkarlin 2015/09/02 17:37:07 Done.
31 33
32 // EventTarget overrides. 34 // EventTarget overrides.
33 const AtomicString& interfaceName() const override; 35 const AtomicString& interfaceName() const override;
34 ExecutionContext* executionContext() const override; 36 ExecutionContext* executionContext() const override;
35 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false) override; 37 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false) override;
36 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false) override; 38 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false) override;
37 void removeAllEventListeners() override; 39 void removeAllEventListeners() override;
38 40
39 // ActiveDOMObject overrides. 41 // ActiveDOMObject overrides.
40 bool hasPendingActivity() const override; 42 bool hasPendingActivity() const override;
41 void stop() override; 43 void stop() override;
42 44
43 DECLARE_VIRTUAL_TRACE(); 45 DECLARE_VIRTUAL_TRACE();
44 46
45 DEFINE_ATTRIBUTE_EVENT_LISTENER(typechange); 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
48 DEFINE_ATTRIBUTE_EVENT_LISTENER(typechange); // Deprecated
46 49
47 private: 50 private:
48 explicit NetworkInformation(ExecutionContext*); 51 explicit NetworkInformation(ExecutionContext*);
49 void startObserving(); 52 void startObserving();
50 void stopObserving(); 53 void stopObserving();
51 54
52 // Touched only on context thread. 55 // Touched only on context thread.
53 WebConnectionType m_type; 56 WebConnectionType m_type;
54 57
58 // Touched only on context thread.
59 double m_downlinkMax;
60
55 // Whether this object is listening for events from NetworkStateNotifier. 61 // Whether this object is listening for events from NetworkStateNotifier.
56 bool m_observing; 62 bool m_observing;
57 63
58 // Whether ActiveDOMObject::stop has been called. 64 // Whether ActiveDOMObject::stop has been called.
59 bool m_contextStopped; 65 bool m_contextStopped;
60 }; 66 };
61 67
62 } // namespace blink 68 } // namespace blink
63 69
64 #endif // NetworkInformation_h 70 #endif // NetworkInformation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698