OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ | |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback_forward.h" | |
10 #include "webkit/fileapi/syncable/sync_status_code.h" | |
11 | |
12 class FilePath; | |
13 | |
14 namespace fileapi { | |
15 class FileChange; | |
16 class FileChangeList; | |
17 class FileSystemURL; | |
18 } | |
19 | |
20 namespace sync_file_system { | |
21 | |
22 // Represents an interface to process one remote change and applies | |
23 // it to the local file system. | |
24 // This interface is to be implemented/backed by LocalSyncFileService. | |
25 class RemoteChangeProcessor { | |
26 public: | |
27 typedef base::Callback<void( | |
28 fileapi::SyncStatusCode status, | |
29 fileapi::FileChangeList& change)> PrepareChangeCallback; | |
30 typedef base::Callback<void(fileapi::SyncStatusCode status)> StatusCallback; | |
31 | |
32 RemoteChangeProcessor() {} | |
33 virtual ~RemoteChangeProcessor() {} | |
34 | |
35 // This must be called before processing the change for the |url|. | |
36 // This tries to lock the target |url| and returns the local changes | |
37 // if any. (The change returned by the callback is to make a decision | |
38 // on conflict resolution, but NOT for applying local changes to the remote, | |
39 // which is supposed to be done by LocalChangeProcessor) | |
40 virtual void PrepareForProcessRemoteChange( | |
41 const fileapi::FileSystemURL& url, | |
42 const PrepareChangeCallback& callback) = 0; | |
kinuko
2012/10/22 09:21:06
The remote sync service will call this method when
| |
43 | |
44 // This is called to apply the remote |change|. If the change type is | |
45 // ADD_OR_UPDATE for a file, |local_path| needs to point to a | |
46 // local file path that contains the latest file image (e.g. a path | |
47 // to a temporary file which has the data downloaded from the server). | |
48 // This may fail with an error but should NOT result in a conflict | |
49 // (as we must have checked the change status in PrepareRemoteSync and | |
50 // have disabled any further writing). | |
51 virtual void ApplyRemoteChange( | |
52 const fileapi::FileChange& change, | |
53 const FilePath& local_path, | |
54 const fileapi::FileSystemURL& url, | |
55 const StatusCallback& callback) = 0; | |
kinuko
2012/10/22 09:21:06
The remote sync service will call this method to a
| |
56 | |
57 private: | |
58 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessor); | |
59 }; | |
60 | |
61 } // namespace sync_file_system | |
62 | |
63 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ | |
OLD | NEW |