Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login/signed_settings_helper.h" | 5 #include "chrome/browser/chromeos/login/signed_settings_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 12 #include "base/singleton.h" | |
| 13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
| 14 #include "chrome/browser/chromeos/login/signed_settings.h" | 14 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class OpContext { | 20 class OpContext { |
| 21 public: | 21 public: |
| 22 class Delegate { | 22 class Delegate { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 | 255 |
| 256 private: | 256 private: |
| 257 SignedSettingsHelperImpl(); | 257 SignedSettingsHelperImpl(); |
| 258 ~SignedSettingsHelperImpl(); | 258 ~SignedSettingsHelperImpl(); |
| 259 | 259 |
| 260 void AddOpContext(OpContext* context); | 260 void AddOpContext(OpContext* context); |
| 261 void ClearAll(); | 261 void ClearAll(); |
| 262 | 262 |
| 263 std::vector<OpContext*> pending_contexts_; | 263 std::vector<OpContext*> pending_contexts_; |
| 264 | 264 |
| 265 friend struct DefaultSingletonTraits<SignedSettingsHelperImpl>; | 265 friend struct base::DefaultLazyInstanceTraits<SignedSettingsHelperImpl>; |
| 266 DISALLOW_COPY_AND_ASSIGN(SignedSettingsHelperImpl); | 266 DISALLOW_COPY_AND_ASSIGN(SignedSettingsHelperImpl); |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 static base::LazyInstance<SignedSettingsHelperImpl> | |
|
Evan Martin
2010/12/13 17:38:30
*
| |
| 270 g_signed_settings_helper_impl(base::LINKER_INITIALIZED); | |
| 271 | |
| 269 SignedSettingsHelperImpl::SignedSettingsHelperImpl() { | 272 SignedSettingsHelperImpl::SignedSettingsHelperImpl() { |
| 270 } | 273 } |
| 271 | 274 |
| 272 SignedSettingsHelperImpl::~SignedSettingsHelperImpl() { | 275 SignedSettingsHelperImpl::~SignedSettingsHelperImpl() { |
| 273 if (!pending_contexts_.empty()) { | 276 if (!pending_contexts_.empty()) { |
| 274 LOG(WARNING) << "SignedSettingsHelperImpl shutdown with pending ops, " | 277 LOG(WARNING) << "SignedSettingsHelperImpl shutdown with pending ops, " |
| 275 << "changes will be lost."; | 278 << "changes will be lost."; |
| 276 ClearAll(); | 279 ClearAll(); |
| 277 } | 280 } |
| 278 } | 281 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 | 367 |
| 365 pending_contexts_.erase(pending_contexts_.begin()); | 368 pending_contexts_.erase(pending_contexts_.begin()); |
| 366 if (!pending_contexts_.empty()) | 369 if (!pending_contexts_.empty()) |
| 367 pending_contexts_.front()->Execute(); | 370 pending_contexts_.front()->Execute(); |
| 368 | 371 |
| 369 if (test_delegate_) | 372 if (test_delegate_) |
| 370 test_delegate_->OnOpCompleted(context->op()); | 373 test_delegate_->OnOpCompleted(context->op()); |
| 371 } | 374 } |
| 372 | 375 |
| 373 SignedSettingsHelper* SignedSettingsHelper::Get() { | 376 SignedSettingsHelper* SignedSettingsHelper::Get() { |
| 374 return Singleton<SignedSettingsHelperImpl>::get(); | 377 return g_signed_settings_helper_impl.Pointer(); |
| 375 } | 378 } |
| 376 | 379 |
| 377 } // namespace chromeos | 380 } // namespace chromeos |
| OLD | NEW |