Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / user_policy_token_loader.h
blob919e4aef43bc7e99b6d7dceaf776d62ebd1972ec
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TOKEN_LOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TOKEN_LOADER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
15 namespace base {
16 class SequencedTaskRunner;
19 namespace policy {
21 // Handles disk access and threading details for loading and storing tokens.
22 // This is legacy-support code that reads the token from its prior location
23 // within the profile directory new code keeps the token in the policy blob
24 // maintained by session_manager.
25 class UserPolicyTokenLoader
26 : public base::RefCountedThreadSafe<UserPolicyTokenLoader> {
27 public:
28 // Callback interface for reporting a successful load.
29 class Delegate {
30 public:
31 virtual ~Delegate();
32 virtual void OnTokenLoaded(const std::string& token,
33 const std::string& device_id) = 0;
36 UserPolicyTokenLoader(
37 const base::WeakPtr<Delegate>& delegate,
38 const base::FilePath& cache_file,
39 scoped_refptr<base::SequencedTaskRunner> background_task_runner);
41 // Starts loading the disk cache. After the load is finished, the result is
42 // reported through the delegate.
43 void Load();
45 private:
46 friend class base::RefCountedThreadSafe<UserPolicyTokenLoader>;
47 ~UserPolicyTokenLoader();
49 void LoadOnBackgroundThread();
50 void NotifyOnOriginThread(const std::string& token,
51 const std::string& device_id);
53 const base::WeakPtr<Delegate> delegate_;
54 const base::FilePath cache_file_;
55 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_;
56 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
58 DISALLOW_COPY_AND_ASSIGN(UserPolicyTokenLoader);
61 } // namespace policy
63 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TOKEN_LOADER_H_