OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 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 #include <string> | |
6 | |
7 #include "base/file_path.h" | |
8 #include "base/task.h" | |
9 | |
10 class ProfileSyncService; | |
11 | |
12 // The TokenMigrator provides a bridge between the IO thread and | |
13 // the UI thread to load the old-style credentials from the user | |
14 // settings DB, and post them back to the UI thread to store the | |
15 // token in the token service. | |
16 class TokenMigrator { | |
17 public: | |
18 TokenMigrator(ProfileSyncService* service, | |
19 const FilePath& profile_path); | |
20 ~TokenMigrator(); | |
21 | |
22 // This is called on the UI thread, it only posts a task. | |
23 // If migration succeeds, the tokens will become available in | |
24 // the token service. | |
25 void TryMigration(); | |
26 | |
27 private: | |
28 // This runs as a deferred task on the IO thread. | |
tim (not reviewing)
2010/09/07 22:01:52
nit- s / IO / DB
| |
29 void LoadTokens(); | |
30 | |
31 // This runs as a deferred task on the UI thread (only after the IO thread is | |
tim (not reviewing)
2010/09/07 22:01:52
nit s/IO/DB
| |
32 // finished with the data. | |
33 void PostTokensBack(); | |
34 | |
35 // The username and token retrieved from the user settings DB. | |
36 std::string username_; | |
37 std::string token_; | |
38 | |
39 // The ProfileSyncService owns this object, so this pointer is valid when | |
40 // PostTokensBack is called. | |
41 ProfileSyncService* service_; | |
42 | |
43 // Pending tasks, stored so they can be canceled if this object is destroyed. | |
44 CancelableTask* loading_task_; | |
45 | |
46 // The directory to search for the user settings database. | |
47 FilePath database_location_; | |
tim (not reviewing)
2010/09/07 22:01:52
DISALLOW_COPY_AND_ASSIGN
| |
48 }; | |
49 | |
50 // We ensure this object will outlive its tasks, so don't need refcounting. | |
51 DISABLE_RUNNABLE_METHOD_REFCOUNT(TokenMigrator); | |
OLD | NEW |