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

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

Issue 7830020: Revert 99169 - 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: 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 // We can only report the OWNERSHIP_NONE status without executing code on the 31 if (status != OwnershipService::OWNERSHIP_UNKNOWN) {
32 // file thread because checking whether the current user is owner needs file
33 // access.
34 if (status == OwnershipService::OWNERSHIP_NONE) {
35 // Take a spin on the message loop in order to avoid reentrancy in callers. 32 // Take a spin on the message loop in order to avoid reentrancy in callers.
36 origin_loop_->PostTask( 33 origin_loop_->PostTask(
37 FROM_HERE, 34 FROM_HERE,
38 NewRunnableMethod(this, 35 NewRunnableMethod(this,
39 &OwnershipStatusChecker::Core::ReportResult, 36 &OwnershipStatusChecker::Core::ReportResult,
40 status, false)); 37 status));
41 } else { 38 } else {
42 // Switch to the file thread to make the blocking call. 39 // Switch to the file thread to make the blocking call.
43 BrowserThread::PostTask( 40 BrowserThread::PostTask(
44 BrowserThread::FILE, FROM_HERE, 41 BrowserThread::FILE, FROM_HERE,
45 NewRunnableMethod(this, 42 NewRunnableMethod(this,
46 &OwnershipStatusChecker::Core::CheckOnFileThread)); 43 &OwnershipStatusChecker::Core::CheckOnFileThread));
47 } 44 }
48 } 45 }
49 46
50 void OwnershipStatusChecker::Core::Cancel() { 47 void OwnershipStatusChecker::Core::Cancel() {
51 DCHECK(origin_loop_->BelongsToCurrentThread()); 48 DCHECK(origin_loop_->BelongsToCurrentThread());
52 callback_.reset(); 49 callback_.reset();
53 } 50 }
54 51
55 void OwnershipStatusChecker::Core::CheckOnFileThread() { 52 void OwnershipStatusChecker::Core::CheckOnFileThread() {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
57 OwnershipService::Status status = 54 OwnershipService::Status status =
58 OwnershipService::GetSharedInstance()->GetStatus(true); 55 OwnershipService::GetSharedInstance()->GetStatus(true);
59 bool current_user_is_owner =
60 OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
61 origin_loop_->PostTask( 56 origin_loop_->PostTask(
62 FROM_HERE, 57 FROM_HERE,
63 NewRunnableMethod(this, 58 NewRunnableMethod(this,
64 &OwnershipStatusChecker::Core::ReportResult, 59 &OwnershipStatusChecker::Core::ReportResult,
65 status, current_user_is_owner)); 60 status));
66 } 61 }
67 62
68 void OwnershipStatusChecker::Core::ReportResult( 63 void OwnershipStatusChecker::Core::ReportResult(
69 OwnershipService::Status status, bool current_user_is_owner) { 64 OwnershipService::Status status) {
70 DCHECK(origin_loop_->BelongsToCurrentThread()); 65 DCHECK(origin_loop_->BelongsToCurrentThread());
71 if (callback_.get()) { 66 if (callback_.get()) {
72 callback_->Run(status, current_user_is_owner); 67 callback_->Run(status);
73 callback_.reset(); 68 callback_.reset();
74 } 69 }
75 } 70 }
76 71
77 } // namespace chromeos 72 } // 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