Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/cros/cros_library.h" | 5 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/cros/brightness_library.h" | 7 #include "chrome/browser/chromeos/cros/brightness_library.h" |
| 8 #include "chrome/browser/chromeos/cros/burn_library.h" | 8 #include "chrome/browser/chromeos/cros/burn_library.h" |
| 9 #include "chrome/browser/chromeos/cros/cert_library.h" | 9 #include "chrome/browser/chromeos/cros/cert_library.h" |
| 10 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 10 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 11 #include "chrome/browser/chromeos/cros/libcros_service_library.h" | 11 #include "chrome/browser/chromeos/cros/libcros_service_library.h" |
| 12 #include "chrome/browser/chromeos/cros/library_loader.h" | 12 #include "chrome/browser/chromeos/cros/library_loader.h" |
| 13 #include "chrome/browser/chromeos/cros/login_library.h" | 13 #include "chrome/browser/chromeos/cros/login_library.h" |
| 14 #include "chrome/browser/chromeos/cros/mount_library.h" | 14 #include "chrome/browser/chromeos/cros/mount_library.h" |
| 15 #include "chrome/browser/chromeos/cros/network_library.h" | 15 #include "chrome/browser/chromeos/cros/network_library.h" |
| 16 #include "chrome/browser/chromeos/cros/power_library.h" | 16 #include "chrome/browser/chromeos/cros/power_library.h" |
| 17 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | 17 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
| 18 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" | 18 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" |
| 19 #include "chrome/browser/chromeos/cros/update_library.h" | 19 #include "chrome/browser/chromeos/cros/update_library.h" |
| 20 #include "third_party/cros/chromeos_cros_api.h" | 20 #include "third_party/cros/chromeos_cros_api.h" |
| 21 | 21 |
| 22 // Pass !libcros_loaded_ to GetDefaultImpl instead of use_stub_impl_ so that | |
| 23 // we load the stub impl regardless of whether use_stub was specified or the | |
| 24 // library failed to load. | |
| 22 #define DEFINE_GET_LIBRARY_METHOD(class_prefix, var_prefix) \ | 25 #define DEFINE_GET_LIBRARY_METHOD(class_prefix, var_prefix) \ |
| 23 class_prefix##Library* CrosLibrary::Get##class_prefix##Library() { \ | 26 class_prefix##Library* CrosLibrary::Get##class_prefix##Library() { \ |
| 24 return var_prefix##_lib_.GetDefaultImpl(use_stub_impl_); \ | 27 return var_prefix##_lib_.GetDefaultImpl(!libcros_loaded_); \ |
| 25 } | 28 } |
| 26 | 29 |
| 27 #define DEFINE_SET_LIBRARY_METHOD(class_prefix, var_prefix) \ | 30 #define DEFINE_SET_LIBRARY_METHOD(class_prefix, var_prefix) \ |
| 28 void CrosLibrary::TestApi::Set##class_prefix##Library( \ | 31 void CrosLibrary::TestApi::Set##class_prefix##Library( \ |
| 29 class_prefix##Library* library, bool own) { \ | 32 class_prefix##Library* library, bool own) { \ |
| 30 library_->var_prefix##_lib_.SetImpl(library, own); \ | 33 library_->var_prefix##_lib_.SetImpl(library, own); \ |
| 31 } | 34 } |
| 32 | 35 |
| 33 namespace chromeos { | 36 namespace chromeos { |
| 34 | 37 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 51 // static | 54 // static |
| 52 void CrosLibrary::Initialize(bool use_stub) { | 55 void CrosLibrary::Initialize(bool use_stub) { |
| 53 CHECK(!g_cros_library) << "CrosLibrary: Multiple calls to Initialize()."; | 56 CHECK(!g_cros_library) << "CrosLibrary: Multiple calls to Initialize()."; |
| 54 g_cros_library = new CrosLibrary(use_stub); | 57 g_cros_library = new CrosLibrary(use_stub); |
| 55 if (use_stub) { | 58 if (use_stub) { |
| 56 VLOG(1) << "CrosLibrary Initialized with Stub Impl."; | 59 VLOG(1) << "CrosLibrary Initialized with Stub Impl."; |
| 57 return; | 60 return; |
| 58 } | 61 } |
| 59 // Attempt to load libcros here, so that we can log, show warnings, and | 62 // Attempt to load libcros here, so that we can log, show warnings, and |
| 60 // set load_error_string_ immediately. | 63 // set load_error_string_ immediately. |
| 61 if (g_cros_library->LoadLibcros()) | 64 if (g_cros_library->LoadLibcros()) { |
| 62 VLOG(1) << "CrosLibrary Initialized, version = " << kCrosAPIVersion; | 65 VLOG(1) << "CrosLibrary Initialized, version = " << kCrosAPIVersion; |
| 63 else | 66 } else { |
| 64 LOG(WARNING) << "CrosLibrary failed to Initialize."; | 67 LOG(WARNING) << "CrosLibrary failed to Initialize." |
| 68 << " Will use stub implementations."; | |
|
satorux1
2011/09/16 20:05:55
This is okay for Linux desktop, but I think this s
stevenjb
2011/09/16 21:44:24
I actually prefer to use a warning here. We alread
satorux1
2011/09/16 21:59:43
I misunderstood. I thought you changed this from a
| |
| 69 } | |
| 65 } | 70 } |
| 66 | 71 |
| 67 // static | 72 // static |
| 68 void CrosLibrary::Shutdown() { | 73 void CrosLibrary::Shutdown() { |
| 69 CHECK(g_cros_library) << "CrosLibrary::Shutdown() called with NULL library"; | 74 CHECK(g_cros_library) << "CrosLibrary::Shutdown() called with NULL library"; |
| 70 VLOG(1) << "CrosLibrary Shutting down..."; | 75 VLOG(1) << "CrosLibrary Shutting down..."; |
| 71 delete g_cros_library; | 76 delete g_cros_library; |
| 72 g_cros_library = NULL; | 77 g_cros_library = NULL; |
| 73 VLOG(1) << " CrosLibrary Shutdown completed."; | 78 VLOG(1) << " CrosLibrary Shutdown completed."; |
| 74 } | 79 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 DEFINE_SET_LIBRARY_METHOD(LibCrosService, libcros_service); | 140 DEFINE_SET_LIBRARY_METHOD(LibCrosService, libcros_service); |
| 136 DEFINE_SET_LIBRARY_METHOD(Login, login); | 141 DEFINE_SET_LIBRARY_METHOD(Login, login); |
| 137 DEFINE_SET_LIBRARY_METHOD(Mount, mount); | 142 DEFINE_SET_LIBRARY_METHOD(Mount, mount); |
| 138 DEFINE_SET_LIBRARY_METHOD(Network, network); | 143 DEFINE_SET_LIBRARY_METHOD(Network, network); |
| 139 DEFINE_SET_LIBRARY_METHOD(Power, power); | 144 DEFINE_SET_LIBRARY_METHOD(Power, power); |
| 140 DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock); | 145 DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock); |
| 141 DEFINE_SET_LIBRARY_METHOD(SpeechSynthesis, speech_synthesis); | 146 DEFINE_SET_LIBRARY_METHOD(SpeechSynthesis, speech_synthesis); |
| 142 DEFINE_SET_LIBRARY_METHOD(Update, update); | 147 DEFINE_SET_LIBRARY_METHOD(Update, update); |
| 143 | 148 |
| 144 } // namespace chromeos | 149 } // namespace chromeos |
| OLD | NEW |