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

Side by Side Diff: chromeos/dbus/shill_service_client_stub.cc

Issue 12319145: Using the new Network*Handlers in networkingPrivate Extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some closing periods from comments. Created 7 years, 9 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
« no previous file with comments | « chromeos/chromeos_switches.cc ('k') | chromeos/network/network_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dbus/shill_service_client_stub.h" 5 #include "chromeos/dbus/shill_service_client_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void ShillServiceClientStub::SetProperty(const dbus::ObjectPath& service_path, 73 void ShillServiceClientStub::SetProperty(const dbus::ObjectPath& service_path,
74 const std::string& name, 74 const std::string& name,
75 const base::Value& value, 75 const base::Value& value,
76 const base::Closure& callback, 76 const base::Closure& callback,
77 const ErrorCallback& error_callback) { 77 const ErrorCallback& error_callback) {
78 base::DictionaryValue* dict = NULL; 78 base::DictionaryValue* dict = NULL;
79 if (!stub_services_.GetDictionaryWithoutPathExpansion( 79 if (!stub_services_.GetDictionaryWithoutPathExpansion(
80 service_path.value(), &dict)) { 80 service_path.value(), &dict)) {
81 error_callback.Run("StubError", "Service not found"); 81 error_callback.Run("Error.InvalidService", "Invalid Service");
82 return; 82 return;
83 } 83 }
84 if (name == flimflam::kStateProperty) { 84 if (name == flimflam::kStateProperty) {
85 // If we connect to a service, then we move it to the top of the list in 85 // If we connect to a service, then we move it to the top of the list in
86 // the manager client. 86 // the manager client.
87 std::string state; 87 std::string state;
88 if (value.GetAsString(&state) && state == flimflam::kStateOnline) { 88 if (value.GetAsString(&state) && state == flimflam::kStateOnline) {
89 ShillManagerClient* manager_client = 89 ShillManagerClient* manager_client =
90 DBusThreadManager::Get()->GetShillManagerClient(); 90 DBusThreadManager::Get()->GetShillManagerClient();
91 manager_client->GetTestInterface()->RemoveService(service_path.value()); 91 manager_client->GetTestInterface()->RemoveService(service_path.value());
(...skipping 12 matching lines...) Expand all
104 } 104 }
105 105
106 void ShillServiceClientStub::ClearProperty( 106 void ShillServiceClientStub::ClearProperty(
107 const dbus::ObjectPath& service_path, 107 const dbus::ObjectPath& service_path,
108 const std::string& name, 108 const std::string& name,
109 const base::Closure& callback, 109 const base::Closure& callback,
110 const ErrorCallback& error_callback) { 110 const ErrorCallback& error_callback) {
111 base::DictionaryValue* dict = NULL; 111 base::DictionaryValue* dict = NULL;
112 if (!stub_services_.GetDictionaryWithoutPathExpansion( 112 if (!stub_services_.GetDictionaryWithoutPathExpansion(
113 service_path.value(), &dict)) { 113 service_path.value(), &dict)) {
114 error_callback.Run("StubError", "Service not found"); 114 error_callback.Run("Error.InvalidService", "Invalid Service");
115 return; 115 return;
116 } 116 }
117 dict->Remove(name, NULL); 117 dict->Remove(name, NULL);
118 MessageLoop::current()->PostTask( 118 MessageLoop::current()->PostTask(
119 FROM_HERE, 119 FROM_HERE,
120 base::Bind(&ShillServiceClientStub::NotifyObserversPropertyChanged, 120 base::Bind(&ShillServiceClientStub::NotifyObserversPropertyChanged,
121 weak_ptr_factory_.GetWeakPtr(), service_path, name)); 121 weak_ptr_factory_.GetWeakPtr(), service_path, name));
122 if (callback.is_null()) 122 if (callback.is_null())
123 return; 123 return;
124 MessageLoop::current()->PostTask(FROM_HERE, callback); 124 MessageLoop::current()->PostTask(FROM_HERE, callback);
125 } 125 }
126 126
127 void ShillServiceClientStub::ClearProperties( 127 void ShillServiceClientStub::ClearProperties(
128 const dbus::ObjectPath& service_path, 128 const dbus::ObjectPath& service_path,
129 const std::vector<std::string>& names, 129 const std::vector<std::string>& names,
130 const ListValueCallback& callback, 130 const ListValueCallback& callback,
131 const ErrorCallback& error_callback) { 131 const ErrorCallback& error_callback) {
132 base::DictionaryValue* dict = NULL; 132 base::DictionaryValue* dict = NULL;
133 if (!stub_services_.GetDictionaryWithoutPathExpansion( 133 if (!stub_services_.GetDictionaryWithoutPathExpansion(
134 service_path.value(), &dict)) { 134 service_path.value(), &dict)) {
135 error_callback.Run("StubError", "Service not found"); 135 error_callback.Run("Error.InvalidService", "Invalid Service");
136 return; 136 return;
137 } 137 }
138 scoped_ptr<base::ListValue> results(new base::ListValue); 138 scoped_ptr<base::ListValue> results(new base::ListValue);
139 for (std::vector<std::string>::const_iterator iter = names.begin(); 139 for (std::vector<std::string>::const_iterator iter = names.begin();
140 iter != names.end(); ++iter) { 140 iter != names.end(); ++iter) {
141 dict->Remove(*iter, NULL); 141 dict->Remove(*iter, NULL);
142 results->AppendBoolean(true); 142 results->AppendBoolean(true);
143 } 143 }
144 for (std::vector<std::string>::const_iterator iter = names.begin(); 144 for (std::vector<std::string>::const_iterator iter = names.begin();
145 iter != names.end(); ++iter) { 145 iter != names.end(); ++iter) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 online_value, 182 online_value,
183 base::Bind(&base::DoNothing), 183 base::Bind(&base::DoNothing),
184 error_callback), 184 error_callback),
185 base::TimeDelta::FromSeconds(kConnectDelaySeconds)); 185 base::TimeDelta::FromSeconds(kConnectDelaySeconds));
186 callback.Run(); 186 callback.Run();
187 } 187 }
188 188
189 void ShillServiceClientStub::Disconnect(const dbus::ObjectPath& service_path, 189 void ShillServiceClientStub::Disconnect(const dbus::ObjectPath& service_path,
190 const base::Closure& callback, 190 const base::Closure& callback,
191 const ErrorCallback& error_callback) { 191 const ErrorCallback& error_callback) {
192 base::Value* service;
193 if (!stub_services_.Get(service_path.value(), &service)) {
194 error_callback.Run("Error.InvalidService", "Invalid Service");
195 return;
196 }
192 // Set Idle after a delay 197 // Set Idle after a delay
193 const int kConnectDelaySeconds = 2; 198 const int kConnectDelaySeconds = 2;
194 base::StringValue idle_value(flimflam::kStateIdle); 199 base::StringValue idle_value(flimflam::kStateIdle);
195 MessageLoop::current()->PostDelayedTask( 200 MessageLoop::current()->PostDelayedTask(
196 FROM_HERE, 201 FROM_HERE,
197 base::Bind(&ShillServiceClientStub::SetProperty, 202 base::Bind(&ShillServiceClientStub::SetProperty,
198 weak_ptr_factory_.GetWeakPtr(), 203 weak_ptr_factory_.GetWeakPtr(),
199 service_path, 204 service_path,
200 flimflam::kStateProperty, 205 flimflam::kStateProperty,
201 idle_value, 206 idle_value,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 AddService("stub_ethernet", "eth0", 310 AddService("stub_ethernet", "eth0",
306 flimflam::kTypeEthernet, 311 flimflam::kTypeEthernet,
307 flimflam::kStateOnline, 312 flimflam::kStateOnline,
308 add_to_watchlist); 313 add_to_watchlist);
309 } 314 }
310 315
311 AddService("stub_wifi1", "wifi1", 316 AddService("stub_wifi1", "wifi1",
312 flimflam::kTypeWifi, 317 flimflam::kTypeWifi,
313 flimflam::kStateOnline, 318 flimflam::kStateOnline,
314 add_to_watchlist); 319 add_to_watchlist);
320 SetServiceProperty("stub_wifi1",
321 flimflam::kSecurityProperty,
322 base::StringValue(flimflam::kSecurityWep));
315 323
316 AddService("stub_wifi2", "wifi2_PSK", 324 AddService("stub_wifi2", "wifi2_PSK",
317 flimflam::kTypeWifi, 325 flimflam::kTypeWifi,
318 flimflam::kStateIdle, 326 flimflam::kStateIdle,
319 add_to_watchlist); 327 add_to_watchlist);
320 base::StringValue psk_value(flimflam::kSecurityPsk);
321 SetServiceProperty("stub_wifi2", 328 SetServiceProperty("stub_wifi2",
322 flimflam::kSecurityProperty, 329 flimflam::kSecurityProperty,
323 psk_value); 330 base::StringValue(flimflam::kSecurityPsk));
324 base::FundamentalValue strength_value(80); 331 base::FundamentalValue strength_value(80);
325 SetServiceProperty("stub_wifi2", 332 SetServiceProperty("stub_wifi2",
326 flimflam::kSignalStrengthProperty, 333 flimflam::kSignalStrengthProperty,
327 strength_value); 334 strength_value);
328 335
329 AddService("stub_cellular1", "cellular1", 336 AddService("stub_cellular1", "cellular1",
330 flimflam::kTypeCellular, 337 flimflam::kTypeCellular,
331 flimflam::kStateIdle, 338 flimflam::kStateIdle,
332 add_to_watchlist); 339 add_to_watchlist);
333 base::StringValue technology_value(flimflam::kNetworkTechnologyGsm); 340 base::StringValue technology_value(flimflam::kNetworkTechnologyGsm);
334 SetServiceProperty("stub_cellular1", 341 SetServiceProperty("stub_cellular1",
335 flimflam::kNetworkTechnologyProperty, 342 flimflam::kNetworkTechnologyProperty,
336 technology_value); 343 technology_value);
337 base::StringValue activation_value(flimflam::kActivationStateActivated);
338 SetServiceProperty("stub_cellular1", 344 SetServiceProperty("stub_cellular1",
339 flimflam::kActivationStateProperty, 345 flimflam::kActivationStateProperty,
340 activation_value); 346 base::StringValue(flimflam::kActivationStateNotActivated));
347 SetServiceProperty("stub_cellular1",
348 flimflam::kRoamingStateProperty,
349 base::StringValue(flimflam::kRoamingStateHome));
341 350
342 AddService("stub_vpn1", "vpn1", 351 AddService("stub_vpn1", "vpn1",
343 flimflam::kTypeVPN, 352 flimflam::kTypeVPN,
344 flimflam::kStateOnline, 353 flimflam::kStateOnline,
345 add_to_watchlist); 354 add_to_watchlist);
346 355
347 AddService("stub_vpn2", "vpn2", 356 AddService("stub_vpn2", "vpn2",
348 flimflam::kTypeVPN, 357 flimflam::kTypeVPN,
349 flimflam::kStateOffline, 358 flimflam::kStateOffline,
350 add_to_watchlist); 359 add_to_watchlist);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = 408 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
400 observer_list_.find(device_path); 409 observer_list_.find(device_path);
401 if (iter != observer_list_.end()) 410 if (iter != observer_list_.end())
402 return *(iter->second); 411 return *(iter->second);
403 PropertyObserverList* observer_list = new PropertyObserverList(); 412 PropertyObserverList* observer_list = new PropertyObserverList();
404 observer_list_[device_path] = observer_list; 413 observer_list_[device_path] = observer_list;
405 return *observer_list; 414 return *observer_list;
406 } 415 }
407 416
408 } // namespace chromeos 417 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/chromeos_switches.cc ('k') | chromeos/network/network_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698