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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "chrome/browser/sync_file_system/remote_change_processor.h" | 17 #include "chrome/browser/sync_file_system/remote_change_processor.h" |
18 #include "webkit/fileapi/syncable/local_origin_change_observer.h" | 18 #include "webkit/fileapi/syncable/local_origin_change_observer.h" |
19 #include "webkit/fileapi/syncable/sync_callbacks.h" | 19 #include "webkit/fileapi/syncable/sync_callbacks.h" |
20 #include "webkit/fileapi/syncable/sync_status_code.h" | 20 #include "webkit/fileapi/syncable/sync_status_code.h" |
21 | 21 |
22 class GURL; | 22 class GURL; |
23 class Profile; | 23 class Profile; |
24 | 24 |
25 namespace fileapi { | 25 namespace fileapi { |
26 class FileChange; | |
27 class FileSystemContext; | 26 class FileSystemContext; |
28 class LocalFileSyncContext; | 27 class LocalFileSyncContext; |
29 struct LocalFileSyncInfo; | 28 struct LocalFileSyncInfo; |
30 } | 29 } |
31 | 30 |
32 namespace sync_file_system { | 31 namespace sync_file_system { |
33 | 32 |
| 33 class FileChange; |
34 class LocalChangeProcessor; | 34 class LocalChangeProcessor; |
35 | 35 |
36 // Maintains local file change tracker and sync status. | 36 // Maintains local file change tracker and sync status. |
37 // Owned by SyncFileSystemService (which is a per-profile object). | 37 // Owned by SyncFileSystemService (which is a per-profile object). |
38 class LocalFileSyncService | 38 class LocalFileSyncService |
39 : public RemoteChangeProcessor, | 39 : public RemoteChangeProcessor, |
40 public fileapi::LocalOriginChangeObserver, | 40 public fileapi::LocalOriginChangeObserver, |
41 public base::SupportsWeakPtr<LocalFileSyncService> { | 41 public base::SupportsWeakPtr<LocalFileSyncService> { |
42 public: | 42 public: |
43 class Observer { | 43 class Observer { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 virtual void GetLocalFileMetadata( | 101 virtual void GetLocalFileMetadata( |
102 const fileapi::FileSystemURL& url, | 102 const fileapi::FileSystemURL& url, |
103 const fileapi::SyncFileMetadataCallback& callback); | 103 const fileapi::SyncFileMetadataCallback& callback); |
104 | 104 |
105 // RemoteChangeProcessor overrides. | 105 // RemoteChangeProcessor overrides. |
106 virtual void PrepareForProcessRemoteChange( | 106 virtual void PrepareForProcessRemoteChange( |
107 const fileapi::FileSystemURL& url, | 107 const fileapi::FileSystemURL& url, |
108 const std::string& service_name, | 108 const std::string& service_name, |
109 const PrepareChangeCallback& callback) OVERRIDE; | 109 const PrepareChangeCallback& callback) OVERRIDE; |
110 virtual void ApplyRemoteChange( | 110 virtual void ApplyRemoteChange( |
111 const fileapi::FileChange& change, | 111 const FileChange& change, |
112 const base::FilePath& local_path, | 112 const base::FilePath& local_path, |
113 const fileapi::FileSystemURL& url, | 113 const fileapi::FileSystemURL& url, |
114 const fileapi::SyncStatusCallback& callback) OVERRIDE; | 114 const fileapi::SyncStatusCallback& callback) OVERRIDE; |
115 virtual void ClearLocalChanges( | 115 virtual void ClearLocalChanges( |
116 const fileapi::FileSystemURL& url, | 116 const fileapi::FileSystemURL& url, |
117 const base::Closure& completion_callback) OVERRIDE; | 117 const base::Closure& completion_callback) OVERRIDE; |
118 virtual void RecordFakeLocalChange( | 118 virtual void RecordFakeLocalChange( |
119 const fileapi::FileSystemURL& url, | 119 const fileapi::FileSystemURL& url, |
120 const fileapi::FileChange& change, | 120 const FileChange& change, |
121 const fileapi::SyncStatusCallback& callback) OVERRIDE; | 121 const fileapi::SyncStatusCallback& callback) OVERRIDE; |
122 | 122 |
123 // LocalOriginChangeObserver override. | 123 // LocalOriginChangeObserver override. |
124 virtual void OnChangesAvailableInOrigins( | 124 virtual void OnChangesAvailableInOrigins( |
125 const std::set<GURL>& origins) OVERRIDE; | 125 const std::set<GURL>& origins) OVERRIDE; |
126 | 126 |
127 // Called when a particular origin (app) is disabled/enabled while | 127 // Called when a particular origin (app) is disabled/enabled while |
128 // the service is running. This may be called for origins/apps that | 128 // the service is running. This may be called for origins/apps that |
129 // are not initialized for the service. | 129 // are not initialized for the service. |
130 void SetOriginEnabled(const GURL& origin, bool enabled); | 130 void SetOriginEnabled(const GURL& origin, bool enabled); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const fileapi::FileSystemURL& url); | 178 const fileapi::FileSystemURL& url); |
179 | 179 |
180 // Callbacks for ProcessLocalChange. | 180 // Callbacks for ProcessLocalChange. |
181 void DidGetFileForLocalSync( | 181 void DidGetFileForLocalSync( |
182 LocalChangeProcessor* processor, | 182 LocalChangeProcessor* processor, |
183 fileapi::SyncStatusCode status, | 183 fileapi::SyncStatusCode status, |
184 const fileapi::LocalFileSyncInfo& sync_file_info); | 184 const fileapi::LocalFileSyncInfo& sync_file_info); |
185 void ProcessNextChangeForURL( | 185 void ProcessNextChangeForURL( |
186 LocalChangeProcessor* processor, | 186 LocalChangeProcessor* processor, |
187 const fileapi::LocalFileSyncInfo& sync_file_info, | 187 const fileapi::LocalFileSyncInfo& sync_file_info, |
188 const fileapi::FileChange& last_change, | 188 const FileChange& last_change, |
189 const fileapi::FileChangeList& changes, | 189 const FileChangeList& changes, |
190 fileapi::SyncStatusCode status); | 190 fileapi::SyncStatusCode status); |
191 | 191 |
192 Profile* profile_; | 192 Profile* profile_; |
193 | 193 |
194 scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; | 194 scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; |
195 | 195 |
196 // Origin to context map. (Assuming that as far as we're in the same | 196 // Origin to context map. (Assuming that as far as we're in the same |
197 // profile single origin wouldn't belong to multiple FileSystemContexts.) | 197 // profile single origin wouldn't belong to multiple FileSystemContexts.) |
198 std::map<GURL, fileapi::FileSystemContext*> origin_to_contexts_; | 198 std::map<GURL, fileapi::FileSystemContext*> origin_to_contexts_; |
199 | 199 |
200 // Origins which have pending changes but have not been initialized yet. | 200 // Origins which have pending changes but have not been initialized yet. |
201 // (Used only for handling dirty files left in the local tracker database | 201 // (Used only for handling dirty files left in the local tracker database |
202 // after a restart.) | 202 // after a restart.) |
203 std::set<GURL> pending_origins_with_changes_; | 203 std::set<GURL> pending_origins_with_changes_; |
204 | 204 |
205 OriginChangeMap origin_change_map_; | 205 OriginChangeMap origin_change_map_; |
206 | 206 |
207 // This callback is non-null while a local sync is running (i.e. | 207 // This callback is non-null while a local sync is running (i.e. |
208 // ProcessLocalChange has been called and has not been returned yet). | 208 // ProcessLocalChange has been called and has not been returned yet). |
209 fileapi::SyncFileCallback local_sync_callback_; | 209 fileapi::SyncFileCallback local_sync_callback_; |
210 | 210 |
211 ObserverList<Observer> change_observers_; | 211 ObserverList<Observer> change_observers_; |
212 | 212 |
213 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); | 213 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncService); |
214 }; | 214 }; |
215 | 215 |
216 } // namespace sync_file_system | 216 } // namespace sync_file_system |
217 | 217 |
218 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ | 218 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_FILE_SYNC_SERVICE_H_ |
OLD | NEW |