Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/chromeos/drive/sync_client.h

Issue 68543002: drive: Support offline delete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to drive/other and mark as deleted Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 15 matching lines...) Expand all
26 26
27 namespace file_system { 27 namespace file_system {
28 class DownloadOperation; 28 class DownloadOperation;
29 class OperationObserver; 29 class OperationObserver;
30 class UpdateOperation; 30 class UpdateOperation;
31 } 31 }
32 32
33 namespace internal { 33 namespace internal {
34 34
35 class FileCache; 35 class FileCache;
36 class RemovePerformer;
36 class ResourceMetadata; 37 class ResourceMetadata;
37 38
38 // The SyncClient is used to synchronize pinned files on Drive and the 39 // The SyncClient is used to synchronize pinned files on Drive and the
39 // cache on the local drive. 40 // cache on the local drive.
40 // 41 //
41 // If the user logs out before fetching of the pinned files is complete, this 42 // If the user logs out before fetching of the pinned files is complete, this
42 // client resumes fetching operations next time the user logs in, based on 43 // client resumes fetching operations next time the user logs in, based on
43 // the states left in the cache. 44 // the states left in the cache.
44 class SyncClient { 45 class SyncClient {
45 public: 46 public:
(...skipping 17 matching lines...) Expand all
63 64
64 // Adds a fetch task to the queue. 65 // Adds a fetch task to the queue.
65 void AddFetchTask(const std::string& local_id); 66 void AddFetchTask(const std::string& local_id);
66 67
67 // Removes a fetch task from the queue. 68 // Removes a fetch task from the queue.
68 void RemoveFetchTask(const std::string& local_id); 69 void RemoveFetchTask(const std::string& local_id);
69 70
70 // Adds an upload task to the queue. 71 // Adds an upload task to the queue.
71 void AddUploadTask(const std::string& local_id); 72 void AddUploadTask(const std::string& local_id);
72 73
74 // Adds a remove task to the queue.
75 void AddRemoveTask(const std::string& local_id);
76
73 // Starts processing the backlog (i.e. pinned-but-not-filed files and 77 // Starts processing the backlog (i.e. pinned-but-not-filed files and
74 // dirty-but-not-uploaded files). Kicks off retrieval of the local 78 // dirty-but-not-uploaded files). Kicks off retrieval of the local
75 // IDs of these files, and then starts the sync loop. 79 // IDs of these files, and then starts the sync loop.
76 void StartProcessingBacklog(); 80 void StartProcessingBacklog();
77 81
78 // Starts checking the existing pinned files to see if these are 82 // Starts checking the existing pinned files to see if these are
79 // up-to-date. If stale files are detected, the local IDs of these files 83 // up-to-date. If stale files are detected, the local IDs of these files
80 // are added to the queue and the sync loop is started. 84 // are added to the queue and the sync loop is started.
81 void StartCheckingExistingPinnedFiles(); 85 void StartCheckingExistingPinnedFiles();
82 86
(...skipping 10 matching lines...) Expand all
93 // existing one, and adds a new one to the end of the queue. 97 // existing one, and adds a new one to the end of the queue.
94 void AddTaskToQueue(SyncType type, 98 void AddTaskToQueue(SyncType type,
95 const std::string& local_id, 99 const std::string& local_id,
96 const base::TimeDelta& delay); 100 const base::TimeDelta& delay);
97 101
98 // Called when a task is ready to be added to the queue. 102 // Called when a task is ready to be added to the queue.
99 void StartTask(SyncType type, const std::string& local_id); 103 void StartTask(SyncType type, const std::string& local_id);
100 104
101 // Called when the local IDs of files in the backlog are obtained. 105 // Called when the local IDs of files in the backlog are obtained.
102 void OnGetLocalIdsOfBacklog(const std::vector<std::string>* to_fetch, 106 void OnGetLocalIdsOfBacklog(const std::vector<std::string>* to_fetch,
103 const std::vector<std::string>* to_upload); 107 const std::vector<std::string>* to_upload,
108 const std::vector<std::string>* to_remove);
104 109
105 // Adds fetch tasks. 110 // Adds fetch tasks.
106 void AddFetchTasks(const std::vector<std::string>* local_ids); 111 void AddFetchTasks(const std::vector<std::string>* local_ids);
107 112
108 // Called when the file for |local_id| is fetched. 113 // Called when the file for |local_id| is fetched.
109 // Calls DoSyncLoop() to go back to the sync loop. 114 // Calls DoSyncLoop() to go back to the sync loop.
110 void OnFetchFileComplete(const std::string& local_id, 115 void OnFetchFileComplete(const std::string& local_id,
111 FileError error, 116 FileError error,
112 const base::FilePath& local_path, 117 const base::FilePath& local_path,
113 scoped_ptr<ResourceEntry> entry); 118 scoped_ptr<ResourceEntry> entry);
114 119
115 // Called when the file for |local_id| is uploaded. 120 // Called when the file for |local_id| is uploaded.
116 // Calls DoSyncLoop() to go back to the sync loop. 121 // Calls DoSyncLoop() to go back to the sync loop.
117 void OnUploadFileComplete(const std::string& local_id, FileError error); 122 void OnUploadFileComplete(const std::string& local_id, FileError error);
118 123
124 // Called when the entry is removed.
125 void OnRemoveComplete(const std::string& local_id, FileError error);
126
119 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 127 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
120 ResourceMetadata* metadata_; 128 ResourceMetadata* metadata_;
121 FileCache* cache_; 129 FileCache* cache_;
122 130
123 // Used to fetch pinned files. 131 // Used to fetch pinned files.
124 scoped_ptr<file_system::DownloadOperation> download_operation_; 132 scoped_ptr<file_system::DownloadOperation> download_operation_;
125 133
126 // Used to upload committed files. 134 // Used to upload committed files.
127 scoped_ptr<file_system::UpdateOperation> update_operation_; 135 scoped_ptr<file_system::UpdateOperation> update_operation_;
128 136
137 // Used to remove entries from the trash.
138 scoped_ptr<RemovePerformer> remove_performer_;
139
129 // List of the local ids of resources which have a fetch task created. 140 // List of the local ids of resources which have a fetch task created.
130 std::set<std::string> fetch_list_; 141 std::set<std::string> fetch_list_;
131 142
132 // List of the local ids of resources which have a upload task created. 143 // List of the local ids of resources which have a upload task created.
133 std::set<std::string> upload_list_; 144 std::set<std::string> upload_list_;
134 145
135 // Fetch tasks which have been created, but not started yet. If they are 146 // Fetch tasks which have been created, but not started yet. If they are
136 // removed before starting, they will be cancelled. 147 // removed before starting, they will be cancelled.
137 std::set<std::string> pending_fetch_list_; 148 std::set<std::string> pending_fetch_list_;
138 149
139 // The delay is used for delaying processing tasks in AddTaskToQueue(). 150 // The delay is used for delaying processing tasks in AddTaskToQueue().
140 base::TimeDelta delay_; 151 base::TimeDelta delay_;
141 152
142 // The delay is used for delaying retry of tasks on server errors. 153 // The delay is used for delaying retry of tasks on server errors.
143 base::TimeDelta long_delay_; 154 base::TimeDelta long_delay_;
144 155
145 // Note: This should remain the last member so it'll be destroyed and 156 // Note: This should remain the last member so it'll be destroyed and
146 // invalidate its weak pointers before any other members are destroyed. 157 // invalidate its weak pointers before any other members are destroyed.
147 base::WeakPtrFactory<SyncClient> weak_ptr_factory_; 158 base::WeakPtrFactory<SyncClient> weak_ptr_factory_;
148 159
149 DISALLOW_COPY_AND_ASSIGN(SyncClient); 160 DISALLOW_COPY_AND_ASSIGN(SyncClient);
150 }; 161 };
151 162
152 } // namespace internal 163 } // namespace internal
153 } // namespace drive 164 } // namespace drive
154 165
155 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_ 166 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698