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

Unified Diff: chromeos/dbus/fake_shill_service_client.cc

Issue 181413006: Replace misc. network stub flags with more flexible ones (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 10 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
Index: chromeos/dbus/fake_shill_service_client.cc
diff --git a/chromeos/dbus/fake_shill_service_client.cc b/chromeos/dbus/fake_shill_service_client.cc
index 8987c189686e8a8fa978ec3ee811f8ebda403109..054815eb1a5f5830cc82c84427aca04b2e70e5c0 100644
--- a/chromeos/dbus/fake_shill_service_client.cc
+++ b/chromeos/dbus/fake_shill_service_client.cc
@@ -6,17 +6,14 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/values.h"
-#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/dbus/shill_property_changed_observer.h"
-#include "chromeos/dbus/shill_stub_helper.h"
#include "chromeos/network/shill_property_util.h"
#include "dbus/bus.h"
#include "dbus/message.h"
@@ -39,6 +36,11 @@ void PassStubServiceProperties(
callback.Run(call_status, *properties);
}
+int GetInteractiveDelay() {
+ return DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
+ GetInteractiveDelay();
+}
+
} // namespace
FakeShillServiceClient::FakeShillServiceClient() : weak_ptr_factory_(this) {
@@ -188,18 +190,12 @@ void FakeShillServiceClient::Connect(const dbus::ObjectPath& service_path,
associating_value);
// Stay Associating until the state is changed again after a delay.
- base::TimeDelta delay;
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableStubInteractive)) {
- const int kConnectDelaySeconds = 5;
- delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds);
- }
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&FakeShillServiceClient::ContinueConnect,
weak_ptr_factory_.GetWeakPtr(),
service_path.value()),
- delay);
+ base::TimeDelta::FromSeconds(GetInteractiveDelay()));
callback.Run();
}
@@ -212,12 +208,6 @@ void FakeShillServiceClient::Disconnect(const dbus::ObjectPath& service_path,
error_callback.Run("Error.InvalidService", "Invalid Service");
return;
}
- base::TimeDelta delay;
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableStubInteractive)) {
- const int kConnectDelaySeconds = 2;
- delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds);
- }
// Set Idle after a delay
base::StringValue idle_value(shill::kStateIdle);
base::MessageLoop::current()->PostDelayedTask(
@@ -229,7 +219,7 @@ void FakeShillServiceClient::Disconnect(const dbus::ObjectPath& service_path,
idle_value,
base::Bind(&base::DoNothing),
error_callback),
- delay);
+ base::TimeDelta::FromSeconds(GetInteractiveDelay()));
callback.Run();
}
@@ -253,12 +243,6 @@ void FakeShillServiceClient::ActivateCellularModem(
SetServiceProperty(service_path.value(),
shill::kActivationStateProperty,
base::StringValue(shill::kActivationStateActivating));
- base::TimeDelta delay;
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableStubInteractive)) {
- const int kConnectDelaySeconds = 2;
- delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds);
- }
// Set Activated after a delay
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
@@ -266,7 +250,7 @@ void FakeShillServiceClient::ActivateCellularModem(
weak_ptr_factory_.GetWeakPtr(),
service_path,
error_callback),
- delay);
+ base::TimeDelta::FromSeconds(GetInteractiveDelay()));
base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
@@ -319,12 +303,7 @@ void FakeShillServiceClient::AddService(const std::string& service_path,
const std::string& state,
bool add_to_visible_list,
bool add_to_watch_list) {
- std::string nstate = state;
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kDefaultStubNetworkStateIdle)) {
- nstate = shill::kStateIdle;
- }
- AddServiceWithIPConfig(service_path, name, type, nstate, "",
+ AddServiceWithIPConfig(service_path, name, type, state, "",
add_to_visible_list, add_to_watch_list);
}

Powered by Google App Engine
This is Rietveld 408576698