OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_CHROMEOS_DRIVE_SYNC_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace drive { | 24 namespace drive { |
25 | 25 |
26 class FileCacheEntry; | 26 class FileCacheEntry; |
27 class JobScheduler; | 27 class JobScheduler; |
28 class ResourceEntry; | 28 class ResourceEntry; |
29 struct ClientContext; | 29 struct ClientContext; |
30 | 30 |
31 namespace file_system { | 31 namespace file_system { |
32 class DownloadOperation; | 32 class DownloadOperation; |
33 class OperationObserver; | 33 class OperationDelegate; |
34 } | 34 } |
35 | 35 |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 class ChangeListLoader; | 38 class ChangeListLoader; |
39 class EntryUpdatePerformer; | 39 class EntryUpdatePerformer; |
40 class FileCache; | 40 class FileCache; |
41 class LoaderController; | 41 class LoaderController; |
42 class ResourceMetadata; | 42 class ResourceMetadata; |
43 | 43 |
44 // The SyncClient is used to synchronize pinned files on Drive and the | 44 // The SyncClient is used to synchronize pinned files on Drive and the |
45 // cache on the local drive. | 45 // cache on the local drive. |
46 // | 46 // |
47 // If the user logs out before fetching of the pinned files is complete, this | 47 // If the user logs out before fetching of the pinned files is complete, this |
48 // client resumes fetching operations next time the user logs in, based on | 48 // client resumes fetching operations next time the user logs in, based on |
49 // the states left in the cache. | 49 // the states left in the cache. |
50 class SyncClient { | 50 class SyncClient { |
51 public: | 51 public: |
52 SyncClient(base::SequencedTaskRunner* blocking_task_runner, | 52 SyncClient(base::SequencedTaskRunner* blocking_task_runner, |
53 file_system::OperationObserver* observer, | 53 file_system::OperationDelegate* delegate, |
54 JobScheduler* scheduler, | 54 JobScheduler* scheduler, |
55 ResourceMetadata* metadata, | 55 ResourceMetadata* metadata, |
56 FileCache* cache, | 56 FileCache* cache, |
57 LoaderController* loader_controller, | 57 LoaderController* loader_controller, |
58 const base::FilePath& temporary_file_directory); | 58 const base::FilePath& temporary_file_directory); |
59 virtual ~SyncClient(); | 59 virtual ~SyncClient(); |
60 | 60 |
61 // Adds a fetch task. | 61 // Adds a fetch task. |
62 void AddFetchTask(const std::string& local_id); | 62 void AddFetchTask(const std::string& local_id); |
63 | 63 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 const std::string& local_id, | 157 const std::string& local_id, |
158 FileError error); | 158 FileError error); |
159 | 159 |
160 // Called when the file for |local_id| is fetched. | 160 // Called when the file for |local_id| is fetched. |
161 void OnFetchFileComplete(const std::string& local_id, | 161 void OnFetchFileComplete(const std::string& local_id, |
162 FileError error, | 162 FileError error, |
163 const base::FilePath& local_path, | 163 const base::FilePath& local_path, |
164 scoped_ptr<ResourceEntry> entry); | 164 scoped_ptr<ResourceEntry> entry); |
165 | 165 |
166 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 166 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
167 file_system::OperationObserver* operation_observer_; | 167 file_system::OperationDelegate* operation_delegate_; |
168 ResourceMetadata* metadata_; | 168 ResourceMetadata* metadata_; |
169 FileCache* cache_; | 169 FileCache* cache_; |
170 | 170 |
171 // Used to fetch pinned files. | 171 // Used to fetch pinned files. |
172 scoped_ptr<file_system::DownloadOperation> download_operation_; | 172 scoped_ptr<file_system::DownloadOperation> download_operation_; |
173 | 173 |
174 // Used to update entry metadata. | 174 // Used to update entry metadata. |
175 scoped_ptr<EntryUpdatePerformer> entry_update_performer_; | 175 scoped_ptr<EntryUpdatePerformer> entry_update_performer_; |
176 | 176 |
177 // Sync tasks to be processed. | 177 // Sync tasks to be processed. |
178 SyncTasks tasks_; | 178 SyncTasks tasks_; |
179 | 179 |
180 // The delay is used for delaying processing tasks in AddTask(). | 180 // The delay is used for delaying processing tasks in AddTask(). |
181 base::TimeDelta delay_; | 181 base::TimeDelta delay_; |
182 | 182 |
183 // The delay is used for delaying retry of tasks on server errors. | 183 // The delay is used for delaying retry of tasks on server errors. |
184 base::TimeDelta long_delay_; | 184 base::TimeDelta long_delay_; |
185 | 185 |
186 // Note: This should remain the last member so it'll be destroyed and | 186 // Note: This should remain the last member so it'll be destroyed and |
187 // invalidate its weak pointers before any other members are destroyed. | 187 // invalidate its weak pointers before any other members are destroyed. |
188 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; | 188 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; |
189 | 189 |
190 DISALLOW_COPY_AND_ASSIGN(SyncClient); | 190 DISALLOW_COPY_AND_ASSIGN(SyncClient); |
191 }; | 191 }; |
192 | 192 |
193 } // namespace internal | 193 } // namespace internal |
194 } // namespace drive | 194 } // namespace drive |
195 | 195 |
196 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ | 196 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ |
OLD | NEW |