diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 19:14:27 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 19:14:27 +0000 |
commit | 66149a5cbd355757e63a82b9d3280cc6e0d36da8 (patch) | |
tree | 50df6fded94acde0224be8d8deb82bb673937ce2 | |
parent | db92eeb9e9003acddf76ba1237630134be67ae56 (diff) | |
download | chromium_src-66149a5cbd355757e63a82b9d3280cc6e0d36da8.zip chromium_src-66149a5cbd355757e63a82b9d3280cc6e0d36da8.tar.gz chromium_src-66149a5cbd355757e63a82b9d3280cc6e0d36da8.tar.bz2 |
Add --dbus-stub for testing dbus stub implementations on a device.
Change-Id: I4730996e6a860833ce7e66792d62dbd1f6db00ea
BUG=none
TEST=Add --dbus-stub to /sbin/session_manager_startup.sh; dbus stub implementation should be used for non-critical components (e.g. power manager)
Review URL: https://chromiumcodereview.appspot.com/10392029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136629 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/login_utils.cc | 94 | ||||
-rw-r--r-- | chromeos/chromeos.gyp | 2 | ||||
-rw-r--r-- | chromeos/chromeos_switches.cc | 14 | ||||
-rw-r--r-- | chromeos/chromeos_switches.h | 29 | ||||
-rw-r--r-- | chromeos/dbus/dbus_thread_manager.cc | 44 | ||||
-rw-r--r-- | chromeos/dbus/dbus_thread_manager.h | 2 |
6 files changed, 125 insertions, 60 deletions
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 17e958b..8fa6b17 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -69,6 +69,7 @@ #include "chrome/common/net/gaia/gaia_urls.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/session_manager_client.h" #include "content/public/browser/browser_thread.h" @@ -1041,62 +1042,63 @@ std::string LoginUtilsImpl::GetOffTheRecordCommandLine( const CommandLine& base_command_line, CommandLine* command_line) { static const char* kForwardSwitches[] = { - switches::kCompressSystemFeedback, - switches::kDeviceManagementUrl, - switches::kDefaultDeviceScaleFactor, - switches::kDisableAccelerated2dCanvas, - switches::kDisableAcceleratedPlugins, - switches::kDisableGpuWatchdog, - switches::kDisableLoginAnimations, - switches::kDisableSeccompFilterSandbox, - switches::kDisableSeccompSandbox, - switches::kDisableThreadedAnimation, - switches::kEnableDevicePolicy, - switches::kEnableGView, - switches::kEnableLogging, - switches::kEnablePartialSwap, - switches::kEnableSmoothScrolling, - switches::kEnableThreadedCompositing, - switches::kEnableTouchEvents, - switches::kEnableViewport, - switches::kDisableThreadedCompositing, - switches::kForceCompositingMode, - switches::kGpuStartupDialog, - switches::kLoginProfile, - switches::kScrollPixels, - switches::kNoFirstRun, - switches::kNoSandbox, - switches::kPpapiFlashArgs, - switches::kPpapiFlashInProcess, - switches::kPpapiFlashPath, - switches::kPpapiFlashVersion, - switches::kRendererStartupDialog, - switches::kFlingTapSuppressMaxDown, - switches::kFlingTapSuppressMaxGap, - switches::kTouchDevices, - switches::kTouchOptimizedUI, + ::switches::kCompressSystemFeedback, + ::switches::kDeviceManagementUrl, + ::switches::kDefaultDeviceScaleFactor, + ::switches::kDisableAccelerated2dCanvas, + ::switches::kDisableAcceleratedPlugins, + ::switches::kDisableGpuWatchdog, + ::switches::kDisableLoginAnimations, + ::switches::kDisableSeccompFilterSandbox, + ::switches::kDisableSeccompSandbox, + ::switches::kDisableThreadedAnimation, + ::switches::kEnableDevicePolicy, + ::switches::kEnableGView, + ::switches::kEnableLogging, + ::switches::kEnablePartialSwap, + ::switches::kEnableSmoothScrolling, + ::switches::kEnableThreadedCompositing, + ::switches::kEnableTouchEvents, + ::switches::kEnableViewport, + ::switches::kDisableThreadedCompositing, + ::switches::kForceCompositingMode, + ::switches::kGpuStartupDialog, + ::switches::kLoginProfile, + ::switches::kScrollPixels, + ::switches::kNoFirstRun, + ::switches::kNoSandbox, + ::switches::kPpapiFlashArgs, + ::switches::kPpapiFlashInProcess, + ::switches::kPpapiFlashPath, + ::switches::kPpapiFlashVersion, + ::switches::kRendererStartupDialog, + ::switches::kFlingTapSuppressMaxDown, + ::switches::kFlingTapSuppressMaxGap, + ::switches::kTouchDevices, + ::switches::kTouchOptimizedUI, ash::switches::kAuraLegacyPowerButton, ash::switches::kAuraNoShadows, ash::switches::kAuraPanelManager, ash::switches::kAuraWindowAnimationsDisabled, - switches::kUIEnablePartialSwap, - switches::kUseGL, - switches::kUserDataDir, + ::switches::kUIEnablePartialSwap, + ::switches::kUseGL, + ::switches::kUserDataDir, #if defined(USE_VIRTUAL_KEYBOARD) // The virtual keyboard extension (chrome://keyboard) highly relies on // experimental APIs. - switches::kEnableExperimentalExtensionApis, + ::switches::kEnableExperimentalExtensionApis, #endif + chromeos::switches::kDbusStub, }; command_line->CopySwitchesFrom(base_command_line, kForwardSwitches, arraysize(kForwardSwitches)); - command_line->AppendSwitch(switches::kGuestSession); - command_line->AppendSwitch(switches::kIncognito); - command_line->AppendSwitchASCII(switches::kLoggingLevel, + command_line->AppendSwitch(::switches::kGuestSession); + command_line->AppendSwitch(::switches::kIncognito); + command_line->AppendSwitchASCII(::switches::kLoggingLevel, kGuestModeLoggingLevel); - command_line->AppendSwitchASCII(switches::kLoginUser, kGuestUserName); + command_line->AppendSwitchASCII(::switches::kLoginUser, kGuestUserName); if (start_url.is_valid()) command_line->AppendArg(start_url.spec()); @@ -1104,19 +1106,19 @@ std::string LoginUtilsImpl::GetOffTheRecordCommandLine( // Override the value of the homepage that is set in first run mode. // TODO(altimofeev): extend action of the |kNoFirstRun| to cover this case. command_line->AppendSwitchASCII( - switches::kHomePage, + ::switches::kHomePage, GURL(chrome::kChromeUINewTabURL).spec()); std::string cmd_line_str = command_line->GetCommandLineString(); // Special workaround for the arguments that should be quoted. // Copying switches won't be needed when Guest mode won't need restart // http://crosbug.com/6924 - if (base_command_line.HasSwitch(switches::kRegisterPepperPlugins)) { + if (base_command_line.HasSwitch(::switches::kRegisterPepperPlugins)) { cmd_line_str += base::StringPrintf( kSwitchFormatString, - switches::kRegisterPepperPlugins, + ::switches::kRegisterPepperPlugins, base_command_line.GetSwitchValueNative( - switches::kRegisterPepperPlugins).c_str()); + ::switches::kRegisterPepperPlugins).c_str()); } return cmd_line_str; diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index f06f8b6..c2c1a3f 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -20,6 +20,8 @@ ], 'sources': [ 'chromeos_export.h', + 'chromeos_switches.cc', + 'chromeos_switches.h', 'dbus/blocking_method_caller.cc', 'dbus/blocking_method_caller.h', 'dbus/bluetooth_adapter_client.cc', diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc new file mode 100644 index 0000000..2c1e3ad --- /dev/null +++ b/chromeos/chromeos_switches.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/chromeos_switches.h" + +namespace chromeos { +namespace switches { + +// Forces the stub implementation of dbus clients. +const char kDbusStub[] = "dbus-stub"; + +} // namespace switches +} // namespace chromeos diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h new file mode 100644 index 0000000..5b33dea --- /dev/null +++ b/chromeos/chromeos_switches.h @@ -0,0 +1,29 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_CHROMEOS_SWITCHES_H_ +#define CHROMEOS_CHROMEOS_SWITCHES_H_ +#pragma once + +#include "chromeos/chromeos_export.h" + +namespace chromeos { +namespace switches { + +// Switches that are used in src/chromeos must go here. +// Other switches that apply just to chromeos code should go here also (along +// with any code that is specific to the chromeos system). ChromeOS specific UI +// should be in src/ash. + +// Note: If you add a switch, consider if it needs to be copied to a subsequent +// command line if the process executes a new copy of itself. (For example, +// see chromeos::LoginUtil::GetOffTheRecordCommandLine().) + +// Please keep alphabetized. +CHROMEOS_EXPORT extern const char kDbusStub[]; + +} // namespace switches +} // namespace chromeos + +#endif // CHROMEOS_CHROMEOS_SWITCHES_H_ diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index 421c2cb..ca436a2 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -5,7 +5,9 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "base/chromeos/chromeos_version.h" +#include "base/command_line.h" #include "base/threading/thread.h" +#include "chromeos/chromeos_switches.h" #include "chromeos/dbus/bluetooth_adapter_client.h" #include "chromeos/dbus/bluetooth_device_client.h" #include "chromeos/dbus/bluetooth_input_client.h" @@ -38,8 +40,15 @@ static DBusThreadManager* g_dbus_thread_manager = NULL; // The DBusThreadManager implementation used in production. class DBusThreadManagerImpl : public DBusThreadManager { public: - DBusThreadManagerImpl() { - // Create the D-Bus thread. + explicit DBusThreadManagerImpl(DBusClientImplementationType client_type) { + // If --dbus-stub was requested, pass STUB to specific components; + // Many components like login are not useful with a stub implementation. + DBusClientImplementationType client_type_maybe_stub = client_type; + if (CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kDbusStub)) + client_type_maybe_stub = STUB_DBUS_CLIENT_IMPLEMENTATION; + + // Create the D-Bus thread. base::Thread::Options thread_options; thread_options.message_loop_type = MessageLoop::TYPE_IO; dbus_thread_.reset(new base::Thread("D-Bus thread")); @@ -53,11 +62,6 @@ class DBusThreadManagerImpl : public DBusThreadManager { dbus_thread_->message_loop_proxy(); system_bus_ = new dbus::Bus(system_bus_options); - // Determine whether we use stub or real client implementations. - const DBusClientImplementationType client_type = - base::chromeos::IsRunningOnChromeOS() ? - REAL_DBUS_CLIENT_IMPLEMENTATION : STUB_DBUS_CLIENT_IMPLEMENTATION; - // Create the bluetooth clients. bluetooth_manager_client_.reset(BluetoothManagerClient::Create( client_type, system_bus_.get())); @@ -108,8 +112,8 @@ class DBusThreadManagerImpl : public DBusThreadManager { introspectable_client_.reset( IntrospectableClient::Create(client_type, system_bus_.get())); // Create the power manager client. - power_manager_client_.reset(PowerManagerClient::Create(client_type, - system_bus_.get())); + power_manager_client_.reset( + PowerManagerClient::Create(client_type_maybe_stub, system_bus_.get())); // Create the session manager client. session_manager_client_.reset( SessionManagerClient::Create(client_type, system_bus_.get())); @@ -277,8 +281,16 @@ void DBusThreadManager::Initialize() { LOG(WARNING) << "DBusThreadManager was already initialized"; return; } - g_dbus_thread_manager = new DBusThreadManagerImpl; - VLOG(1) << "DBusThreadManager initialized"; + // Determine whether we use stub or real client implementations. + if (base::chromeos::IsRunningOnChromeOS()) { + g_dbus_thread_manager = + new DBusThreadManagerImpl(REAL_DBUS_CLIENT_IMPLEMENTATION); + VLOG(1) << "DBusThreadManager initialized for ChromeOS"; + } else { + g_dbus_thread_manager = + new DBusThreadManagerImpl(STUB_DBUS_CLIENT_IMPLEMENTATION); + VLOG(1) << "DBusThreadManager initialized with Stub"; + } } // static @@ -288,8 +300,14 @@ void DBusThreadManager::InitializeForTesting( LOG(WARNING) << "DBusThreadManager was already initialized"; return; } - g_dbus_thread_manager = dbus_thread_manager; - VLOG(1) << "DBusThreadManager initialized"; + if (dbus_thread_manager) { + g_dbus_thread_manager = dbus_thread_manager; + VLOG(1) << "DBusThreadManager initialized with test implementation"; + } else { + g_dbus_thread_manager = + new DBusThreadManagerImpl(STUB_DBUS_CLIENT_IMPLEMENTATION); + VLOG(1) << "DBusThreadManager initialized with stub implementation"; + } } // static diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h index 648be05..742bb09 100644 --- a/chromeos/dbus/dbus_thread_manager.h +++ b/chromeos/dbus/dbus_thread_manager.h @@ -72,7 +72,7 @@ class CHROMEOS_EXPORT DBusThreadManager { // Similar to Initialize(), but can inject an alternative // DBusThreadManager such as MockDBusThreadManager for testing. // The injected object will be owned by the internal pointer and deleted - // by Shutdown(). + // by Shutdown(). If NULL, a stub implementation will be constructed. static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); // Destroys the global instance. |