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

Side by Side Diff: chrome/browser/policy/user_policy_token_cache.h

Issue 7298012: Consolidate data storage and notifications in the cloud policy subsystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 5 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_POLICY_USER_POLICY_TOKEN_CACHE_H_ 5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_CACHE_H_
6 #define CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_CACHE_H_ 6 #define CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_CACHE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
Joao da Silva 2011/07/06 16:45:14 Nit: weak_ptr.h not used
gfeher 2011/07/07 13:51:00 Now that you mention, I actually reintroduce using
15 #include "chrome/browser/policy/cloud_policy_data.h"
15 #include "chrome/browser/policy/proto/device_management_local.pb.h" 16 #include "chrome/browser/policy/proto/device_management_local.pb.h"
Joao da Silva 2011/07/06 16:45:14 Nit: move device_management_local.pb.h to .cc
gfeher 2011/07/07 13:51:00 Done.
16 17
17 namespace policy { 18 namespace policy {
18 19
19 // Responsible for managing the on-disk token cache. 20 // Responsible for managing the on-disk token cache.
20 class UserPolicyTokenCache 21 class UserPolicyTokenCache
21 : public base::RefCountedThreadSafe<UserPolicyTokenCache> { 22 : public base::RefCountedThreadSafe<UserPolicyTokenCache>,
23 public CloudPolicyData::Observer {
22 public: 24 public:
23 // Callback interface for reporting a successfull load. 25 UserPolicyTokenCache(CloudPolicyData* data,
24 class Delegate {
25 public:
26 virtual ~Delegate();
27 virtual void OnTokenCacheLoaded(const std::string& token,
28 const std::string& device_id) = 0;
29 };
30
31 UserPolicyTokenCache(const base::WeakPtr<Delegate>& delegate,
32 const FilePath& cache_file); 26 const FilePath& cache_file);
33 27
34 // Starts loading the disk cache. After the load is finished, the result is 28 // Starts loading the disk cache. After the load is finished, the result is
35 // reported through the delegate. 29 // reported through the delegate.
36 void Load(); 30 void Load();
37 31
38 // Stores credentials asynchronously to disk. 32 // Stores credentials asynchronously to disk.
39 void Store(const std::string& token, const std::string& device_id); 33 void Store(const std::string& token, const std::string& device_id);
40 34
35 // CloudPolicyData::Observer implementation:
36 virtual void OnDeviceTokenChanged() OVERRIDE;
37 virtual void OnCredentialsChanged() OVERRIDE;
38 virtual void OnPolicyDataGoingAway() OVERRIDE;
39
41 private: 40 private:
42 friend class base::RefCountedThreadSafe<UserPolicyTokenCache>; 41 friend class base::RefCountedThreadSafe<UserPolicyTokenCache>;
43 ~UserPolicyTokenCache(); 42 virtual ~UserPolicyTokenCache();
44 43
45 void LoadOnFileThread(); 44 void LoadOnFileThread();
46 void NotifyOnUIThread(const std::string& token, 45 void NotifyOnUIThread(const std::string& token,
47 const std::string& device_id); 46 const std::string& device_id);
48 void StoreOnFileThread(const std::string& token, 47 void StoreOnFileThread(const std::string& token,
49 const std::string& device_id); 48 const std::string& device_id);
50 49
51 const base::WeakPtr<Delegate> delegate_; 50 CloudPolicyData* data_;
52 const FilePath cache_file_; 51 const FilePath cache_file_;
53 52
54 DISALLOW_COPY_AND_ASSIGN(UserPolicyTokenCache); 53 DISALLOW_COPY_AND_ASSIGN(UserPolicyTokenCache);
55 }; 54 };
56 55
57 } // namespace policy 56 } // namespace policy
58 57
59 #endif // CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_CACHE_H_ 58 #endif // CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698