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_REMOTE_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_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 "chrome/browser/sync_file_system/sync_callbacks.h" | 10 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
11 #include "chrome/browser/sync_file_system/sync_status_code.h" | 11 #include "chrome/browser/sync_file_system/sync_status_code.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class FilePath; | 14 class FilePath; |
15 } | 15 } |
16 | 16 |
17 namespace fileapi { | 17 namespace storage { |
18 class FileSystemURL; | 18 class FileSystemURL; |
19 } | 19 } |
20 | 20 |
21 namespace sync_file_system { | 21 namespace sync_file_system { |
22 | 22 |
23 class FileChange; | 23 class FileChange; |
24 class FileChangeList; | 24 class FileChangeList; |
25 class SyncFileMetadata; | 25 class SyncFileMetadata; |
26 | 26 |
27 // Represents an interface to process one remote change and applies | 27 // Represents an interface to process one remote change and applies |
(...skipping 13 matching lines...) Expand all Loading... |
41 | 41 |
42 RemoteChangeProcessor() {} | 42 RemoteChangeProcessor() {} |
43 virtual ~RemoteChangeProcessor() {} | 43 virtual ~RemoteChangeProcessor() {} |
44 | 44 |
45 // This must be called before processing the change for the |url|. | 45 // This must be called before processing the change for the |url|. |
46 // This tries to lock the target |url| and returns the local changes | 46 // This tries to lock the target |url| and returns the local changes |
47 // if any. (The change returned by the callback is to make a decision | 47 // if any. (The change returned by the callback is to make a decision |
48 // on conflict resolution, but NOT for applying local changes to the remote, | 48 // on conflict resolution, but NOT for applying local changes to the remote, |
49 // which is supposed to be done by LocalChangeProcessor) | 49 // which is supposed to be done by LocalChangeProcessor) |
50 virtual void PrepareForProcessRemoteChange( | 50 virtual void PrepareForProcessRemoteChange( |
51 const fileapi::FileSystemURL& url, | 51 const storage::FileSystemURL& url, |
52 const PrepareChangeCallback& callback) = 0; | 52 const PrepareChangeCallback& callback) = 0; |
53 | 53 |
54 // This is called to apply the remote |change|. If the change type is | 54 // This is called to apply the remote |change|. If the change type is |
55 // ADD_OR_UPDATE for a file, |local_path| needs to point to a | 55 // ADD_OR_UPDATE for a file, |local_path| needs to point to a |
56 // local file path that contains the latest file image (e.g. a path | 56 // local file path that contains the latest file image (e.g. a path |
57 // to a temporary file which has the data downloaded from the server). | 57 // to a temporary file which has the data downloaded from the server). |
58 // This may fail with an error but should NOT result in a conflict | 58 // This may fail with an error but should NOT result in a conflict |
59 // (as we must have checked the change status in PrepareRemoteSync and | 59 // (as we must have checked the change status in PrepareRemoteSync and |
60 // have disabled any further writing). | 60 // have disabled any further writing). |
61 virtual void ApplyRemoteChange( | 61 virtual void ApplyRemoteChange(const FileChange& change, |
62 const FileChange& change, | 62 const base::FilePath& local_path, |
63 const base::FilePath& local_path, | 63 const storage::FileSystemURL& url, |
64 const fileapi::FileSystemURL& url, | 64 const SyncStatusCallback& callback) = 0; |
65 const SyncStatusCallback& callback) = 0; | |
66 | 65 |
67 // Finalizes the remote sync started by PrepareForProcessRemoteChange. | 66 // Finalizes the remote sync started by PrepareForProcessRemoteChange. |
68 // This clears sync flag on |url| to unlock the file for future writes/sync. | 67 // This clears sync flag on |url| to unlock the file for future writes/sync. |
69 // Clears all local changes if |clear_local_changes| is true. | 68 // Clears all local changes if |clear_local_changes| is true. |
70 // This should be set to true when the remote sync service reconciled or | 69 // This should be set to true when the remote sync service reconciled or |
71 // processed the existing local changes while processing a remote change. | 70 // processed the existing local changes while processing a remote change. |
72 virtual void FinalizeRemoteSync( | 71 virtual void FinalizeRemoteSync(const storage::FileSystemURL& url, |
73 const fileapi::FileSystemURL& url, | 72 bool clear_local_changes, |
74 bool clear_local_changes, | 73 const base::Closure& completion_callback) = 0; |
75 const base::Closure& completion_callback) = 0; | |
76 | 74 |
77 // Records a fake local change so that the change will be processed in the | 75 // Records a fake local change so that the change will be processed in the |
78 // next local sync. | 76 // next local sync. |
79 // This is called when the remote side wants to trigger a local sync | 77 // This is called when the remote side wants to trigger a local sync |
80 // to propagate the local change to the remote change (e.g. to | 78 // to propagate the local change to the remote change (e.g. to |
81 // resolve a conflict by uploading the local file). | 79 // resolve a conflict by uploading the local file). |
82 virtual void RecordFakeLocalChange( | 80 virtual void RecordFakeLocalChange(const storage::FileSystemURL& url, |
83 const fileapi::FileSystemURL& url, | 81 const FileChange& change, |
84 const FileChange& change, | 82 const SyncStatusCallback& callback) = 0; |
85 const SyncStatusCallback& callback) = 0; | |
86 | 83 |
87 private: | 84 private: |
88 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessor); | 85 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessor); |
89 }; | 86 }; |
90 | 87 |
91 } // namespace sync_file_system | 88 } // namespace sync_file_system |
92 | 89 |
93 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ | 90 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_CHANGE_PROCESSOR_H_ |
OLD | NEW |