OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/files/file.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
20 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
21 #include "base/timer/timer.h" | 22 #include "base/timer/timer.h" |
22 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" | 23 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" |
23 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 24 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
24 #include "chrome/browser/sync_file_system/sync_status_code.h" | 25 #include "chrome/browser/sync_file_system/sync_status_code.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void set_mock_notify_changes_duration_in_sec(int duration) { | 202 void set_mock_notify_changes_duration_in_sec(int duration) { |
202 mock_notify_changes_duration_in_sec_ = duration; | 203 mock_notify_changes_duration_in_sec_ = duration; |
203 } | 204 } |
204 | 205 |
205 protected: | 206 protected: |
206 // LocalFileSyncStatus::Observer overrides. They are called on IO thread. | 207 // LocalFileSyncStatus::Observer overrides. They are called on IO thread. |
207 virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE; | 208 virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE; |
208 virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) OVERRIDE; | 209 virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) OVERRIDE; |
209 | 210 |
210 private: | 211 private: |
211 typedef base::Callback<void(base::PlatformFileError result)> StatusCallback; | 212 typedef base::Callback<void(base::File::Error result)> StatusCallback; |
212 typedef std::deque<SyncStatusCallback> StatusCallbackQueue; | 213 typedef std::deque<SyncStatusCallback> StatusCallbackQueue; |
213 friend class base::RefCountedThreadSafe<LocalFileSyncContext>; | 214 friend class base::RefCountedThreadSafe<LocalFileSyncContext>; |
214 friend class CannedSyncableFileSystem; | 215 friend class CannedSyncableFileSystem; |
215 | 216 |
216 virtual ~LocalFileSyncContext(); | 217 virtual ~LocalFileSyncContext(); |
217 | 218 |
218 void ShutdownOnIOThread(); | 219 void ShutdownOnIOThread(); |
219 | 220 |
220 // Starts a timer to eventually call NotifyAvailableChangesOnIOThread. | 221 // Starts a timer to eventually call NotifyAvailableChangesOnIOThread. |
221 // The caller is expected to update origins_with_pending_changes_ before | 222 // The caller is expected to update origins_with_pending_changes_ before |
222 // calling this. | 223 // calling this. |
223 void ScheduleNotifyChangesUpdatedOnIOThread(); | 224 void ScheduleNotifyChangesUpdatedOnIOThread(); |
224 | 225 |
225 // Called by the internal timer on IO thread to notify changes to UI thread. | 226 // Called by the internal timer on IO thread to notify changes to UI thread. |
226 void NotifyAvailableChangesOnIOThread(); | 227 void NotifyAvailableChangesOnIOThread(); |
227 | 228 |
228 // Called from NotifyAvailableChangesOnIOThread. | 229 // Called from NotifyAvailableChangesOnIOThread. |
229 void NotifyAvailableChanges(const std::set<GURL>& origins); | 230 void NotifyAvailableChanges(const std::set<GURL>& origins); |
230 | 231 |
231 // Helper routines for MaybeInitializeFileSystemContext. | 232 // Helper routines for MaybeInitializeFileSystemContext. |
232 void InitializeFileSystemContextOnIOThread( | 233 void InitializeFileSystemContextOnIOThread( |
233 const GURL& source_url, | 234 const GURL& source_url, |
234 fileapi::FileSystemContext* file_system_context, | 235 fileapi::FileSystemContext* file_system_context, |
235 const GURL& /* root */, | 236 const GURL& /* root */, |
236 const std::string& /* name */, | 237 const std::string& /* name */, |
237 base::PlatformFileError error); | 238 base::File::Error error); |
238 SyncStatusCode InitializeChangeTrackerOnFileThread( | 239 SyncStatusCode InitializeChangeTrackerOnFileThread( |
239 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, | 240 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, |
240 fileapi::FileSystemContext* file_system_context, | 241 fileapi::FileSystemContext* file_system_context, |
241 std::set<GURL>* origins_with_changes); | 242 std::set<GURL>* origins_with_changes); |
242 void DidInitializeChangeTrackerOnIOThread( | 243 void DidInitializeChangeTrackerOnIOThread( |
243 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, | 244 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, |
244 const GURL& source_url, | 245 const GURL& source_url, |
245 fileapi::FileSystemContext* file_system_context, | 246 fileapi::FileSystemContext* file_system_context, |
246 std::set<GURL>* origins_with_changes, | 247 std::set<GURL>* origins_with_changes, |
247 SyncStatusCode status); | 248 SyncStatusCode status); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 const FileChange& change, | 295 const FileChange& change, |
295 const base::FilePath& local_path, | 296 const base::FilePath& local_path, |
296 const fileapi::FileSystemURL& url, | 297 const fileapi::FileSystemURL& url, |
297 const SyncStatusCallback& callback); | 298 const SyncStatusCallback& callback); |
298 void DidRemoveExistingEntryForRemoteAddOrUpdate( | 299 void DidRemoveExistingEntryForRemoteAddOrUpdate( |
299 fileapi::FileSystemContext* file_system_context, | 300 fileapi::FileSystemContext* file_system_context, |
300 const FileChange& change, | 301 const FileChange& change, |
301 const base::FilePath& local_path, | 302 const base::FilePath& local_path, |
302 const fileapi::FileSystemURL& url, | 303 const fileapi::FileSystemURL& url, |
303 const SyncStatusCallback& callback, | 304 const SyncStatusCallback& callback, |
304 base::PlatformFileError error); | 305 base::File::Error error); |
305 | 306 |
306 // Callback routine for ApplyRemoteChange. | 307 // Callback routine for ApplyRemoteChange. |
307 void DidApplyRemoteChange( | 308 void DidApplyRemoteChange( |
308 const fileapi::FileSystemURL& url, | 309 const fileapi::FileSystemURL& url, |
309 const SyncStatusCallback& callback_on_ui, | 310 const SyncStatusCallback& callback_on_ui, |
310 base::PlatformFileError file_error); | 311 base::File::Error file_error); |
311 | 312 |
312 void DidGetFileMetadata( | 313 void DidGetFileMetadata( |
313 const SyncFileMetadataCallback& callback, | 314 const SyncFileMetadataCallback& callback, |
314 base::PlatformFileError file_error, | 315 base::File::Error file_error, |
315 const base::PlatformFileInfo& file_info); | 316 const base::File::Info& file_info); |
316 | 317 |
317 base::TimeDelta NotifyChangesDuration(); | 318 base::TimeDelta NotifyChangesDuration(); |
318 | 319 |
319 void DidCreateDirectoryForCopyIn( | 320 void DidCreateDirectoryForCopyIn( |
320 fileapi::FileSystemContext* file_system_context, | 321 fileapi::FileSystemContext* file_system_context, |
321 const base::FilePath& local_file_path, | 322 const base::FilePath& local_file_path, |
322 const fileapi::FileSystemURL& dest_url, | 323 const fileapi::FileSystemURL& dest_url, |
323 const StatusCallback& callback, | 324 const StatusCallback& callback, |
324 base::PlatformFileError error); | 325 base::File::Error error); |
325 | 326 |
326 const base::FilePath local_base_path_; | 327 const base::FilePath local_base_path_; |
327 | 328 |
328 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 329 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
329 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 330 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
330 | 331 |
331 // Indicates if the sync service is shutdown. | 332 // Indicates if the sync service is shutdown. |
332 bool shutdown_on_ui_; // Updated and referred only on UI thread. | 333 bool shutdown_on_ui_; // Updated and referred only on UI thread. |
333 bool shutdown_on_io_; // Updated and referred only on IO thread. | 334 bool shutdown_on_io_; // Updated and referred only on IO thread. |
334 | 335 |
(...skipping 30 matching lines...) Expand all Loading... |
365 ObserverList<LocalOriginChangeObserver> origin_change_observers_; | 366 ObserverList<LocalOriginChangeObserver> origin_change_observers_; |
366 | 367 |
367 int mock_notify_changes_duration_in_sec_; | 368 int mock_notify_changes_duration_in_sec_; |
368 | 369 |
369 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext); | 370 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext); |
370 }; | 371 }; |
371 | 372 |
372 } // namespace sync_file_system | 373 } // namespace sync_file_system |
373 | 374 |
374 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ | 375 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ |
OLD | NEW |