| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // States of sync tasks. | 94 // States of sync tasks. |
| 95 enum SyncState { | 95 enum SyncState { |
| 96 PENDING, | 96 PENDING, |
| 97 RUNNING, | 97 RUNNING, |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 struct SyncTask { | 100 struct SyncTask { |
| 101 SyncTask(); | 101 SyncTask(); |
| 102 ~SyncTask(); | 102 ~SyncTask(); |
| 103 SyncState state; | 103 SyncState state; |
| 104 base::Closure task; | 104 base::Callback<base::Closure()> task; |
| 105 bool should_run_again; | 105 bool should_run_again; |
| 106 base::Closure cancel_closure; | 106 base::Closure cancel_closure; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 typedef std::map<std::pair<SyncType, std::string>, SyncTask> SyncTasks; | 109 typedef std::map<std::pair<SyncType, std::string>, SyncTask> SyncTasks; |
| 110 | 110 |
| 111 // Adds a FETCH task. | 111 // Adds a FETCH task. |
| 112 void AddFetchTaskInternal(const std::string& local_id, | 112 void AddFetchTaskInternal(const std::string& local_id, |
| 113 const base::TimeDelta& delay); | 113 const base::TimeDelta& delay); |
| 114 | 114 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 125 // Called when a task is ready to start. | 125 // Called when a task is ready to start. |
| 126 void StartTask(const SyncTasks::key_type& key); | 126 void StartTask(const SyncTasks::key_type& key); |
| 127 | 127 |
| 128 // Called when the local IDs of files in the backlog are obtained. | 128 // Called when the local IDs of files in the backlog are obtained. |
| 129 void OnGetLocalIdsOfBacklog(const std::vector<std::string>* to_fetch, | 129 void OnGetLocalIdsOfBacklog(const std::vector<std::string>* to_fetch, |
| 130 const std::vector<std::string>* to_update); | 130 const std::vector<std::string>* to_update); |
| 131 | 131 |
| 132 // Adds fetch tasks. | 132 // Adds fetch tasks. |
| 133 void AddFetchTasks(const std::vector<std::string>* local_ids); | 133 void AddFetchTasks(const std::vector<std::string>* local_ids); |
| 134 | 134 |
| 135 // Used as GetFileContentInitializedCallback. | |
| 136 void OnGetFileContentInitialized( | |
| 137 FileError error, | |
| 138 scoped_ptr<ResourceEntry> entry, | |
| 139 const base::FilePath& local_cache_file_path, | |
| 140 const base::Closure& cancel_download_closure); | |
| 141 | |
| 142 // Erases the task and returns true if task is completed. | 135 // Erases the task and returns true if task is completed. |
| 143 bool OnTaskComplete(SyncType type, const std::string& local_id); | 136 bool OnTaskComplete(SyncType type, const std::string& local_id); |
| 144 | 137 |
| 145 // Called when the file for |local_id| is fetched. | 138 // Called when the file for |local_id| is fetched. |
| 146 void OnFetchFileComplete(const std::string& local_id, | 139 void OnFetchFileComplete(const std::string& local_id, |
| 147 FileError error, | 140 FileError error, |
| 148 const base::FilePath& local_path, | 141 const base::FilePath& local_path, |
| 149 scoped_ptr<ResourceEntry> entry); | 142 scoped_ptr<ResourceEntry> entry); |
| 150 | 143 |
| 151 // Called when the entry is updated. | 144 // Called when the entry is updated. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 179 // invalidate its weak pointers before any other members are destroyed. | 172 // invalidate its weak pointers before any other members are destroyed. |
| 180 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; | 173 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; |
| 181 | 174 |
| 182 DISALLOW_COPY_AND_ASSIGN(SyncClient); | 175 DISALLOW_COPY_AND_ASSIGN(SyncClient); |
| 183 }; | 176 }; |
| 184 | 177 |
| 185 } // namespace internal | 178 } // namespace internal |
| 186 } // namespace drive | 179 } // namespace drive |
| 187 | 180 |
| 188 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ | 181 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ |
| OLD | NEW |