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

Side by Side Diff: chromeos/network/network_state_handler.h

Issue 14729017: Add NetworkHandler to own network handlers in src/chromeos/network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromeos_unittests Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ 6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "chromeos/chromeos_export.h" 17 #include "chromeos/chromeos_export.h"
18 #include "chromeos/network/managed_state.h" 18 #include "chromeos/network/managed_state.h"
19 #include "chromeos/network/network_handler.h"
19 #include "chromeos/network/network_handler_callbacks.h" 20 #include "chromeos/network/network_handler_callbacks.h"
20 #include "chromeos/network/shill_property_handler.h" 21 #include "chromeos/network/shill_property_handler.h"
21 22
22 namespace base { 23 namespace base {
23 class DictionaryValue; 24 class DictionaryValue;
24 class ListValue; 25 class ListValue;
25 class Value; 26 class Value;
26 } 27 }
27 28
28 namespace chromeos { 29 namespace chromeos {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 enum TechnologyState { 61 enum TechnologyState {
61 TECHNOLOGY_UNAVAILABLE, 62 TECHNOLOGY_UNAVAILABLE,
62 TECHNOLOGY_AVAILABLE, 63 TECHNOLOGY_AVAILABLE,
63 TECHNOLOGY_UNINITIALIZED, 64 TECHNOLOGY_UNINITIALIZED,
64 TECHNOLOGY_ENABLING, 65 TECHNOLOGY_ENABLING,
65 TECHNOLOGY_ENABLED 66 TECHNOLOGY_ENABLED
66 }; 67 };
67 68
68 virtual ~NetworkStateHandler(); 69 virtual ~NetworkStateHandler();
69 70
70 // Sets the global instance. Must be called before any calls to Get().
71 static void Initialize();
72
73 // Returns true if the global instance has been initialized.
74 static bool IsInitialized();
75
76 // Destroys the global instance.
77 static void Shutdown();
78
79 // Gets the global instance. Initialize() must be called first.
80 static NetworkStateHandler* Get();
81
82 // Add/remove observers. 71 // Add/remove observers.
83 void AddObserver(NetworkStateHandlerObserver* observer); 72 void AddObserver(NetworkStateHandlerObserver* observer);
84 void RemoveObserver(NetworkStateHandlerObserver* observer); 73 void RemoveObserver(NetworkStateHandlerObserver* observer);
85 74
86 // Returns the state for technology |type|. kMatchTypeMobile (only) is 75 // Returns the state for technology |type|. kMatchTypeMobile (only) is
87 // also supported. 76 // also supported.
88 TechnologyState GetTechnologyState(const std::string& type) const; 77 TechnologyState GetTechnologyState(const std::string& type) const;
89 bool IsTechnologyEnabled(const std::string& type) const { 78 bool IsTechnologyEnabled(const std::string& type) const {
90 return GetTechnologyState(type) == TECHNOLOGY_ENABLED; 79 return GetTechnologyState(type) == TECHNOLOGY_ENABLED;
91 } 80 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Set the user initiated connecting network. 162 // Set the user initiated connecting network.
174 void SetConnectingNetwork(const std::string& service_path); 163 void SetConnectingNetwork(const std::string& service_path);
175 164
176 const std::string& connecting_network() const { return connecting_network_; } 165 const std::string& connecting_network() const { return connecting_network_; }
177 166
178 // Generates a DictionaryValue of all NetworkState properties. Currently 167 // Generates a DictionaryValue of all NetworkState properties. Currently
179 // provided for debugging purposes only. 168 // provided for debugging purposes only.
180 void GetNetworkStatePropertiesForTest( 169 void GetNetworkStatePropertiesForTest(
181 base::DictionaryValue* dictionary) const; 170 base::DictionaryValue* dictionary) const;
182 171
172 // Construct and initialize an instance for testing.
173 static NetworkStateHandler* InitializeForTest();
174
183 static const char kMatchTypeDefault[]; 175 static const char kMatchTypeDefault[];
184 static const char kMatchTypeWireless[]; 176 static const char kMatchTypeWireless[];
185 static const char kMatchTypeMobile[]; 177 static const char kMatchTypeMobile[];
186 static const char kMatchTypeNonVirtual[]; 178 static const char kMatchTypeNonVirtual[];
187 179
188 protected: 180 protected:
181 friend class NetworkHandler;
189 NetworkStateHandler(); 182 NetworkStateHandler();
190 183
191 // ShillPropertyHandler::Listener overrides. 184 // ShillPropertyHandler::Listener overrides.
192 185
193 // This adds new entries to the managed list specified by |type| and deletes 186 // This adds new entries to the managed list specified by |type| and deletes
194 // any entries that are no longer in the list. 187 // any entries that are no longer in the list.
195 virtual void UpdateManagedList(ManagedState::ManagedType type, 188 virtual void UpdateManagedList(ManagedState::ManagedType type,
196 const base::ListValue& entries) OVERRIDE; 189 const base::ListValue& entries) OVERRIDE;
197 190
198 // The list of profiles changed (i.e. a user has logged in). Re-request 191 // The list of profiles changed (i.e. a user has logged in). Re-request
(...skipping 22 matching lines...) Expand all
221 // Sends NetworkManagerChanged() to observers and logs an event. 214 // Sends NetworkManagerChanged() to observers and logs an event.
222 virtual void NotifyManagerPropertyChanged() OVERRIDE; 215 virtual void NotifyManagerPropertyChanged() OVERRIDE;
223 216
224 // Called by |shill_property_handler_| when the service or device list has 217 // Called by |shill_property_handler_| when the service or device list has
225 // changed and all entries have been updated. This updates the list and 218 // changed and all entries have been updated. This updates the list and
226 // notifies observers. If |type| == TYPE_NETWORK this also calls 219 // notifies observers. If |type| == TYPE_NETWORK this also calls
227 // CheckDefaultNetworkChanged(). 220 // CheckDefaultNetworkChanged().
228 virtual void ManagedStateListChanged( 221 virtual void ManagedStateListChanged(
229 ManagedState::ManagedType type) OVERRIDE; 222 ManagedState::ManagedType type) OVERRIDE;
230 223
231 // Called in Initialize(). Called explicitly by tests after adding 224 // Called after construction. Called explicitly by tests after adding
232 // test observers. 225 // test observers.
233 void InitShillPropertyHandler(); 226 void InitShillPropertyHandler();
234 227
235 private: 228 private:
236 typedef std::list<base::Closure> ScanCallbackList; 229 typedef std::list<base::Closure> ScanCallbackList;
237 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap; 230 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap;
238 friend class NetworkStateHandlerTest; 231 friend class NetworkStateHandlerTest;
239 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub); 232 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub);
240 233
241 // Non-const getters for managed entries. These are const so that they can 234 // Non-const getters for managed entries. These are const so that they can
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 283
291 // Callbacks to run when a scan for the technology type completes. 284 // Callbacks to run when a scan for the technology type completes.
292 ScanCompleteCallbackMap scan_complete_callbacks_; 285 ScanCompleteCallbackMap scan_complete_callbacks_;
293 286
294 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); 287 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler);
295 }; 288 };
296 289
297 } // namespace chromeos 290 } // namespace chromeos
298 291
299 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ 292 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/network/network_profile_handler_stub.h ('k') | chromeos/network/network_state_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698