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_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "chrome/browser/sync_file_system/remote_change_processor.h" |
11 #include "webkit/fileapi/syncable/sync_status_code.h" | 12 #include "webkit/fileapi/syncable/sync_status_code.h" |
12 | 13 |
13 class GURL; | 14 class GURL; |
14 | 15 |
15 namespace fileapi { | 16 namespace fileapi { |
16 class FileSystemContext; | 17 class FileSystemContext; |
17 class LocalFileSyncContext; | 18 class LocalFileSyncContext; |
18 } | 19 } |
19 | 20 |
20 namespace sync_file_system { | 21 namespace sync_file_system { |
21 | 22 |
| 23 class LocalChangeProcessor; |
| 24 |
22 // Maintains local file change tracker and sync status. | 25 // Maintains local file change tracker and sync status. |
23 // Owned by SyncFileSystemService (which is a per-profile object). | 26 // Owned by SyncFileSystemService (which is a per-profile object). |
24 class LocalFileSyncService { | 27 class LocalFileSyncService : public RemoteChangeProcessor { |
25 public: | 28 public: |
26 typedef base::Callback<void(fileapi::SyncStatusCode)> StatusCallback; | 29 typedef base::Callback<void(fileapi::SyncStatusCode)> StatusCallback; |
27 | 30 |
| 31 typedef base::Callback< |
| 32 void(fileapi::SyncStatusCode status, fileapi::FileSystemURL& url)> |
| 33 SyncCompletionCallback; |
| 34 |
28 LocalFileSyncService(); | 35 LocalFileSyncService(); |
29 ~LocalFileSyncService(); | 36 virtual ~LocalFileSyncService(); |
30 | 37 |
31 void Shutdown(); | 38 void Shutdown(); |
32 | 39 |
33 void MaybeInitializeFileSystemContext( | 40 void MaybeInitializeFileSystemContext( |
34 const GURL& app_url, | 41 const GURL& app_url, |
35 fileapi::FileSystemContext* file_system_context, | 42 fileapi::FileSystemContext* file_system_context, |
36 const StatusCallback& callback); | 43 const StatusCallback& callback); |
37 | 44 |
| 45 // Synchronize one local change (to the remote server) using |processor|. |
| 46 // |processor| must have same or longer lifetime than this service. |
| 47 void ProcessChange(LocalChangeProcessor* processor, |
| 48 const SyncCompletionCallback& callback); |
| 49 |
| 50 // RemoteChangeProcessor overrides. |
| 51 virtual void PrepareForProcessRemoteChange( |
| 52 const fileapi::FileSystemURL& url, |
| 53 const PrepareChangeCallback& callback) OVERRIDE; |
| 54 virtual void ApplyRemoteChange( |
| 55 const fileapi::FileChange& change, |
| 56 const FilePath& local_path, |
| 57 const fileapi::FileSystemURL& url, |
| 58 const StatusCallback& callback) OVERRIDE; |
| 59 |
38 private: | 60 private: |
39 scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; | 61 scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; |
40 | 62 |
41 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); | 63 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); |
42 }; | 64 }; |
43 | 65 |
44 } // namespace sync_file_system | 66 } // namespace sync_file_system |
45 | 67 |
46 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ | 68 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ |
OLD | NEW |