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

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

Issue 2900903002: Create a FakeTetherService, which stubs out TetherService for development. (Closed)
Patch Set: Fix TetherService tests. 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..400aa6a132815ff872c66825543b34f4069388c1 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,6 +44,25 @@ KeyedService* TetherServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
DCHECK(chromeos::NetworkHandler::IsInitialized());
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(chromeos::switches::kTetherStub)) {
+ FakeTetherService* fake_tether_service = new FakeTetherService(
+ Profile::FromBrowserContext(context),
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
+ chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
+ ChromeCryptAuthServiceFactory::GetForBrowserContext(
+ Profile::FromBrowserContext(context)),
+ chromeos::NetworkHandler::Get()->network_state_handler());
+
+ int num_tether_networks = 0;
+ base::StringToInt(
+ command_line->GetSwitchValueASCII(chromeos::switches::kTetherStub),
+ &num_tether_networks);
+ fake_tether_service->set_num_tether_networks(num_tether_networks);
+
+ return fake_tether_service;
+ }
+
return new TetherService(
Profile::FromBrowserContext(context),
chromeos::DBusThreadManager::Get()->GetPowerManagerClient(),
« no previous file with comments | « chrome/browser/chromeos/tether/tether_service.cc ('k') | chrome/browser/chromeos/tether/tether_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698