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/login/ownership_service.h" | 5 #include "chrome/browser/chromeos/login/ownership_service.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 return g_ownership_service.Pointer(); | 25 return g_ownership_service.Pointer(); |
26 } | 26 } |
27 | 27 |
28 OwnershipService::OwnershipService() | 28 OwnershipService::OwnershipService() |
29 : manager_(new OwnerManager), | 29 : manager_(new OwnerManager), |
30 utils_(OwnerKeyUtils::Create()), | 30 utils_(OwnerKeyUtils::Create()), |
31 policy_(NULL), | 31 policy_(NULL), |
32 ownership_status_(OWNERSHIP_UNKNOWN) { | 32 ownership_status_(OWNERSHIP_UNKNOWN) { |
33 notification_registrar_.Add( | 33 notification_registrar_.Add( |
34 this, | 34 this, |
35 NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, | 35 chrome::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, |
36 NotificationService::AllSources()); | 36 NotificationService::AllSources()); |
37 } | 37 } |
38 | 38 |
39 OwnershipService::~OwnershipService() {} | 39 OwnershipService::~OwnershipService() {} |
40 | 40 |
41 void OwnershipService::Prewarm() { | 41 void OwnershipService::Prewarm() { |
42 // Note that we cannot prewarm in constructor because in current codebase | 42 // Note that we cannot prewarm in constructor because in current codebase |
43 // object is created before spawning threads. | 43 // object is created before spawning threads. |
44 if (g_ownership_service == this) { | 44 if (g_ownership_service == this) { |
45 // Start getting ownership status. | 45 // Start getting ownership status. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 BrowserThread::FILE, FROM_HERE, | 142 BrowserThread::FILE, FROM_HERE, |
143 NewRunnableFunction(&OwnershipService::TryVerifyAttempt, | 143 NewRunnableFunction(&OwnershipService::TryVerifyAttempt, |
144 this, | 144 this, |
145 thread_id, | 145 thread_id, |
146 data, | 146 data, |
147 signature, | 147 signature, |
148 d)); | 148 d)); |
149 return; | 149 return; |
150 } | 150 } |
151 | 151 |
152 void OwnershipService::Observe(NotificationType type, | 152 void OwnershipService::Observe(int type, |
153 const NotificationSource& source, | 153 const NotificationSource& source, |
154 const NotificationDetails& details) { | 154 const NotificationDetails& details) { |
155 if (type.value == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { | 155 if (type == chrome::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { |
156 SetStatus(OWNERSHIP_TAKEN); | 156 SetStatus(OWNERSHIP_TAKEN); |
157 notification_registrar_.RemoveAll(); | 157 notification_registrar_.RemoveAll(); |
158 } else { | 158 } else { |
159 NOTREACHED(); | 159 NOTREACHED(); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 bool OwnershipService::CurrentUserIsOwner() { | 163 bool OwnershipService::CurrentUserIsOwner() { |
164 // If this user has the private key associated with the owner's | 164 // If this user has the private key associated with the owner's |
165 // public key, this user is the owner. | 165 // public key, this user is the owner. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 SetStatus(status); | 229 SetStatus(status); |
230 } | 230 } |
231 | 231 |
232 void OwnershipService::SetStatus(Status new_status) { | 232 void OwnershipService::SetStatus(Status new_status) { |
233 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE); | 233 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE); |
234 base::AutoLock lk(ownership_status_lock_); | 234 base::AutoLock lk(ownership_status_lock_); |
235 ownership_status_ = new_status; | 235 ownership_status_ = new_status; |
236 } | 236 } |
237 | 237 |
238 } // namespace chromeos | 238 } // namespace chromeos |
OLD | NEW |