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

Unified Diff: chromeos/dbus/shill_manager_client_stub.cc

Issue 14137017: Add TechnologyState to NetworkStateHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/shill_manager_client_stub.h ('k') | chromeos/network/device_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/shill_manager_client_stub.cc
diff --git a/chromeos/dbus/shill_manager_client_stub.cc b/chromeos/dbus/shill_manager_client_stub.cc
index 2bac7dcfe1648fbbe5cb6679faf01940535f3afa..35e8e25cc124d2a472fee9aab307e19f6c8745aa 100644
--- a/chromeos/dbus/shill_manager_client_stub.cc
+++ b/chromeos/dbus/shill_manager_client_stub.cc
@@ -135,14 +135,17 @@ void ShillManagerClientStub::EnableTechnology(
}
return;
}
- enabled_list->AppendIfNotPresent(new base::StringValue(type));
- CallNotifyObserversPropertyChanged(
- flimflam::kEnabledTechnologiesProperty, 0);
- if (!callback.is_null())
- MessageLoop::current()->PostTask(FROM_HERE, callback);
- // May affect available services
- CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
- CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableStubInteractive)) {
+ const int kEnableTechnologyDelaySeconds = 3;
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ShillManagerClientStub::SetTechnologyEnabled,
+ weak_ptr_factory_.GetWeakPtr(), type, callback, true),
+ base::TimeDelta::FromSeconds(kEnableTechnologyDelaySeconds));
+ } else {
+ SetTechnologyEnabled(type, callback, true);
+ }
}
void ShillManagerClientStub::DisableTechnology(
@@ -159,16 +162,18 @@ void ShillManagerClientStub::DisableTechnology(
}
return;
}
- base::StringValue type_value(type);
- enabled_list->Remove(type_value, NULL);
- CallNotifyObserversPropertyChanged(
- flimflam::kEnabledTechnologiesProperty, 0);
- if (!callback.is_null())
- MessageLoop::current()->PostTask(FROM_HERE, callback);
- // May affect available services
- CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
- CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0);
- }
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableStubInteractive)) {
+ const int kDisableTechnologyDelaySeconds = 3;
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ShillManagerClientStub::SetTechnologyEnabled,
+ weak_ptr_factory_.GetWeakPtr(), type, callback, false),
+ base::TimeDelta::FromSeconds(kDisableTechnologyDelaySeconds));
+ } else {
+ SetTechnologyEnabled(type, callback, false);
+ }
+}
void ShillManagerClientStub::ConfigureService(
const base::DictionaryValue& properties,
@@ -448,6 +453,10 @@ void ShillManagerClientStub::CallNotifyObserversPropertyChanged(
// initial setup).
if (observer_list_.size() == 0)
return;
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableStubInteractive)) {
+ delay_ms = 0;
+ }
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&ShillManagerClientStub::NotifyObserversPropertyChanged,
@@ -501,6 +510,27 @@ bool ShillManagerClientStub::TechnologyEnabled(const std::string& type) const {
return enabled;
}
+void ShillManagerClientStub::SetTechnologyEnabled(
+ const std::string& type,
+ const base::Closure& callback,
+ bool enabled) {
+ base::ListValue* enabled_list = NULL;
+ stub_properties_.GetListWithoutPathExpansion(
+ flimflam::kEnabledTechnologiesProperty, &enabled_list);
+ DCHECK(enabled_list);
+ if (enabled)
+ enabled_list->AppendIfNotPresent(new base::StringValue(type));
+ else
+ enabled_list->Remove(base::StringValue(type), NULL);
+ CallNotifyObserversPropertyChanged(
+ flimflam::kEnabledTechnologiesProperty, 0 /* already delayed */);
+ if (!callback.is_null())
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
+ // May affect available services
+ CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
+ CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0);
+}
+
base::ListValue* ShillManagerClientStub::GetEnabledServiceList(
const std::string& property) const {
base::ListValue* new_service_list = new base::ListValue;
« no previous file with comments | « chromeos/dbus/shill_manager_client_stub.h ('k') | chromeos/network/device_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698