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

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

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 #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. The bool parameter is true iff the current logged in 26 // OWNERSHIP_UNKNOWN.
27 // user is the owner. 27 typedef Callback1<OwnershipService::Status>::Type Callback;
28 typedef Callback2<OwnershipService::Status, bool>::Type Callback;
29 28
30 explicit OwnershipStatusChecker(Callback* callback); 29 explicit OwnershipStatusChecker(Callback* callback);
31 ~OwnershipStatusChecker(); 30 ~OwnershipStatusChecker();
32 31
33 private: 32 private:
34 // The refcounted core that handles the thread switching. 33 // The refcounted core that handles the thread switching.
35 class Core : public base::RefCountedThreadSafe<Core> { 34 class Core : public base::RefCountedThreadSafe<Core> {
36 public: 35 public:
37 explicit Core(Callback* callback); 36 explicit Core(Callback* callback);
38 ~Core(); 37 ~Core();
39 38
40 // Starts the check. 39 // Starts the check.
41 void Check(); 40 void Check();
42 41
43 // Cancels the outstanding callback (if applicable). 42 // Cancels the outstanding callback (if applicable).
44 void Cancel(); 43 void Cancel();
45 44
46 private: 45 private:
47 void CheckOnFileThread(); 46 void CheckOnFileThread();
48 void ReportResult(OwnershipService::Status status, 47 void ReportResult(OwnershipService::Status status);
49 bool current_user_is_owner);
50 48
51 scoped_ptr<Callback> callback_; 49 scoped_ptr<Callback> callback_;
52 scoped_refptr<base::MessageLoopProxy> origin_loop_; 50 scoped_refptr<base::MessageLoopProxy> origin_loop_;
53 51
54 DISALLOW_COPY_AND_ASSIGN(Core); 52 DISALLOW_COPY_AND_ASSIGN(Core);
55 }; 53 };
56 54
57 scoped_refptr<Core> core_; 55 scoped_refptr<Core> core_;
58 56
59 DISALLOW_COPY_AND_ASSIGN(OwnershipStatusChecker); 57 DISALLOW_COPY_AND_ASSIGN(OwnershipStatusChecker);
60 }; 58 };
61 59
62 } // namespace chromeos 60 } // namespace chromeos
63 61
64 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_STATUS_CHECKER_H_ 62 #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