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

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

Issue 7741045: Delay the metrics policy migration call to make sure ownership has been taken. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits. Created 9 years, 3 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_status_checker.h" 5 #include "chrome/browser/chromeos/login/ownership_status_checker.h"
6 6
7 #include "content/browser/browser_thread.h" 7 #include "content/browser/browser_thread.h"
8 8
9 namespace chromeos { 9 namespace chromeos {
10 10
(...skipping 10 matching lines...) Expand all
21 : callback_(callback), 21 : callback_(callback),
22 origin_loop_(base::MessageLoopProxy::current()) { 22 origin_loop_(base::MessageLoopProxy::current()) {
23 } 23 }
24 24
25 OwnershipStatusChecker::Core::~Core() {} 25 OwnershipStatusChecker::Core::~Core() {}
26 26
27 void OwnershipStatusChecker::Core::Check() { 27 void OwnershipStatusChecker::Core::Check() {
28 DCHECK(origin_loop_->BelongsToCurrentThread()); 28 DCHECK(origin_loop_->BelongsToCurrentThread());
29 OwnershipService::Status status = 29 OwnershipService::Status status =
30 OwnershipService::GetSharedInstance()->GetStatus(false); 30 OwnershipService::GetSharedInstance()->GetStatus(false);
31 if (status != OwnershipService::OWNERSHIP_UNKNOWN) { 31 // We can only report the OWNERSHIP_NONE status without executing code on the
32 // file thread because checking whether the current user is owner needs file
33 // access.
34 if (status == OwnershipService::OWNERSHIP_NONE) {
32 // Take a spin on the message loop in order to avoid reentrancy in callers. 35 // Take a spin on the message loop in order to avoid reentrancy in callers.
33 origin_loop_->PostTask( 36 origin_loop_->PostTask(
34 FROM_HERE, 37 FROM_HERE,
35 NewRunnableMethod(this, 38 NewRunnableMethod(this,
36 &OwnershipStatusChecker::Core::ReportResult, 39 &OwnershipStatusChecker::Core::ReportResult,
37 status)); 40 status, false));
38 } else { 41 } else {
39 // Switch to the file thread to make the blocking call. 42 // Switch to the file thread to make the blocking call.
40 BrowserThread::PostTask( 43 BrowserThread::PostTask(
41 BrowserThread::FILE, FROM_HERE, 44 BrowserThread::FILE, FROM_HERE,
42 NewRunnableMethod(this, 45 NewRunnableMethod(this,
43 &OwnershipStatusChecker::Core::CheckOnFileThread)); 46 &OwnershipStatusChecker::Core::CheckOnFileThread));
44 } 47 }
45 } 48 }
46 49
47 void OwnershipStatusChecker::Core::Cancel() { 50 void OwnershipStatusChecker::Core::Cancel() {
48 DCHECK(origin_loop_->BelongsToCurrentThread()); 51 DCHECK(origin_loop_->BelongsToCurrentThread());
49 callback_.reset(); 52 callback_.reset();
50 } 53 }
51 54
52 void OwnershipStatusChecker::Core::CheckOnFileThread() { 55 void OwnershipStatusChecker::Core::CheckOnFileThread() {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
54 OwnershipService::Status status = 57 OwnershipService::Status status =
55 OwnershipService::GetSharedInstance()->GetStatus(true); 58 OwnershipService::GetSharedInstance()->GetStatus(true);
59 bool current_user_is_owner =
60 OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
56 origin_loop_->PostTask( 61 origin_loop_->PostTask(
57 FROM_HERE, 62 FROM_HERE,
58 NewRunnableMethod(this, 63 NewRunnableMethod(this,
59 &OwnershipStatusChecker::Core::ReportResult, 64 &OwnershipStatusChecker::Core::ReportResult,
60 status)); 65 status, current_user_is_owner));
61 } 66 }
62 67
63 void OwnershipStatusChecker::Core::ReportResult( 68 void OwnershipStatusChecker::Core::ReportResult(
64 OwnershipService::Status status) { 69 OwnershipService::Status status, bool current_user_is_owner) {
65 DCHECK(origin_loop_->BelongsToCurrentThread()); 70 DCHECK(origin_loop_->BelongsToCurrentThread());
66 if (callback_.get()) { 71 if (callback_.get()) {
67 callback_->Run(status); 72 callback_->Run(status, current_user_is_owner);
68 callback_.reset(); 73 callback_.reset();
69 } 74 }
70 } 75 }
71 76
72 } // namespace chromeos 77 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ownership_status_checker.h ('k') | chrome/browser/chromeos/login/signed_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698