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

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

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 9 years 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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "chrome/browser/chromeos/login/owner_key_utils.h" 15 #include "chrome/browser/chromeos/login/owner_key_utils.h"
16 #include "chrome/browser/chromeos/login/owner_manager.h" 16 #include "chrome/browser/chromeos/login/owner_manager.h"
17 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
18 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
21 20
22 namespace base { 21 namespace base {
23 template <typename T> struct DefaultLazyInstanceTraits; 22 template <typename T> struct DefaultLazyInstanceTraits;
24 } 23 }
25 24
26 namespace em = enterprise_management;
27 namespace chromeos { 25 namespace chromeos {
28 26
29 class OwnershipService : public content::NotificationObserver { 27 class OwnershipService : public content::NotificationObserver {
30 public: 28 public:
31 enum Status { 29 enum Status {
32 // Listed in upgrade order. 30 // Listed in upgrade order.
33 OWNERSHIP_UNKNOWN = 0, 31 OWNERSHIP_UNKNOWN = 0,
34 OWNERSHIP_NONE, 32 OWNERSHIP_NONE,
35 OWNERSHIP_TAKEN 33 OWNERSHIP_TAKEN
36 }; 34 };
37 35
38 // Returns the singleton instance of the OwnershipService. 36 // Returns the singleton instance of the OwnershipService.
39 static OwnershipService* GetSharedInstance(); 37 static OwnershipService* GetSharedInstance();
40 virtual ~OwnershipService(); 38 virtual ~OwnershipService();
41 39
42 // Called after FILE thread is created to prefetch ownership status and avoid 40 // Called after FILE thread is created to prefetch ownership status and avoid
43 // blocking on UI thread. 41 // blocking on UI thread.
44 void Prewarm(); 42 void Prewarm();
45 43
46 // Owner settings are being re-implemented as a single, signed protobuf
47 // that is stored by the session manager. Thus, to write a setting, you
48 // need to have the existing policy, update it, re-sign it, and then have
49 // it stored. This could be done by requesting the policy every time, or
50 // by caching it and updating it upon every successful store.
51 // Caching is faster and easier, so we'll do that. These are the
52 // getters/setters for the cached policy.
53 virtual void set_cached_policy(const em::PolicyData& pol);
54 virtual bool has_cached_policy();
55 virtual const em::PolicyData& cached_policy();
56
57 // Sets a new owner key. This will _not_ load the key material from disk, but 44 // Sets a new owner key. This will _not_ load the key material from disk, but
58 // rather update Chrome's in-memory copy of the key. |callback| will be 45 // rather update Chrome's in-memory copy of the key. |callback| will be
59 // invoked once the operation completes. 46 // invoked once the operation completes.
60 virtual void StartUpdateOwnerKey(const std::vector<uint8>& new_key, 47 virtual void StartUpdateOwnerKey(const std::vector<uint8>& new_key,
61 OwnerManager::KeyUpdateDelegate* d); 48 OwnerManager::KeyUpdateDelegate* d);
62 49
63 // If the device has been owned already, posts a task to the FILE thread to 50 // If the device has been owned already, posts a task to the FILE thread to
64 // fetch the public key off disk. 51 // fetch the public key off disk.
65 // 52 //
66 // Sends out a OWNER_KEY_FETCH_ATTEMPT_SUCCESS notification on success, 53 // Sends out a OWNER_KEY_FETCH_ATTEMPT_SUCCESS notification on success,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const content::BrowserThread::ID thread_id, 117 const content::BrowserThread::ID thread_id,
131 const std::string& data, 118 const std::string& data,
132 const std::vector<uint8>& signature, 119 const std::vector<uint8>& signature,
133 OwnerManager::Delegate* d); 120 OwnerManager::Delegate* d);
134 static void FailAttempt(OwnerManager::Delegate* d); 121 static void FailAttempt(OwnerManager::Delegate* d);
135 122
136 OwnerManager* manager() { return manager_.get(); } 123 OwnerManager* manager() { return manager_.get(); }
137 124
138 scoped_refptr<OwnerManager> manager_; 125 scoped_refptr<OwnerManager> manager_;
139 scoped_refptr<OwnerKeyUtils> utils_; 126 scoped_refptr<OwnerKeyUtils> utils_;
140 scoped_ptr<em::PolicyData> policy_;
141 content::NotificationRegistrar notification_registrar_; 127 content::NotificationRegistrar notification_registrar_;
142 volatile Status ownership_status_; 128 volatile Status ownership_status_;
143 base::Lock ownership_status_lock_; 129 base::Lock ownership_status_lock_;
144 }; 130 };
145 131
146 } // namespace chromeos 132 } // namespace chromeos
147 133
148 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ 134 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698