OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_LOADER_H_ |
| 6 #define CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_LOADER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 |
| 15 namespace policy { |
| 16 |
| 17 // Handles disk access and threading details for loading and storing tokens. |
| 18 // This is legacy-support code that reads the token from its prior location |
| 19 // within the profile directory new code keeps the token in the policy blob |
| 20 // maintained by session_manager. |
| 21 class UserPolicyTokenLoader |
| 22 : public base::RefCountedThreadSafe<UserPolicyTokenLoader> { |
| 23 public: |
| 24 // Callback interface for reporting a successful load. |
| 25 class Delegate { |
| 26 public: |
| 27 virtual ~Delegate(); |
| 28 virtual void OnTokenLoaded(const std::string& token, |
| 29 const std::string& device_id) = 0; |
| 30 }; |
| 31 |
| 32 UserPolicyTokenLoader(const base::WeakPtr<Delegate>& delegate, |
| 33 const FilePath& cache_file); |
| 34 |
| 35 // Starts loading the disk cache. After the load is finished, the result is |
| 36 // reported through the delegate. |
| 37 void Load(); |
| 38 |
| 39 private: |
| 40 friend class base::RefCountedThreadSafe<UserPolicyTokenLoader>; |
| 41 ~UserPolicyTokenLoader(); |
| 42 |
| 43 void LoadOnFileThread(); |
| 44 void NotifyOnUIThread(const std::string& token, |
| 45 const std::string& device_id); |
| 46 |
| 47 const base::WeakPtr<Delegate> delegate_; |
| 48 const FilePath cache_file_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(UserPolicyTokenLoader); |
| 51 }; |
| 52 |
| 53 } // namespace policy |
| 54 |
| 55 #endif // CHROME_BROWSER_POLICY_USER_POLICY_TOKEN_LOADER_H_ |
OLD | NEW |