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 #include "chrome/browser/sync_file_system/local_file_sync_service.h" | 5 #include "chrome/browser/sync_file_system/local_file_sync_service.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/sync_file_system/local_change_processor.h" | 11 #include "chrome/browser/sync_file_system/local_change_processor.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/site_instance.h" | 14 #include "content/public/browser/site_instance.h" |
15 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "webkit/fileapi/file_system_context.h" | 17 #include "webkit/fileapi/file_system_context.h" |
18 #include "webkit/fileapi/file_system_url.h" | 18 #include "webkit/fileapi/file_system_url.h" |
19 #include "webkit/fileapi/syncable/file_change.h" | 19 #include "webkit/fileapi/syncable/file_change.h" |
20 #include "webkit/fileapi/syncable/local_file_change_tracker.h" | 20 #include "webkit/fileapi/syncable/local_file_change_tracker.h" |
21 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 21 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
22 #include "webkit/fileapi/syncable/sync_file_metadata.h" | 22 #include "webkit/fileapi/syncable/sync_file_metadata.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
25 using fileapi::FileChange; | |
26 using fileapi::FileChangeList; | |
27 using fileapi::FileSystemURL; | 25 using fileapi::FileSystemURL; |
28 using fileapi::LocalFileSyncContext; | 26 using fileapi::LocalFileSyncContext; |
29 using fileapi::LocalFileSyncInfo; | 27 using fileapi::LocalFileSyncInfo; |
30 using fileapi::SyncFileCallback; | 28 using fileapi::SyncFileCallback; |
31 using fileapi::SyncFileMetadataCallback; | 29 using fileapi::SyncFileMetadataCallback; |
32 using fileapi::SyncStatusCallback; | 30 using fileapi::SyncStatusCallback; |
33 using fileapi::SyncStatusCallback; | 31 using fileapi::SyncStatusCallback; |
34 using fileapi::SyncStatusCode; | 32 using fileapi::SyncStatusCode; |
| 33 using sync_file_system::FileChange; |
| 34 using sync_file_system::FileChangeList; |
35 | 35 |
36 namespace sync_file_system { | 36 namespace sync_file_system { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 void PrepareForProcessRemoteChangeCallbackAdapter( | 40 void PrepareForProcessRemoteChangeCallbackAdapter( |
41 const RemoteChangeProcessor::PrepareChangeCallback& callback, | 41 const RemoteChangeProcessor::PrepareChangeCallback& callback, |
42 SyncStatusCode status, | 42 SyncStatusCode status, |
43 const LocalFileSyncInfo& sync_file_info) { | 43 const LocalFileSyncInfo& sync_file_info) { |
44 callback.Run(status, sync_file_info.metadata, sync_file_info.changes); | 44 callback.Run(status, sync_file_info.metadata, sync_file_info.changes); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 void LocalFileSyncService::ClearLocalChanges( | 243 void LocalFileSyncService::ClearLocalChanges( |
244 const fileapi::FileSystemURL& url, | 244 const fileapi::FileSystemURL& url, |
245 const base::Closure& completion_callback) { | 245 const base::Closure& completion_callback) { |
246 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); | 246 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); |
247 sync_context_->ClearChangesForURL(origin_to_contexts_[url.origin()], | 247 sync_context_->ClearChangesForURL(origin_to_contexts_[url.origin()], |
248 url, completion_callback); | 248 url, completion_callback); |
249 } | 249 } |
250 | 250 |
251 void LocalFileSyncService::RecordFakeLocalChange( | 251 void LocalFileSyncService::RecordFakeLocalChange( |
252 const fileapi::FileSystemURL& url, | 252 const fileapi::FileSystemURL& url, |
253 const fileapi::FileChange& change, | 253 const FileChange& change, |
254 const fileapi::SyncStatusCallback& callback) { | 254 const fileapi::SyncStatusCallback& callback) { |
255 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); | 255 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); |
256 sync_context_->RecordFakeLocalChange(origin_to_contexts_[url.origin()], | 256 sync_context_->RecordFakeLocalChange(origin_to_contexts_[url.origin()], |
257 url, change, callback); | 257 url, change, callback); |
258 } | 258 } |
259 | 259 |
260 void LocalFileSyncService::OnChangesAvailableInOrigins( | 260 void LocalFileSyncService::OnChangesAvailableInOrigins( |
261 const std::set<GURL>& origins) { | 261 const std::set<GURL>& origins) { |
262 bool need_notification = false; | 262 bool need_notification = false; |
263 for (std::set<GURL>::const_iterator iter = origins.begin(); | 263 for (std::set<GURL>::const_iterator iter = origins.begin(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 processor->ApplyLocalChange( | 418 processor->ApplyLocalChange( |
419 changes.front(), | 419 changes.front(), |
420 sync_file_info.local_file_path, | 420 sync_file_info.local_file_path, |
421 url, | 421 url, |
422 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, | 422 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, |
423 AsWeakPtr(), processor, sync_file_info, | 423 AsWeakPtr(), processor, sync_file_info, |
424 changes.front(), changes.PopAndGetNewList())); | 424 changes.front(), changes.PopAndGetNewList())); |
425 } | 425 } |
426 | 426 |
427 } // namespace sync_file_system | 427 } // namespace sync_file_system |
OLD | NEW |