Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chrome/browser/chromeos/login/ownership_service.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/login/ownership_service.h" 5 #include "chrome/browser/chromeos/login/ownership_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "content/browser/browser_thread.h" 15 #include "content/browser/browser_thread.h"
16 #include "content/public/browser/notification_service.h"
16 17
17 namespace chromeos { 18 namespace chromeos {
18 19
19 static base::LazyInstance<OwnershipService> g_ownership_service( 20 static base::LazyInstance<OwnershipService> g_ownership_service(
20 base::LINKER_INITIALIZED); 21 base::LINKER_INITIALIZED);
21 22
22 // static 23 // static
23 OwnershipService* OwnershipService::GetSharedInstance() { 24 OwnershipService* OwnershipService::GetSharedInstance() {
24 return g_ownership_service.Pointer(); 25 return g_ownership_service.Pointer();
25 } 26 }
26 27
27 OwnershipService::OwnershipService() 28 OwnershipService::OwnershipService()
28 : manager_(new OwnerManager), 29 : manager_(new OwnerManager),
29 utils_(OwnerKeyUtils::Create()), 30 utils_(OwnerKeyUtils::Create()),
30 policy_(NULL), 31 policy_(NULL),
31 ownership_status_(OWNERSHIP_UNKNOWN) { 32 ownership_status_(OWNERSHIP_UNKNOWN) {
32 notification_registrar_.Add( 33 notification_registrar_.Add(
33 this, 34 this,
34 chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 35 chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
35 NotificationService::AllSources()); 36 content::NotificationService::AllSources());
36 } 37 }
37 38
38 OwnershipService::~OwnershipService() {} 39 OwnershipService::~OwnershipService() {}
39 40
40 void OwnershipService::Prewarm() { 41 void OwnershipService::Prewarm() {
41 // Note that we cannot prewarm in constructor because in current codebase 42 // Note that we cannot prewarm in constructor because in current codebase
42 // object is created before spawning threads. 43 // object is created before spawning threads.
43 if (g_ownership_service == this) { 44 if (g_ownership_service == this) {
44 // Start getting ownership status. 45 // Start getting ownership status.
45 BrowserThread::PostTask( 46 BrowserThread::PostTask(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 SetStatus(status); 218 SetStatus(status);
218 } 219 }
219 220
220 void OwnershipService::SetStatus(Status new_status) { 221 void OwnershipService::SetStatus(Status new_status) {
221 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE); 222 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE);
222 base::AutoLock lk(ownership_status_lock_); 223 base::AutoLock lk(ownership_status_lock_);
223 ownership_status_ = new_status; 224 ownership_status_ = new_status;
224 } 225 }
225 226
226 } // namespace chromeos 227 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ownership_service.h ('k') | chrome/browser/chromeos/login/ownership_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698