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

Side by Side Diff: chrome/browser/chromeos/network_state_notifier.h

Issue 4235005: Push for ers:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ 6 #define CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/chromeos/cros/network_library.h" 9 #include "chrome/browser/chromeos/cros/network_library.h"
10 10
(...skipping 24 matching lines...) Expand all
35 explicit NetworkStateDetails(State state) 35 explicit NetworkStateDetails(State state)
36 : state_(state) { 36 : state_(state) {
37 } 37 }
38 38
39 State state_; 39 State state_;
40 40
41 DISALLOW_COPY_AND_ASSIGN(NetworkStateDetails); 41 DISALLOW_COPY_AND_ASSIGN(NetworkStateDetails);
42 }; 42 };
43 43
44 // NetworkStateNotifier sends notification when network state has 44 // NetworkStateNotifier sends notification when network state has
45 // chagned. Notificatio is sent in UI thread. 45 // chagned. Notification is sent in UI thread.
46 // TODO(oshima): port this to other platform. merge with 46 // TODO(oshima): port this to other platform. merge with
47 // NetworkChangeNotifier if possible. 47 // NetworkChangeNotifier if possible.
48 class NetworkStateNotifier : public NetworkLibrary::Observer { 48 class NetworkStateNotifier : public NetworkLibrary::NetworkManagerObserver {
49 public: 49 public:
50 // Returns the singleton instance of the network state notifier; 50 // Returns the singleton instance of the network state notifier;
51 static NetworkStateNotifier* Get(); 51 static NetworkStateNotifier* Get();
52 52
53 // The duration of being in offline. The value is undefined when 53 // The duration of being in offline. The value is undefined when
54 // when network is connected. 54 // when network is connected.
55 static base::TimeDelta GetOfflineDuration(); 55 static base::TimeDelta GetOfflineDuration();
56 56
57 // Returns true if the network is connected. 57 // Returns true if the network is connected.
58 static bool is_connected() { 58 static bool is_connected() {
59 return Get()->state_ == NetworkStateDetails::CONNECTED; 59 return Get()->state_ == NetworkStateDetails::CONNECTED;
60 } 60 }
61 61
62 // NetworkLibrary::Observer implementation. 62 // NetworkLibrary::NetworkManagerObserver implementation.
63 virtual void NetworkChanged(NetworkLibrary* cros); 63 virtual void OnNetworkManagerChanged(NetworkLibrary* cros);
64 64
65 private: 65 private:
66 friend struct DefaultSingletonTraits<NetworkStateNotifier>; 66 friend struct DefaultSingletonTraits<NetworkStateNotifier>;
67 67
68 // Retrieve the current state from libcros. 68 // Retrieve the current state from libcros.
69 static NetworkStateDetails::State RetrieveState(); 69 static NetworkStateDetails::State RetrieveState();
70 70
71 NetworkStateNotifier(); 71 NetworkStateNotifier();
72 virtual ~NetworkStateNotifier() {} 72 virtual ~NetworkStateNotifier();
73 73
74 // Update the current state and sends notification to observers. 74 // Update the current state and sends notification to observers.
75 // This should be invoked in UI thread. 75 // This should be invoked in UI thread.
76 void UpdateNetworkState(NetworkStateDetails::State new_state); 76 void UpdateNetworkState(NetworkStateDetails::State new_state);
77 77
78 // A factory to post a task in UI thread. 78 // A factory to post a task in UI thread.
79 ScopedRunnableMethodFactory<NetworkStateNotifier> task_factory_; 79 ScopedRunnableMethodFactory<NetworkStateNotifier> task_factory_;
80 80
81 // The current network state. 81 // The current network state.
82 NetworkStateDetails::State state_; 82 NetworkStateDetails::State state_;
83 83
84 // The start time of offline. 84 // The start time of offline.
85 base::Time offline_start_time_; 85 base::Time offline_start_time_;
86 86
87 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); 87 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier);
88 }; 88 };
89 89
90 } // namespace chromeos 90 } // namespace chromeos
91 91
92 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ 92 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/network_message_observer.cc ('k') | chrome/browser/chromeos/network_state_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698