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

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

Issue 14069010: Call RequestScan periodically while the network list is open (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 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
« no previous file with comments | « chromeos/dbus/shill_manager_client_stub.h ('k') | no next file » | 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_manager_client_stub.h" 5 #include "chromeos/dbus/shill_manager_client_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h" 8 #include "base/chromeos/chromeos_version.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chromeos/chromeos_switches.h" 12 #include "chromeos/chromeos_switches.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/shill_device_client.h"
14 #include "chromeos/dbus/shill_property_changed_observer.h" 15 #include "chromeos/dbus/shill_property_changed_observer.h"
15 #include "chromeos/dbus/shill_service_client.h" 16 #include "chromeos/dbus/shill_service_client.h"
16 #include "dbus/bus.h" 17 #include "dbus/bus.h"
17 #include "dbus/message.h" 18 #include "dbus/message.h"
18 #include "dbus/object_path.h" 19 #include "dbus/object_path.h"
19 #include "dbus/object_proxy.h" 20 #include "dbus/object_proxy.h"
20 #include "dbus/values_util.h" 21 #include "dbus/values_util.h"
21 #include "third_party/cros_system_api/dbus/service_constants.h" 22 #include "third_party/cros_system_api/dbus/service_constants.h"
22 23
23 namespace chromeos { 24 namespace chromeos {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const ErrorCallback& error_callback) { 88 const ErrorCallback& error_callback) {
88 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); 89 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy());
89 if (callback.is_null()) 90 if (callback.is_null())
90 return; 91 return;
91 MessageLoop::current()->PostTask(FROM_HERE, callback); 92 MessageLoop::current()->PostTask(FROM_HERE, callback);
92 } 93 }
93 94
94 void ShillManagerClientStub::RequestScan(const std::string& type, 95 void ShillManagerClientStub::RequestScan(const std::string& type,
95 const base::Closure& callback, 96 const base::Closure& callback,
96 const ErrorCallback& error_callback) { 97 const ErrorCallback& error_callback) {
97 const int kScanDelayMilliseconds = 3000; 98 // For Stub purposes, default to a Wifi scan.
98 CallNotifyObserversPropertyChanged( 99 std::string device_type = flimflam::kTypeWifi;
99 flimflam::kServicesProperty, kScanDelayMilliseconds); 100 if (!type.empty())
100 if (callback.is_null()) 101 device_type = type;
101 return; 102 ShillDeviceClient::TestInterface* device_client =
102 MessageLoop::current()->PostTask(FROM_HERE, callback); 103 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
104 std::string device_path = device_client->GetDevicePathForType(device_type);
105 if (!device_path.empty()) {
106 device_client->SetDeviceProperty(device_path,
107 flimflam::kScanningProperty,
108 base::FundamentalValue(true));
109 }
110 const int kScanDurationSeconds = 3;
111 MessageLoop::current()->PostDelayedTask(
112 FROM_HERE,
113 base::Bind(&ShillManagerClientStub::ScanCompleted,
114 weak_ptr_factory_.GetWeakPtr(), device_path, callback),
115 base::TimeDelta::FromSeconds(kScanDurationSeconds));
103 } 116 }
104 117
105 void ShillManagerClientStub::EnableTechnology( 118 void ShillManagerClientStub::EnableTechnology(
106 const std::string& type, 119 const std::string& type,
107 const base::Closure& callback, 120 const base::Closure& callback,
108 const ErrorCallback& error_callback) { 121 const ErrorCallback& error_callback) {
109 base::ListValue* enabled_list = NULL; 122 base::ListValue* enabled_list = NULL;
110 if (!stub_properties_.GetListWithoutPathExpansion( 123 if (!stub_properties_.GetListWithoutPathExpansion(
111 flimflam::kEnabledTechnologiesProperty, &enabled_list)) { 124 flimflam::kEnabledTechnologiesProperty, &enabled_list)) {
112 if (!error_callback.is_null()) { 125 if (!error_callback.is_null()) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 318
306 void ShillManagerClientStub::AddServiceAtIndex(const std::string& service_path, 319 void ShillManagerClientStub::AddServiceAtIndex(const std::string& service_path,
307 size_t index, 320 size_t index,
308 bool add_to_watch_list) { 321 bool add_to_watch_list) {
309 base::StringValue path_value(service_path); 322 base::StringValue path_value(service_path);
310 base::ListValue* service_list = 323 base::ListValue* service_list =
311 GetListProperty(flimflam::kServicesProperty); 324 GetListProperty(flimflam::kServicesProperty);
312 base::ListValue::iterator iter = 325 base::ListValue::iterator iter =
313 std::find_if(service_list->begin(), service_list->end(), 326 std::find_if(service_list->begin(), service_list->end(),
314 ValueEquals(&path_value)); 327 ValueEquals(&path_value));
315 service_list->Find(path_value);
316 if (iter != service_list->end()) 328 if (iter != service_list->end())
317 service_list->Erase(iter, NULL); 329 service_list->Erase(iter, NULL);
318 service_list->Insert(index, path_value.DeepCopy()); 330 service_list->Insert(index, path_value.DeepCopy());
319 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); 331 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
320 if (add_to_watch_list) 332 if (add_to_watch_list)
321 AddServiceToWatchList(service_path); 333 AddServiceToWatchList(service_path);
322 } 334 }
323 335
324 void ShillManagerClientStub::RemoveService(const std::string& service_path) { 336 void ShillManagerClientStub::RemoveService(const std::string& service_path) {
325 base::StringValue service_path_value(service_path); 337 base::StringValue service_path_value(service_path);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 properties->GetString(flimflam::kNameProperty, &name); 512 properties->GetString(flimflam::kNameProperty, &name);
501 std::string type; 513 std::string type;
502 properties->GetString(flimflam::kTypeProperty, &type); 514 properties->GetString(flimflam::kTypeProperty, &type);
503 if (TechnologyEnabled(type)) 515 if (TechnologyEnabled(type))
504 new_service_list->Append((*iter)->DeepCopy()); 516 new_service_list->Append((*iter)->DeepCopy());
505 } 517 }
506 } 518 }
507 return new_service_list; 519 return new_service_list;
508 } 520 }
509 521
522 void ShillManagerClientStub::ScanCompleted(const std::string& device_path,
523 const base::Closure& callback) {
524 if (!device_path.empty()) {
525 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()->
526 SetDeviceProperty(device_path,
527 flimflam::kScanningProperty,
528 base::FundamentalValue(false));
529 }
530 if (!callback.is_null())
531 MessageLoop::current()->PostTask(FROM_HERE, callback);
532 }
533
510 } // namespace chromeos 534 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_manager_client_stub.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698