Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_context.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_LOCAL_FILE_SYNC_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 11 matching lines...) Expand all
22 #include "base/timer/timer.h" 22 #include "base/timer/timer.h"
23 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" 23 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h"
24 #include "chrome/browser/sync_file_system/sync_callbacks.h" 24 #include "chrome/browser/sync_file_system/sync_callbacks.h"
25 #include "chrome/browser/sync_file_system/sync_status_code.h" 25 #include "chrome/browser/sync_file_system/sync_status_code.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 namespace base { 28 namespace base {
29 class SingleThreadTaskRunner; 29 class SingleThreadTaskRunner;
30 } 30 }
31 31
32 namespace fileapi { 32 namespace storage {
33 class FileSystemContext; 33 class FileSystemContext;
34 class FileSystemURL; 34 class FileSystemURL;
35 } 35 }
36 36
37 namespace leveldb { 37 namespace leveldb {
38 class Env; 38 class Env;
39 } 39 }
40 40
41 namespace webkit_blob { 41 namespace storage {
42 class ScopedFile; 42 class ScopedFile;
43 } 43 }
44 44
45 namespace sync_file_system { 45 namespace sync_file_system {
46 46
47 class FileChange; 47 class FileChange;
48 class LocalFileChangeTracker; 48 class LocalFileChangeTracker;
49 struct LocalFileSyncInfo; 49 struct LocalFileSyncInfo;
50 class LocalOriginChangeObserver; 50 class LocalOriginChangeObserver;
51 class RootDeleteHelper; 51 class RootDeleteHelper;
52 class SyncableFileOperationRunner; 52 class SyncableFileOperationRunner;
53 53
54 // This class works as a bridge between LocalFileSyncService (which is a 54 // This class works as a bridge between LocalFileSyncService (which is a
55 // per-profile object) and FileSystemContext's (which is a per-storage-partition 55 // per-profile object) and FileSystemContext's (which is a per-storage-partition
56 // object and may exist multiple in a profile). 56 // object and may exist multiple in a profile).
57 // An instance of this class is shared by FileSystemContexts and outlives 57 // An instance of this class is shared by FileSystemContexts and outlives
58 // LocalFileSyncService. 58 // LocalFileSyncService.
59 class LocalFileSyncContext 59 class LocalFileSyncContext
60 : public base::RefCountedThreadSafe<LocalFileSyncContext>, 60 : public base::RefCountedThreadSafe<LocalFileSyncContext>,
61 public LocalFileSyncStatus::Observer { 61 public LocalFileSyncStatus::Observer {
62 public: 62 public:
63 enum SyncMode { 63 enum SyncMode {
64 SYNC_EXCLUSIVE, 64 SYNC_EXCLUSIVE,
65 SYNC_SNAPSHOT, 65 SYNC_SNAPSHOT,
66 }; 66 };
67 67
68 typedef base::Callback<void( 68 typedef base::Callback<void(SyncStatusCode status,
69 SyncStatusCode status, 69 const LocalFileSyncInfo& sync_file_info,
70 const LocalFileSyncInfo& sync_file_info, 70 storage::ScopedFile snapshot)>
71 webkit_blob::ScopedFile snapshot)> 71 LocalFileSyncInfoCallback;
72 LocalFileSyncInfoCallback;
73 72
74 typedef base::Callback<void(SyncStatusCode status, 73 typedef base::Callback<void(SyncStatusCode status,
75 bool has_pending_changes)> 74 bool has_pending_changes)>
76 HasPendingLocalChangeCallback; 75 HasPendingLocalChangeCallback;
77 76
78 LocalFileSyncContext(const base::FilePath& base_path, 77 LocalFileSyncContext(const base::FilePath& base_path,
79 leveldb::Env* env_override, 78 leveldb::Env* env_override,
80 base::SingleThreadTaskRunner* ui_task_runner, 79 base::SingleThreadTaskRunner* ui_task_runner,
81 base::SingleThreadTaskRunner* io_task_runner); 80 base::SingleThreadTaskRunner* io_task_runner);
82 81
83 // Initializes |file_system_context| for syncable file operations 82 // Initializes |file_system_context| for syncable file operations
84 // and registers the it into the internal map. 83 // and registers the it into the internal map.
85 // Calling this multiple times for the same file_system_context is valid. 84 // Calling this multiple times for the same file_system_context is valid.
86 // This method must be called on UI thread. 85 // This method must be called on UI thread.
87 void MaybeInitializeFileSystemContext( 86 void MaybeInitializeFileSystemContext(
88 const GURL& source_url, 87 const GURL& source_url,
89 fileapi::FileSystemContext* file_system_context, 88 storage::FileSystemContext* file_system_context,
90 const SyncStatusCallback& callback); 89 const SyncStatusCallback& callback);
91 90
92 // Called when the corresponding LocalFileSyncService exits. 91 // Called when the corresponding LocalFileSyncService exits.
93 // This method must be called on UI thread. 92 // This method must be called on UI thread.
94 void ShutdownOnUIThread(); 93 void ShutdownOnUIThread();
95 94
96 // Picks a file for next local sync and returns it after disabling writes 95 // Picks a file for next local sync and returns it after disabling writes
97 // for the file. 96 // for the file.
98 // This method must be called on UI thread. 97 // This method must be called on UI thread.
99 void GetFileForLocalSync(fileapi::FileSystemContext* file_system_context, 98 void GetFileForLocalSync(storage::FileSystemContext* file_system_context,
100 const LocalFileSyncInfoCallback& callback); 99 const LocalFileSyncInfoCallback& callback);
101 100
102 // TODO(kinuko): Make this private. 101 // TODO(kinuko): Make this private.
103 // Clears all pending local changes for |url|. |done_callback| is called 102 // Clears all pending local changes for |url|. |done_callback| is called
104 // when the changes are cleared. 103 // when the changes are cleared.
105 // This method must be called on UI thread. 104 // This method must be called on UI thread.
106 void ClearChangesForURL(fileapi::FileSystemContext* file_system_context, 105 void ClearChangesForURL(storage::FileSystemContext* file_system_context,
107 const fileapi::FileSystemURL& url, 106 const storage::FileSystemURL& url,
108 const base::Closure& done_callback); 107 const base::Closure& done_callback);
109 108
110 // Finalizes SnapshotSync, which must have been started by 109 // Finalizes SnapshotSync, which must have been started by
111 // PrepareForSync with SYNC_SNAPSHOT. 110 // PrepareForSync with SYNC_SNAPSHOT.
112 // Updates the on-disk dirty flag for |url| in the tracker DB. 111 // Updates the on-disk dirty flag for |url| in the tracker DB.
113 // This will clear the dirty flag if |sync_finish_status| is SYNC_STATUS_OK 112 // This will clear the dirty flag if |sync_finish_status| is SYNC_STATUS_OK
114 // or SYNC_STATUS_HAS_CONFLICT. 113 // or SYNC_STATUS_HAS_CONFLICT.
115 // |done_callback| is called when the changes are committed. 114 // |done_callback| is called when the changes are committed.
116 void FinalizeSnapshotSync( 115 void FinalizeSnapshotSync(storage::FileSystemContext* file_system_context,
117 fileapi::FileSystemContext* file_system_context, 116 const storage::FileSystemURL& url,
118 const fileapi::FileSystemURL& url, 117 SyncStatusCode sync_finish_status,
119 SyncStatusCode sync_finish_status, 118 const base::Closure& done_callback);
120 const base::Closure& done_callback);
121 119
122 // Finalizes ExclusiveSync, which must have been started by 120 // Finalizes ExclusiveSync, which must have been started by
123 // PrepareForSync with SYNC_EXCLUSIVE. 121 // PrepareForSync with SYNC_EXCLUSIVE.
124 void FinalizeExclusiveSync( 122 void FinalizeExclusiveSync(storage::FileSystemContext* file_system_context,
125 fileapi::FileSystemContext* file_system_context, 123 const storage::FileSystemURL& url,
126 const fileapi::FileSystemURL& url, 124 bool clear_local_changes,
127 bool clear_local_changes, 125 const base::Closure& done_callback);
128 const base::Closure& done_callback);
129 126
130 // Prepares for sync |url| by disabling writes on |url|. 127 // Prepares for sync |url| by disabling writes on |url|.
131 // If the target |url| is being written and cannot start sync it 128 // If the target |url| is being written and cannot start sync it
132 // returns SYNC_STATUS_WRITING status code via |callback|. 129 // returns SYNC_STATUS_WRITING status code via |callback|.
133 // Otherwise returns the current change sets made on |url|. 130 // Otherwise returns the current change sets made on |url|.
134 // 131 //
135 // If |sync_mode| is SYNC_EXCLUSIVE this leaves the target file locked. 132 // If |sync_mode| is SYNC_EXCLUSIVE this leaves the target file locked.
136 // If |sync_mode| is SYNC_SNAPSHOT this creates a snapshot (if the 133 // If |sync_mode| is SYNC_SNAPSHOT this creates a snapshot (if the
137 // target file is not deleted) and unlocks the file before returning. 134 // target file is not deleted) and unlocks the file before returning.
138 // 135 //
139 // For SYNC_EXCLUSIVE, caller must call FinalizeExclusiveSync() to finalize 136 // For SYNC_EXCLUSIVE, caller must call FinalizeExclusiveSync() to finalize
140 // sync and unlock the file. 137 // sync and unlock the file.
141 // For SYNC_SNAPSHOT, caller must call FinalizeSnapshotSync() to finalize 138 // For SYNC_SNAPSHOT, caller must call FinalizeSnapshotSync() to finalize
142 // sync to reset the mirrored change status and decrement writing count. 139 // sync to reset the mirrored change status and decrement writing count.
143 // 140 //
144 // This method must be called on UI thread. 141 // This method must be called on UI thread.
145 void PrepareForSync(fileapi::FileSystemContext* file_system_context, 142 void PrepareForSync(storage::FileSystemContext* file_system_context,
146 const fileapi::FileSystemURL& url, 143 const storage::FileSystemURL& url,
147 SyncMode sync_mode, 144 SyncMode sync_mode,
148 const LocalFileSyncInfoCallback& callback); 145 const LocalFileSyncInfoCallback& callback);
149 146
150 // Registers |url| to wait until sync is enabled for |url|. 147 // Registers |url| to wait until sync is enabled for |url|.
151 // |on_syncable_callback| is to be called when |url| becomes syncable 148 // |on_syncable_callback| is to be called when |url| becomes syncable
152 // (i.e. when we have no pending writes and the file is successfully locked 149 // (i.e. when we have no pending writes and the file is successfully locked
153 // for sync). 150 // for sync).
154 // 151 //
155 // Calling this method again while this already has another URL waiting 152 // Calling this method again while this already has another URL waiting
156 // for sync will overwrite the previously registered URL. 153 // for sync will overwrite the previously registered URL.
157 // 154 //
158 // This method must be called on UI thread. 155 // This method must be called on UI thread.
159 void RegisterURLForWaitingSync(const fileapi::FileSystemURL& url, 156 void RegisterURLForWaitingSync(const storage::FileSystemURL& url,
160 const base::Closure& on_syncable_callback); 157 const base::Closure& on_syncable_callback);
161 158
162 // Applies a remote change. 159 // Applies a remote change.
163 // This method must be called on UI thread. 160 // This method must be called on UI thread.
164 void ApplyRemoteChange( 161 void ApplyRemoteChange(storage::FileSystemContext* file_system_context,
165 fileapi::FileSystemContext* file_system_context, 162 const FileChange& change,
166 const FileChange& change, 163 const base::FilePath& local_path,
167 const base::FilePath& local_path, 164 const storage::FileSystemURL& url,
168 const fileapi::FileSystemURL& url, 165 const SyncStatusCallback& callback);
169 const SyncStatusCallback& callback);
170 166
171 // Records a fake local change in the local change tracker. 167 // Records a fake local change in the local change tracker.
172 void RecordFakeLocalChange( 168 void RecordFakeLocalChange(storage::FileSystemContext* file_system_context,
173 fileapi::FileSystemContext* file_system_context, 169 const storage::FileSystemURL& url,
174 const fileapi::FileSystemURL& url, 170 const FileChange& change,
175 const FileChange& change, 171 const SyncStatusCallback& callback);
176 const SyncStatusCallback& callback);
177 172
178 // This must be called on UI thread. 173 // This must be called on UI thread.
179 void GetFileMetadata( 174 void GetFileMetadata(storage::FileSystemContext* file_system_context,
180 fileapi::FileSystemContext* file_system_context, 175 const storage::FileSystemURL& url,
181 const fileapi::FileSystemURL& url, 176 const SyncFileMetadataCallback& callback);
182 const SyncFileMetadataCallback& callback);
183 177
184 // Returns true via |callback| if the given file |url| has local pending 178 // Returns true via |callback| if the given file |url| has local pending
185 // changes. 179 // changes.
186 void HasPendingLocalChanges( 180 void HasPendingLocalChanges(storage::FileSystemContext* file_system_context,
187 fileapi::FileSystemContext* file_system_context, 181 const storage::FileSystemURL& url,
188 const fileapi::FileSystemURL& url, 182 const HasPendingLocalChangeCallback& callback);
189 const HasPendingLocalChangeCallback& callback);
190 183
191 void PromoteDemotedChanges(const GURL& origin, 184 void PromoteDemotedChanges(const GURL& origin,
192 fileapi::FileSystemContext* file_system_context, 185 storage::FileSystemContext* file_system_context,
193 const base::Closure& callback); 186 const base::Closure& callback);
194 void UpdateChangesForOrigin(const GURL& origin, 187 void UpdateChangesForOrigin(const GURL& origin,
195 const base::Closure& callback); 188 const base::Closure& callback);
196 189
197 // They must be called on UI thread. 190 // They must be called on UI thread.
198 void AddOriginChangeObserver(LocalOriginChangeObserver* observer); 191 void AddOriginChangeObserver(LocalOriginChangeObserver* observer);
199 void RemoveOriginChangeObserver(LocalOriginChangeObserver* observer); 192 void RemoveOriginChangeObserver(LocalOriginChangeObserver* observer);
200 193
201 // OperationRunner is accessible only on IO thread. 194 // OperationRunner is accessible only on IO thread.
202 base::WeakPtr<SyncableFileOperationRunner> operation_runner() const; 195 base::WeakPtr<SyncableFileOperationRunner> operation_runner() const;
203 196
204 // SyncContext is accessible only on IO thread. 197 // SyncContext is accessible only on IO thread.
205 LocalFileSyncStatus* sync_status() const; 198 LocalFileSyncStatus* sync_status() const;
206 199
207 // For testing; override the duration to notify changes from the 200 // For testing; override the duration to notify changes from the
208 // default value. 201 // default value.
209 void set_mock_notify_changes_duration_in_sec(int duration) { 202 void set_mock_notify_changes_duration_in_sec(int duration) {
210 mock_notify_changes_duration_in_sec_ = duration; 203 mock_notify_changes_duration_in_sec_ = duration;
211 } 204 }
212 205
213 protected: 206 protected:
214 // LocalFileSyncStatus::Observer overrides. They are called on IO thread. 207 // LocalFileSyncStatus::Observer overrides. They are called on IO thread.
215 virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE; 208 virtual void OnSyncEnabled(const storage::FileSystemURL& url) OVERRIDE;
216 virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) OVERRIDE; 209 virtual void OnWriteEnabled(const storage::FileSystemURL& url) OVERRIDE;
217 210
218 private: 211 private:
219 typedef base::Callback<void(base::File::Error result)> StatusCallback; 212 typedef base::Callback<void(base::File::Error result)> StatusCallback;
220 typedef std::deque<SyncStatusCallback> StatusCallbackQueue; 213 typedef std::deque<SyncStatusCallback> StatusCallbackQueue;
221 typedef std::deque<fileapi::FileSystemURL> FileSystemURLQueue; 214 typedef std::deque<storage::FileSystemURL> FileSystemURLQueue;
222 friend class base::RefCountedThreadSafe<LocalFileSyncContext>; 215 friend class base::RefCountedThreadSafe<LocalFileSyncContext>;
223 friend class CannedSyncableFileSystem; 216 friend class CannedSyncableFileSystem;
224 217
225 virtual ~LocalFileSyncContext(); 218 virtual ~LocalFileSyncContext();
226 219
227 void ShutdownOnIOThread(); 220 void ShutdownOnIOThread();
228 221
229 // Starts a timer to eventually call NotifyAvailableChangesOnIOThread. 222 // Starts a timer to eventually call NotifyAvailableChangesOnIOThread.
230 // The caller is expected to update origins_with_pending_changes_ before 223 // The caller is expected to update origins_with_pending_changes_ before
231 // calling this. 224 // calling this.
232 void ScheduleNotifyChangesUpdatedOnIOThread(const base::Closure& callback); 225 void ScheduleNotifyChangesUpdatedOnIOThread(const base::Closure& callback);
233 226
234 // Called by the internal timer on IO thread to notify changes to UI thread. 227 // Called by the internal timer on IO thread to notify changes to UI thread.
235 void NotifyAvailableChangesOnIOThread(const base::Closure& callback); 228 void NotifyAvailableChangesOnIOThread(const base::Closure& callback);
236 229
237 // Called from NotifyAvailableChangesOnIOThread. 230 // Called from NotifyAvailableChangesOnIOThread.
238 void NotifyAvailableChanges(const std::set<GURL>& origins, 231 void NotifyAvailableChanges(const std::set<GURL>& origins,
239 const base::Closure& callback); 232 const base::Closure& callback);
240 233
241 // Helper routines for MaybeInitializeFileSystemContext. 234 // Helper routines for MaybeInitializeFileSystemContext.
242 void InitializeFileSystemContextOnIOThread( 235 void InitializeFileSystemContextOnIOThread(
243 const GURL& source_url, 236 const GURL& source_url,
244 fileapi::FileSystemContext* file_system_context, 237 storage::FileSystemContext* file_system_context,
245 const GURL& /* root */, 238 const GURL& /* root */,
246 const std::string& /* name */, 239 const std::string& /* name */,
247 base::File::Error error); 240 base::File::Error error);
248 SyncStatusCode InitializeChangeTrackerOnFileThread( 241 SyncStatusCode InitializeChangeTrackerOnFileThread(
249 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, 242 scoped_ptr<LocalFileChangeTracker>* tracker_ptr,
250 fileapi::FileSystemContext* file_system_context, 243 storage::FileSystemContext* file_system_context,
251 std::set<GURL>* origins_with_changes); 244 std::set<GURL>* origins_with_changes);
252 void DidInitializeChangeTrackerOnIOThread( 245 void DidInitializeChangeTrackerOnIOThread(
253 scoped_ptr<LocalFileChangeTracker>* tracker_ptr, 246 scoped_ptr<LocalFileChangeTracker>* tracker_ptr,
254 const GURL& source_url, 247 const GURL& source_url,
255 fileapi::FileSystemContext* file_system_context, 248 storage::FileSystemContext* file_system_context,
256 std::set<GURL>* origins_with_changes, 249 std::set<GURL>* origins_with_changes,
257 SyncStatusCode status); 250 SyncStatusCode status);
258 void DidInitialize( 251 void DidInitialize(const GURL& source_url,
259 const GURL& source_url, 252 storage::FileSystemContext* file_system_context,
260 fileapi::FileSystemContext* file_system_context, 253 SyncStatusCode status);
261 SyncStatusCode status);
262 254
263 // Helper routines for GetFileForLocalSync. 255 // Helper routines for GetFileForLocalSync.
264 scoped_ptr<FileSystemURLQueue> GetNextURLsForSyncOnFileThread( 256 scoped_ptr<FileSystemURLQueue> GetNextURLsForSyncOnFileThread(
265 fileapi::FileSystemContext* file_system_context); 257 storage::FileSystemContext* file_system_context);
266 void TryPrepareForLocalSync( 258 void TryPrepareForLocalSync(storage::FileSystemContext* file_system_context,
267 fileapi::FileSystemContext* file_system_context, 259 const LocalFileSyncInfoCallback& callback,
268 const LocalFileSyncInfoCallback& callback, 260 scoped_ptr<FileSystemURLQueue> urls);
269 scoped_ptr<FileSystemURLQueue> urls);
270 void DidTryPrepareForLocalSync( 261 void DidTryPrepareForLocalSync(
271 fileapi::FileSystemContext* file_system_context, 262 storage::FileSystemContext* file_system_context,
272 scoped_ptr<FileSystemURLQueue> remaining_urls, 263 scoped_ptr<FileSystemURLQueue> remaining_urls,
273 const LocalFileSyncInfoCallback& callback, 264 const LocalFileSyncInfoCallback& callback,
274 SyncStatusCode status, 265 SyncStatusCode status,
275 const LocalFileSyncInfo& sync_file_info, 266 const LocalFileSyncInfo& sync_file_info,
276 webkit_blob::ScopedFile snapshot); 267 storage::ScopedFile snapshot);
277 void PromoteDemotedChangesForURL( 268 void PromoteDemotedChangesForURL(
278 fileapi::FileSystemContext* file_system_context, 269 storage::FileSystemContext* file_system_context,
279 const fileapi::FileSystemURL& url); 270 const storage::FileSystemURL& url);
280 void PromoteDemotedChangesForURLs( 271 void PromoteDemotedChangesForURLs(
281 fileapi::FileSystemContext* file_system_context, 272 storage::FileSystemContext* file_system_context,
282 scoped_ptr<FileSystemURLQueue> url); 273 scoped_ptr<FileSystemURLQueue> url);
283 274
284 // Callback routine for PrepareForSync and GetFileForLocalSync. 275 // Callback routine for PrepareForSync and GetFileForLocalSync.
285 void DidGetWritingStatusForSync( 276 void DidGetWritingStatusForSync(
286 fileapi::FileSystemContext* file_system_context, 277 storage::FileSystemContext* file_system_context,
287 SyncStatusCode status, 278 SyncStatusCode status,
288 const fileapi::FileSystemURL& url, 279 const storage::FileSystemURL& url,
289 SyncMode sync_mode, 280 SyncMode sync_mode,
290 const LocalFileSyncInfoCallback& callback); 281 const LocalFileSyncInfoCallback& callback);
291 282
292 // Helper routine for sync/writing flag handling. 283 // Helper routine for sync/writing flag handling.
293 // 284 //
294 // If |for_snapshot_sync| is true, this increments the writing counter 285 // If |for_snapshot_sync| is true, this increments the writing counter
295 // for |url| (after clearing syncing flag), so that other sync activities 286 // for |url| (after clearing syncing flag), so that other sync activities
296 // won't step in while snapshot sync is ongoing. 287 // won't step in while snapshot sync is ongoing.
297 // In this case FinalizeSnapshotSyncOnIOThread must be called after the 288 // In this case FinalizeSnapshotSyncOnIOThread must be called after the
298 // snapshot sync is finished to decrement the writing counter. 289 // snapshot sync is finished to decrement the writing counter.
299 void ClearSyncFlagOnIOThread(const fileapi::FileSystemURL& url, 290 void ClearSyncFlagOnIOThread(const storage::FileSystemURL& url,
300 bool for_snapshot_sync); 291 bool for_snapshot_sync);
301 void FinalizeSnapshotSyncOnIOThread(const fileapi::FileSystemURL& url); 292 void FinalizeSnapshotSyncOnIOThread(const storage::FileSystemURL& url);
302 293
303 void HandleRemoteDelete( 294 void HandleRemoteDelete(storage::FileSystemContext* file_system_context,
304 fileapi::FileSystemContext* file_system_context, 295 const storage::FileSystemURL& url,
305 const fileapi::FileSystemURL& url, 296 const SyncStatusCallback& callback);
306 const SyncStatusCallback& callback); 297 void HandleRemoteAddOrUpdate(storage::FileSystemContext* file_system_context,
307 void HandleRemoteAddOrUpdate( 298 const FileChange& change,
308 fileapi::FileSystemContext* file_system_context, 299 const base::FilePath& local_path,
300 const storage::FileSystemURL& url,
301 const SyncStatusCallback& callback);
302 void DidRemoveExistingEntryForRemoteAddOrUpdate(
303 storage::FileSystemContext* file_system_context,
309 const FileChange& change, 304 const FileChange& change,
310 const base::FilePath& local_path, 305 const base::FilePath& local_path,
311 const fileapi::FileSystemURL& url, 306 const storage::FileSystemURL& url,
312 const SyncStatusCallback& callback);
313 void DidRemoveExistingEntryForRemoteAddOrUpdate(
314 fileapi::FileSystemContext* file_system_context,
315 const FileChange& change,
316 const base::FilePath& local_path,
317 const fileapi::FileSystemURL& url,
318 const SyncStatusCallback& callback, 307 const SyncStatusCallback& callback,
319 base::File::Error error); 308 base::File::Error error);
320 309
321 // Callback routine for ApplyRemoteChange. 310 // Callback routine for ApplyRemoteChange.
322 void DidApplyRemoteChange( 311 void DidApplyRemoteChange(const storage::FileSystemURL& url,
323 const fileapi::FileSystemURL& url, 312 const SyncStatusCallback& callback_on_ui,
324 const SyncStatusCallback& callback_on_ui, 313 base::File::Error file_error);
325 base::File::Error file_error);
326 314
327 void DidGetFileMetadata( 315 void DidGetFileMetadata(
328 const SyncFileMetadataCallback& callback, 316 const SyncFileMetadataCallback& callback,
329 base::File::Error file_error, 317 base::File::Error file_error,
330 const base::File::Info& file_info); 318 const base::File::Info& file_info);
331 319
332 base::TimeDelta NotifyChangesDuration(); 320 base::TimeDelta NotifyChangesDuration();
333 321
334 void DidCreateDirectoryForCopyIn( 322 void DidCreateDirectoryForCopyIn(
335 fileapi::FileSystemContext* file_system_context, 323 storage::FileSystemContext* file_system_context,
336 const base::FilePath& local_file_path, 324 const base::FilePath& local_file_path,
337 const fileapi::FileSystemURL& dest_url, 325 const storage::FileSystemURL& dest_url,
338 const StatusCallback& callback, 326 const StatusCallback& callback,
339 base::File::Error error); 327 base::File::Error error);
340 328
341 const base::FilePath local_base_path_; 329 const base::FilePath local_base_path_;
342 leveldb::Env* env_override_; 330 leveldb::Env* env_override_;
343 331
344 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 332 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
345 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 333 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
346 334
347 // Indicates if the sync service is shutdown. 335 // Indicates if the sync service is shutdown.
348 bool shutdown_on_ui_; // Updated and referred only on UI thread. 336 bool shutdown_on_ui_; // Updated and referred only on UI thread.
349 bool shutdown_on_io_; // Updated and referred only on IO thread. 337 bool shutdown_on_io_; // Updated and referred only on IO thread.
350 338
351 // OperationRunner. This must be accessed only on IO thread. 339 // OperationRunner. This must be accessed only on IO thread.
352 scoped_ptr<SyncableFileOperationRunner> operation_runner_; 340 scoped_ptr<SyncableFileOperationRunner> operation_runner_;
353 341
354 // Keeps track of writing/syncing status. 342 // Keeps track of writing/syncing status.
355 // This must be accessed only on IO thread. 343 // This must be accessed only on IO thread.
356 scoped_ptr<LocalFileSyncStatus> sync_status_; 344 scoped_ptr<LocalFileSyncStatus> sync_status_;
357 345
358 // Pointers to file system contexts that have been initialized for 346 // Pointers to file system contexts that have been initialized for
359 // synchronization (i.e. that own this instance). 347 // synchronization (i.e. that own this instance).
360 // This must be accessed only on UI thread. 348 // This must be accessed only on UI thread.
361 std::set<fileapi::FileSystemContext*> file_system_contexts_; 349 std::set<storage::FileSystemContext*> file_system_contexts_;
362 350
363 // Accessed only on UI thread. 351 // Accessed only on UI thread.
364 std::map<fileapi::FileSystemContext*, StatusCallbackQueue> 352 std::map<storage::FileSystemContext*, StatusCallbackQueue>
365 pending_initialize_callbacks_; 353 pending_initialize_callbacks_;
366 354
367 // A URL and associated callback waiting for sync is enabled. 355 // A URL and associated callback waiting for sync is enabled.
368 // Accessed only on IO thread. 356 // Accessed only on IO thread.
369 fileapi::FileSystemURL url_waiting_sync_on_io_; 357 storage::FileSystemURL url_waiting_sync_on_io_;
370 base::Closure url_syncable_callback_; 358 base::Closure url_syncable_callback_;
371 359
372 // Used only on IO thread for available changes notifications. 360 // Used only on IO thread for available changes notifications.
373 base::Time last_notified_changes_; 361 base::Time last_notified_changes_;
374 scoped_ptr<base::OneShotTimer<LocalFileSyncContext> > timer_on_io_; 362 scoped_ptr<base::OneShotTimer<LocalFileSyncContext> > timer_on_io_;
375 std::set<GURL> origins_with_pending_changes_; 363 std::set<GURL> origins_with_pending_changes_;
376 364
377 // Populated while root directory deletion is being handled for 365 // Populated while root directory deletion is being handled for
378 // ApplyRemoteChange(). Modified only on IO thread. 366 // ApplyRemoteChange(). Modified only on IO thread.
379 scoped_ptr<RootDeleteHelper> root_delete_helper_; 367 scoped_ptr<RootDeleteHelper> root_delete_helper_;
380 368
381 ObserverList<LocalOriginChangeObserver> origin_change_observers_; 369 ObserverList<LocalOriginChangeObserver> origin_change_observers_;
382 370
383 int mock_notify_changes_duration_in_sec_; 371 int mock_notify_changes_duration_in_sec_;
384 372
385 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext); 373 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext);
386 }; 374 };
387 375
388 } // namespace sync_file_system 376 } // namespace sync_file_system
389 377
390 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_ 378 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_LOCAL_FILE_SYNC_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698