| Index: chrome/browser/chromeos/cros/cros_library.h
|
| diff --git a/chrome/browser/chromeos/cros/cros_library.h b/chrome/browser/chromeos/cros/cros_library.h
|
| index 76650abd0a1c8b65af176e52731e30f18263ec69..3f3b7b568f122a32a4e741742b74152b1a1ace76 100644
|
| --- a/chrome/browser/chromeos/cros/cros_library.h
|
| +++ b/chrome/browser/chromeos/cros/cros_library.h
|
| @@ -9,7 +9,6 @@
|
| #include <string>
|
| #include "base/basictypes.h"
|
| #include "base/singleton.h"
|
| -
|
| namespace chromeos {
|
|
|
| class CryptohomeLibrary;
|
| @@ -32,12 +31,14 @@ class UpdateLibrary;
|
| // be mocked for testing.
|
| class CrosLibrary {
|
| public:
|
| -
|
| // This class provides access to internal members of CrosLibrary class for
|
| // purpose of testing (i.e. replacement of members' implementation with
|
| // mock objects).
|
| class TestApi {
|
| public:
|
| + // Use the stub implementations of the library. This is mainly for
|
| + // running the chromeos build of chrome on the desktop.
|
| + void SetUseStubImpl();
|
| // 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.
|
| @@ -137,35 +138,58 @@ class CrosLibrary {
|
| virtual ~CrosLibrary();
|
|
|
| LibraryLoader* library_loader_;
|
| - CryptohomeLibrary* crypto_lib_;
|
| - KeyboardLibrary* keyboard_lib_;
|
| - InputMethodLibrary* input_method_lib_;
|
| - LoginLibrary* login_lib_;
|
| - MountLibrary* mount_lib_;
|
| - NetworkLibrary* network_lib_;
|
| - PowerLibrary* power_lib_;
|
| - ScreenLockLibrary* screen_lock_lib_;
|
| - SpeechSynthesisLibrary* speech_synthesis_lib_;
|
| - SynapticsLibrary* synaptics_lib_;
|
| - SyslogsLibrary* syslogs_lib_;
|
| - SystemLibrary* system_lib_;
|
| - UpdateLibrary* update_lib_;
|
| -
|
| bool own_library_loader_;
|
| - bool own_cryptohome_lib_;
|
| - bool own_keyboard_lib_;
|
| - bool own_input_method_lib_;
|
| - bool own_login_lib_;
|
| - bool own_mount_lib_;
|
| - bool own_network_lib_;
|
| - bool own_power_lib_;
|
| - bool own_screen_lock_lib_;
|
| - bool own_speech_synthesis_lib_;
|
| - bool own_synaptics_lib_;
|
| - bool own_syslogs_lib_;
|
| - bool own_system_lib_;
|
| - bool own_update_lib_;
|
|
|
| + // This template supports the creation, setting and optional deletion of
|
| + // the cros libraries.
|
| + template <class L>
|
| + class Library {
|
| + public:
|
| + Library() : library_(NULL), own_(true) {}
|
| +
|
| + ~Library() {
|
| + if (own_)
|
| + delete library_;
|
| + }
|
| +
|
| + L* GetDefaultImpl(bool use_stub_impl) {
|
| + if (!library_) {
|
| + own_ = true;
|
| + library_ = L::GetImpl(use_stub_impl);
|
| + }
|
| + return library_;
|
| + }
|
| +
|
| + void SetImpl(L* library, bool own) {
|
| + if (library != library_) {
|
| + if (own_)
|
| + delete library_;
|
| + library_ = library;
|
| + own_ = own;
|
| + }
|
| + }
|
| +
|
| + private:
|
| + L* library_;
|
| + bool own_;
|
| + };
|
| +
|
| + Library<CryptohomeLibrary> crypto_lib_;
|
| + Library<KeyboardLibrary> keyboard_lib_;
|
| + Library<InputMethodLibrary> input_method_lib_;
|
| + Library<LoginLibrary> login_lib_;
|
| + Library<MountLibrary> mount_lib_;
|
| + Library<NetworkLibrary> network_lib_;
|
| + Library<PowerLibrary> power_lib_;
|
| + Library<ScreenLockLibrary> screen_lock_lib_;
|
| + Library<SpeechSynthesisLibrary> speech_synthesis_lib_;
|
| + Library<SynapticsLibrary> synaptics_lib_;
|
| + Library<SyslogsLibrary> syslogs_lib_;
|
| + Library<SystemLibrary> system_lib_;
|
| + Library<UpdateLibrary> update_lib_;
|
| +
|
| + // Stub implementations of the libraries should be used.
|
| + bool use_stub_impl_;
|
| // True if libcros was successfully loaded.
|
| bool loaded_;
|
| // True if the last load attempt had an error.
|
|
|