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

Unified Diff: chrome/browser/chromeos/tether/tether_service_factory.cc

Issue 2900903002: Create a FakeTetherService, which stubs out TetherService for development. (Closed)
Patch Set: Rebase. Created 3 years, 7 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: chrome/browser/chromeos/tether/tether_service_factory.cc
diff --git a/chrome/browser/chromeos/tether/tether_service_factory.cc b/chrome/browser/chromeos/tether/tether_service_factory.cc
index da33cc9260605bc7eb70ff385cc0e8cb5adab31c..eef06b3b6c1e080e3ded977a482b950a15addbe5 100644
--- a/chrome/browser/chromeos/tether/tether_service_factory.cc
+++ b/chrome/browser/chromeos/tether/tether_service_factory.cc
@@ -4,10 +4,14 @@
#include "chrome/browser/chromeos/tether/tether_service_factory.h"
+#include "base/command_line.h"
#include "base/memory/singleton.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/chromeos/tether/fake_tether_service.h"
#include "chrome/browser/cryptauth/chrome_cryptauth_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
+#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state_handler.h"
@@ -40,13 +44,29 @@ KeyedService* TetherServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
DCHECK(chromeos::NetworkHandler::IsInitialized());
- return new TetherService(
- Profile::FromBrowserContext(context),
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
- chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
- ChromeCryptAuthServiceFactory::GetForBrowserContext(
- Profile::FromBrowserContext(context)),
- chromeos::NetworkHandler::Get()->network_state_handler());
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(chromeos::switches::kTetherStub)) {
+ int num_tether_networks = 0;
+ base::StringToInt(
+ command_line->GetSwitchValueASCII(chromeos::switches::kTetherStub),
+ &num_tether_networks);
+
+ return new FakeTetherService(
+ num_tether_networks, Profile::FromBrowserContext(context),
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
+ chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
+ ChromeCryptAuthServiceFactory::GetForBrowserContext(
+ Profile::FromBrowserContext(context)),
+ chromeos::NetworkHandler::Get()->network_state_handler());
+ } else {
stevenjb 2017/05/23 22:24:33 no else
Ryan Hansberry 2017/05/23 22:53:12 Done.
+ return new TetherService(
+ Profile::FromBrowserContext(context),
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
+ chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
+ ChromeCryptAuthServiceFactory::GetForBrowserContext(
+ Profile::FromBrowserContext(context)),
+ chromeos::NetworkHandler::Get()->network_state_handler());
+ }
}
void TetherServiceFactory::RegisterProfilePrefs(

Powered by Google App Engine
This is Rietveld 408576698