summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/cros/cros_library.cc175
-rw-r--r--chrome/browser/chromeos/cros/cros_library.h50
2 files changed, 46 insertions, 179 deletions
diff --git a/chrome/browser/chromeos/cros/cros_library.cc b/chrome/browser/chromeos/cros/cros_library.cc
index 8efd3e1..af6e426 100644
--- a/chrome/browser/chromeos/cros/cros_library.cc
+++ b/chrome/browser/chromeos/cros/cros_library.cc
@@ -22,6 +22,18 @@
#include "chrome/browser/chromeos/cros/touchpad_library.h"
#include "chrome/browser/chromeos/cros/update_library.h"
+#define DEFINE_GET_LIBRARY_METHOD(class_prefix, var_prefix) \
+class_prefix##Library* CrosLibrary::Get##class_prefix##Library() { \
+ return var_prefix##_lib_.GetDefaultImpl(use_stub_impl_); \
+}
+
+#define DEFINE_SET_LIBRARY_METHOD(class_prefix, var_prefix) \
+void CrosLibrary::TestApi::Set##class_prefix##Library( \
+ class_prefix##Library* library, bool own) { \
+ library_->var_prefix##_lib_.SetImpl(library, own); \
+}
+
+
namespace chromeos {
static base::LazyInstance<CrosLibrary> g_cros_library(
@@ -45,65 +57,21 @@ CrosLibrary* CrosLibrary::Get() {
return g_cros_library.Pointer();
}
-BrightnessLibrary* CrosLibrary::GetBrightnessLibrary() {
- return brightness_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-BurnLibrary* CrosLibrary::GetBurnLibrary() {
- return burn_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-CryptohomeLibrary* CrosLibrary::GetCryptohomeLibrary() {
- return crypto_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-KeyboardLibrary* CrosLibrary::GetKeyboardLibrary() {
- return keyboard_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-InputMethodLibrary* CrosLibrary::GetInputMethodLibrary() {
- return input_method_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-LoginLibrary* CrosLibrary::GetLoginLibrary() {
- return login_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-MountLibrary* CrosLibrary::GetMountLibrary() {
- return mount_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-NetworkLibrary* CrosLibrary::GetNetworkLibrary() {
- return network_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-PowerLibrary* CrosLibrary::GetPowerLibrary() {
- return power_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-ScreenLockLibrary* CrosLibrary::GetScreenLockLibrary() {
- return screen_lock_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-SpeechSynthesisLibrary* CrosLibrary::GetSpeechSynthesisLibrary() {
- return speech_synthesis_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-SyslogsLibrary* CrosLibrary::GetSyslogsLibrary() {
- return syslogs_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-SystemLibrary* CrosLibrary::GetSystemLibrary() {
- return system_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-TouchpadLibrary* CrosLibrary::GetTouchpadLibrary() {
- return touchpad_lib_.GetDefaultImpl(use_stub_impl_);
-}
-
-UpdateLibrary* CrosLibrary::GetUpdateLibrary() {
- return update_lib_.GetDefaultImpl(use_stub_impl_);
-}
+DEFINE_GET_LIBRARY_METHOD(Brightness, brightness);
+DEFINE_GET_LIBRARY_METHOD(Burn, burn);
+DEFINE_GET_LIBRARY_METHOD(Cryptohome, crypto);
+DEFINE_GET_LIBRARY_METHOD(Keyboard, keyboard);
+DEFINE_GET_LIBRARY_METHOD(InputMethod, input_method);
+DEFINE_GET_LIBRARY_METHOD(Login, login);
+DEFINE_GET_LIBRARY_METHOD(Mount, mount);
+DEFINE_GET_LIBRARY_METHOD(Network, network);
+DEFINE_GET_LIBRARY_METHOD(Power, power);
+DEFINE_GET_LIBRARY_METHOD(ScreenLock, screen_lock);
+DEFINE_GET_LIBRARY_METHOD(SpeechSynthesis, speech_synthesis);
+DEFINE_GET_LIBRARY_METHOD(Syslogs, syslogs);
+DEFINE_GET_LIBRARY_METHOD(System, system);
+DEFINE_GET_LIBRARY_METHOD(Touchpad, touchpad);
+DEFINE_GET_LIBRARY_METHOD(Update, update);
bool CrosLibrary::EnsureLoaded() {
if (use_stub_impl_)
@@ -147,79 +115,20 @@ void CrosLibrary::TestApi::SetLibraryLoader(LibraryLoader* loader, bool own) {
library_->load_error_ = false;
}
-void CrosLibrary::TestApi::SetBrightnessLibrary(
- BrightnessLibrary* library, bool own) {
- library_->brightness_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetBurnLibrary(
- BurnLibrary* library, bool own) {
- library_->burn_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetCryptohomeLibrary(
- CryptohomeLibrary* library, bool own) {
- library_->crypto_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetKeyboardLibrary(
- KeyboardLibrary* library, bool own) {
- library_->keyboard_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetInputMethodLibrary(
- InputMethodLibrary* library, bool own) {
- library_->input_method_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetLoginLibrary(
- LoginLibrary* library, bool own) {
- library_->login_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetMountLibrary(
- MountLibrary* library, bool own) {
- library_->mount_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetNetworkLibrary(
- NetworkLibrary* library, bool own) {
- library_->network_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetPowerLibrary(
- PowerLibrary* library, bool own) {
- library_->power_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetScreenLockLibrary(
- ScreenLockLibrary* library, bool own) {
- library_->screen_lock_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetSpeechSynthesisLibrary(
- SpeechSynthesisLibrary* library, bool own) {
- library_->speech_synthesis_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetTouchpadLibrary(
- TouchpadLibrary* library, bool own) {
- library_->touchpad_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetSyslogsLibrary(
- SyslogsLibrary* library, bool own) {
- library_->syslogs_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetSystemLibrary(
- SystemLibrary* library, bool own) {
- library_->system_lib_.SetImpl(library, own);
-}
-
-void CrosLibrary::TestApi::SetUpdateLibrary(
- UpdateLibrary* library, bool own) {
- library_->update_lib_.SetImpl(library, own);
-}
+DEFINE_SET_LIBRARY_METHOD(Brightness, brightness);
+DEFINE_SET_LIBRARY_METHOD(Burn, burn);
+DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto);
+DEFINE_SET_LIBRARY_METHOD(Keyboard, keyboard);
+DEFINE_SET_LIBRARY_METHOD(InputMethod, input_method);
+DEFINE_SET_LIBRARY_METHOD(Login, login);
+DEFINE_SET_LIBRARY_METHOD(Mount, mount);
+DEFINE_SET_LIBRARY_METHOD(Network, network);
+DEFINE_SET_LIBRARY_METHOD(Power, power);
+DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock);
+DEFINE_SET_LIBRARY_METHOD(SpeechSynthesis, speech_synthesis);
+DEFINE_SET_LIBRARY_METHOD(Syslogs, syslogs);
+DEFINE_SET_LIBRARY_METHOD(System, system);
+DEFINE_SET_LIBRARY_METHOD(Touchpad, touchpad);
+DEFINE_SET_LIBRARY_METHOD(Update, update);
} // namespace chromeos
diff --git a/chrome/browser/chromeos/cros/cros_library.h b/chrome/browser/chromeos/cros/cros_library.h
index deb2dfc6..9c5810c 100644
--- a/chrome/browser/chromeos/cros/cros_library.h
+++ b/chrome/browser/chromeos/cros/cros_library.h
@@ -21,8 +21,8 @@ namespace chromeos {
class BrightnessLibrary;
class BurnLibrary;
class CryptohomeLibrary;
-class KeyboardLibrary;
class InputMethodLibrary;
+class KeyboardLibrary;
class LibraryLoader;
class LoginLibrary;
class MountLibrary;
@@ -48,42 +48,29 @@ class CrosLibrary {
// Use the stub implementations of the library. This is mainly for
// running the chromeos build of chrome on the desktop.
void SetUseStubImpl();
+
// Reset the stub implementations of the library, called after
// SetUseStubImp is called.
void ResetUseStubImpl();
+
// Passing true for own for these setters will cause them to be deleted
// when the CrosLibrary is deleted (or other mocks are set).
// Setter for LibraryLoader.
void SetLibraryLoader(LibraryLoader* loader, bool own);
- // Setter for BrightnessLibrary.
void SetBrightnessLibrary(BrightnessLibrary* library, bool own);
- // Setter for BurnLibrary.
void SetBurnLibrary(BurnLibrary* library, bool own);
- // Setter for CryptohomeLibrary.
void SetCryptohomeLibrary(CryptohomeLibrary* library, bool own);
- // Setter for KeyboardLibrary
void SetKeyboardLibrary(KeyboardLibrary* library, bool own);
- // Setter for InputMethodLibrary
void SetInputMethodLibrary(InputMethodLibrary* library, bool own);
- // Setter for LoginLibrary.
void SetLoginLibrary(LoginLibrary* library, bool own);
- // Setter for MountLibrary.
void SetMountLibrary(MountLibrary* library, bool own);
- // Setter for NetworkLibrary.
void SetNetworkLibrary(NetworkLibrary* library, bool own);
- // Setter for PowerLibrary.
void SetPowerLibrary(PowerLibrary* library, bool own);
- // Setter for ScreenLockLibrary.
void SetScreenLockLibrary(ScreenLockLibrary* library, bool own);
- // Setter for SpeechSynthesisLibrary.
void SetSpeechSynthesisLibrary(SpeechSynthesisLibrary* library, bool own);
- // Setter for SyslogsLibrary.
void SetSyslogsLibrary(SyslogsLibrary* library, bool own);
- // Setter for SystemLibrary.
void SetSystemLibrary(SystemLibrary* library, bool own);
- // Setter for TouchpadLibrary.
void SetTouchpadLibrary(TouchpadLibrary* library, bool own);
- // Setter for UpdateLibrary.
void SetUpdateLibrary(UpdateLibrary* library, bool own);
private:
@@ -95,49 +82,20 @@ class CrosLibrary {
// This gets the CrosLibrary.
static CrosLibrary* Get();
- // Getter for BrightnessLibrary.
BrightnessLibrary* GetBrightnessLibrary();
-
- // Getter for BurnLibrary.
BurnLibrary* GetBurnLibrary();
-
- // Getter for CryptohomeLibrary.
CryptohomeLibrary* GetCryptohomeLibrary();
-
- // Getter for KeyboardLibrary
- KeyboardLibrary* GetKeyboardLibrary();
-
- // Getter for InputMethodLibrary
InputMethodLibrary* GetInputMethodLibrary();
-
- // Getter for LoginLibrary.
+ KeyboardLibrary* GetKeyboardLibrary();
LoginLibrary* GetLoginLibrary();
-
- // Getter for MountLibrary
MountLibrary* GetMountLibrary();
-
- // Getter for NetworkLibrary
NetworkLibrary* GetNetworkLibrary();
-
- // Getter for PowerLibrary
PowerLibrary* GetPowerLibrary();
-
- // Getter for ScreenLockLibrary
ScreenLockLibrary* GetScreenLockLibrary();
-
- // This gets the singleton SpeechSynthesisLibrary.
SpeechSynthesisLibrary* GetSpeechSynthesisLibrary();
-
- // This gets the singleton SyslogsLibrary.
SyslogsLibrary* GetSyslogsLibrary();
-
- // This gets the singleton SystemLibrary.
SystemLibrary* GetSystemLibrary();
-
- // This gets the singleton TouchpadLibrary.
TouchpadLibrary* GetTouchpadLibrary();
-
- // This gets the singleton UpdateLibrary.
UpdateLibrary* GetUpdateLibrary();
// Getter for Test API that gives access to internal members of this class.