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

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

Issue 289383004: Merge FavoriteState into NetworkState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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/strings/string_util.h" 10 #include "base/strings/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 "chromeos/network/network_state_handler.h"
17 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
19 18
20 namespace chromeos { 19 namespace chromeos {
21 20
22 namespace { 21 namespace {
23 22
24 bool ConvertListValueToStringVector(const base::ListValue& string_list, 23 bool ConvertListValueToStringVector(const base::ListValue& string_list,
25 std::vector<std::string>* result) { 24 std::vector<std::string>* result) {
26 for (size_t i = 0; i < string_list.GetSize(); ++i) { 25 for (size_t i = 0; i < string_list.GetSize(); ++i) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 continue; 124 continue;
126 125
127 VLOG(2) << "Requesting properties of profile path " << *it << "."; 126 VLOG(2) << "Requesting properties of profile path " << *it << ".";
128 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties( 127 DBusThreadManager::Get()->GetShillProfileClient()->GetProperties(
129 dbus::ObjectPath(*it), 128 dbus::ObjectPath(*it),
130 base::Bind(&NetworkProfileHandler::GetProfilePropertiesCallback, 129 base::Bind(&NetworkProfileHandler::GetProfilePropertiesCallback,
131 weak_ptr_factory_.GetWeakPtr(), 130 weak_ptr_factory_.GetWeakPtr(),
132 *it), 131 *it),
133 base::Bind(&LogProfileRequestError, *it)); 132 base::Bind(&LogProfileRequestError, *it));
134 } 133 }
135
136 // When the profile list changes, ServiceCompleteList may also change, so
137 // trigger a Manager update to request the updated list.
138 if (network_state_handler_)
139 network_state_handler_->UpdateManagerProperties();
140 } 134 }
141 135
142 void NetworkProfileHandler::GetProfilePropertiesCallback( 136 void NetworkProfileHandler::GetProfilePropertiesCallback(
143 const std::string& profile_path, 137 const std::string& profile_path,
144 const base::DictionaryValue& properties) { 138 const base::DictionaryValue& properties) {
145 std::string userhash; 139 std::string userhash;
146 properties.GetStringWithoutPathExpansion(shill::kUserHashProperty, &userhash); 140 properties.GetStringWithoutPathExpansion(shill::kUserHashProperty, &userhash);
147 141
148 AddProfile(NetworkProfile(profile_path, userhash)); 142 AddProfile(NetworkProfile(profile_path, userhash));
149 } 143 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 for (NetworkProfileHandler::ProfileList::const_iterator it = 187 for (NetworkProfileHandler::ProfileList::const_iterator it =
194 profiles_.begin(); 188 profiles_.begin();
195 it != profiles_.end(); ++it) { 189 it != profiles_.end(); ++it) {
196 if (!it->userhash.empty()) 190 if (!it->userhash.empty())
197 return &*it; 191 return &*it;
198 } 192 }
199 return NULL; 193 return NULL;
200 } 194 }
201 195
202 NetworkProfileHandler::NetworkProfileHandler() 196 NetworkProfileHandler::NetworkProfileHandler()
203 : network_state_handler_(NULL), 197 : weak_ptr_factory_(this) {
204 weak_ptr_factory_(this) {
205 } 198 }
206 199
207 void NetworkProfileHandler::Init(NetworkStateHandler* network_state_handler) { 200 void NetworkProfileHandler::Init() {
208 network_state_handler_ = network_state_handler;
209
210 DBusThreadManager::Get()->GetShillManagerClient()-> 201 DBusThreadManager::Get()->GetShillManagerClient()->
211 AddPropertyChangedObserver(this); 202 AddPropertyChangedObserver(this);
212 203
213 // Request the initial profile list. 204 // Request the initial profile list.
214 DBusThreadManager::Get()->GetShillManagerClient()->GetProperties( 205 DBusThreadManager::Get()->GetShillManagerClient()->GetProperties(
215 base::Bind(&NetworkProfileHandler::GetManagerPropertiesCallback, 206 base::Bind(&NetworkProfileHandler::GetManagerPropertiesCallback,
216 weak_ptr_factory_.GetWeakPtr())); 207 weak_ptr_factory_.GetWeakPtr()));
217 } 208 }
218 209
219 NetworkProfileHandler::~NetworkProfileHandler() { 210 NetworkProfileHandler::~NetworkProfileHandler() {
220 DBusThreadManager::Get()->GetShillManagerClient()-> 211 DBusThreadManager::Get()->GetShillManagerClient()->
221 RemovePropertyChangedObserver(this); 212 RemovePropertyChangedObserver(this);
222 } 213 }
223 214
224 } // namespace chromeos 215 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_profile_handler.h ('k') | chromeos/network/network_sms_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698