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

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

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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback_old.h" 10 #include "base/callback_old.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop_proxy.h" 13 #include "base/message_loop_proxy.h"
14 #include "chrome/browser/chromeos/login/ownership_service.h" 14 #include "chrome/browser/chromeos/login/ownership_service.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 // A helper that does ownership checking on the file thread and reports back the 18 // A helper that does ownership checking on the file thread and reports back the
19 // result on whatever thread the call was made on. The pattern is to construct 19 // result on whatever thread the call was made on. The pattern is to construct
20 // a checker, passing in the callback. Once the check is done, the callback will 20 // a checker, passing in the callback. Once the check is done, the callback will
21 // be invoked with the result. In order to cancel the callback, just destroy the 21 // be invoked with the result. In order to cancel the callback, just destroy the
22 // checker object. 22 // checker object.
23 class OwnershipStatusChecker { 23 class OwnershipStatusChecker {
24 public: 24 public:
25 // Callback function type. The status code is guaranteed to be different from 25 // Callback function type. The status code is guaranteed to be different from
26 // OWNERSHIP_UNKNOWN. 26 // OWNERSHIP_UNKNOWN. The bool parameter is true iff the current logged in
27 typedef Callback1<OwnershipService::Status>::Type Callback; 27 // user is the owner.
28 typedef Callback2<OwnershipService::Status, bool>::Type Callback;
28 29
29 explicit OwnershipStatusChecker(Callback* callback); 30 explicit OwnershipStatusChecker(Callback* callback);
30 ~OwnershipStatusChecker(); 31 ~OwnershipStatusChecker();
31 32
32 private: 33 private:
33 // The refcounted core that handles the thread switching. 34 // The refcounted core that handles the thread switching.
34 class Core : public base::RefCountedThreadSafe<Core> { 35 class Core : public base::RefCountedThreadSafe<Core> {
35 public: 36 public:
36 explicit Core(Callback* callback); 37 explicit Core(Callback* callback);
37 ~Core(); 38 ~Core();
38 39
39 // Starts the check. 40 // Starts the check.
40 void Check(); 41 void Check();
41 42
42 // Cancels the outstanding callback (if applicable). 43 // Cancels the outstanding callback (if applicable).
43 void Cancel(); 44 void Cancel();
44 45
45 private: 46 private:
46 void CheckOnFileThread(); 47 void CheckOnFileThread();
47 void ReportResult(OwnershipService::Status status); 48 void ReportResult(OwnershipService::Status status,
49 bool current_user_is_owner);
48 50
49 scoped_ptr<Callback> callback_; 51 scoped_ptr<Callback> callback_;
50 scoped_refptr<base::MessageLoopProxy> origin_loop_; 52 scoped_refptr<base::MessageLoopProxy> origin_loop_;
51 53
52 DISALLOW_COPY_AND_ASSIGN(Core); 54 DISALLOW_COPY_AND_ASSIGN(Core);
53 }; 55 };
54 56
55 scoped_refptr<Core> core_; 57 scoped_refptr<Core> core_;
56 58
57 DISALLOW_COPY_AND_ASSIGN(OwnershipStatusChecker); 59 DISALLOW_COPY_AND_ASSIGN(OwnershipStatusChecker);
58 }; 60 };
59 61
60 } // namespace chromeos 62 } // namespace chromeos
61 63
62 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_ 64 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.cc ('k') | chrome/browser/chromeos/login/ownership_status_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698