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_
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"
16 class SequencedTaskRunner
;
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
> {
28 // Callback interface for reporting a successful load.
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.
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
);
63 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TOKEN_LOADER_H_