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

Side by Side Diff: chromeos/network/network_profile_handler.cc

Issue 14729017: Add NetworkHandler to own network handlers in src/chromeos/network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Add NetworkConnectionHandler to NetworkHandler 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chromeos/network/network_profile_handler.h" 5 #include "chromeos/network/network_profile_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/dbus/shill_manager_client.h" 13 #include "chromeos/dbus/shill_manager_client.h"
14 #include "chromeos/dbus/shill_profile_client.h" 14 #include "chromeos/dbus/shill_profile_client.h"
15 #include "chromeos/network/network_profile_observer.h" 15 #include "chromeos/network/network_profile_observer.h"
16 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
18 18
19 namespace chromeos { 19 namespace chromeos {
20 20
21 static NetworkProfileHandler* g_profile_handler_instance = NULL;
22
23 namespace { 21 namespace {
24 22
25 bool ConvertListValueToStringVector(const base::ListValue& string_list, 23 bool ConvertListValueToStringVector(const base::ListValue& string_list,
26 std::vector<std::string>* result) { 24 std::vector<std::string>* result) {
27 for (size_t i = 0; i < string_list.GetSize(); ++i) { 25 for (size_t i = 0; i < string_list.GetSize(); ++i) {
28 std::string str; 26 std::string str;
29 if (!string_list.GetString(i, &str)) 27 if (!string_list.GetString(i, &str))
30 return false; 28 return false;
31 result->push_back(str); 29 result->push_back(str);
32 } 30 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 65 }
68 66
69 virtual ~NetworkProfileHandlerImpl() { 67 virtual ~NetworkProfileHandlerImpl() {
70 DBusThreadManager::Get()->GetShillManagerClient()-> 68 DBusThreadManager::Get()->GetShillManagerClient()->
71 RemovePropertyChangedObserver(this); 69 RemovePropertyChangedObserver(this);
72 } 70 }
73 }; 71 };
74 72
75 } // namespace 73 } // namespace
76 74
77 // static
78 NetworkProfileHandler* NetworkProfileHandler::Initialize() {
79 CHECK(!g_profile_handler_instance);
80 g_profile_handler_instance = new NetworkProfileHandlerImpl();
81 return g_profile_handler_instance;
82 }
83
84 // static
85 bool NetworkProfileHandler::IsInitialized() {
86 return g_profile_handler_instance;
87 }
88
89 // static
90 void NetworkProfileHandler::Shutdown() {
91 CHECK(g_profile_handler_instance);
92 delete g_profile_handler_instance;
93 g_profile_handler_instance = NULL;
94 }
95
96 // static
97 NetworkProfileHandler* NetworkProfileHandler::Get() {
98 CHECK(g_profile_handler_instance);
99 return g_profile_handler_instance;
100 }
101
102 void NetworkProfileHandler::AddObserver(NetworkProfileObserver* observer) { 75 void NetworkProfileHandler::AddObserver(NetworkProfileObserver* observer) {
103 observers_.AddObserver(observer); 76 observers_.AddObserver(observer);
104 } 77 }
105 78
106 void NetworkProfileHandler::RemoveObserver(NetworkProfileObserver* observer) { 79 void NetworkProfileHandler::RemoveObserver(NetworkProfileObserver* observer) {
107 observers_.RemoveObserver(observer); 80 observers_.RemoveObserver(observer);
108 } 81 }
109 82
110 void NetworkProfileHandler::GetManagerPropertiesCallback( 83 void NetworkProfileHandler::GetManagerPropertiesCallback(
111 DBusMethodCallStatus call_status, 84 DBusMethodCallStatus call_status,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 197 }
225 198
226 NetworkProfileHandler::NetworkProfileHandler() 199 NetworkProfileHandler::NetworkProfileHandler()
227 : weak_ptr_factory_(this) { 200 : weak_ptr_factory_(this) {
228 } 201 }
229 202
230 NetworkProfileHandler::~NetworkProfileHandler() { 203 NetworkProfileHandler::~NetworkProfileHandler() {
231 } 204 }
232 205
233 } // namespace chromeos 206 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698