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 |
28 LocalFileSyncService(); | 31 LocalFileSyncService(); |
29 ~LocalFileSyncService(); | 32 ~LocalFileSyncService(); |
30 | 33 |
31 void Shutdown(); | 34 void Shutdown(); |
32 | 35 |
33 void MaybeInitializeFileSystemContext( | 36 void MaybeInitializeFileSystemContext( |
34 const GURL& app_url, | 37 const GURL& app_url, |
35 fileapi::FileSystemContext* file_system_context, | 38 fileapi::FileSystemContext* file_system_context, |
36 const StatusCallback& callback); | 39 const StatusCallback& callback); |
37 | 40 |
| 41 // Synchronize one local change (to the remote server) using |processor|. |
| 42 // |processor| must have same or longer lifetime than this service. |
| 43 void ProcessChange(LocalChangeProcessor* processor, |
| 44 const StatusCallback& callback); |
| 45 |
| 46 // RemoteChangeProcessor overrides. |
| 47 virtual void PrepareForProcessRemoteChange( |
| 48 const fileapi::FileSystemURL& url, |
| 49 const PrepareChangeCallback& callback) OVERRIDE; |
| 50 virtual void ApplyRemoteChange( |
| 51 const fileapi::FileChange& change, |
| 52 const FilePath& local_path, |
| 53 const fileapi::FileSystemURL& url, |
| 54 const StatusCallback& callback) OVERRIDE; |
| 55 |
38 private: | 56 private: |
39 scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; | 57 scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; |
40 | 58 |
41 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); | 59 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); |
42 }; | 60 }; |
43 | 61 |
44 } // namespace sync_file_system | 62 } // namespace sync_file_system |
45 | 63 |
46 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ | 64 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ |
OLD | NEW |