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 "chrome/browser/sync_file_system/logger.h" | 12 #include "chrome/browser/sync_file_system/logger.h" |
13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/site_instance.h" | 15 #include "content/public/browser/site_instance.h" |
16 #include "content/public/browser/storage_partition.h" | 16 #include "content/public/browser/storage_partition.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 #include "webkit/browser/fileapi/file_system_context.h" | 18 #include "webkit/browser/fileapi/file_system_context.h" |
19 #include "webkit/browser/fileapi/file_system_url.h" | 19 #include "webkit/browser/fileapi/file_system_url.h" |
20 #include "webkit/browser/fileapi/syncable/file_change.h" | 20 #include "webkit/browser/fileapi/syncable/file_change.h" |
21 #include "webkit/browser/fileapi/syncable/local_file_change_tracker.h" | 21 #include "webkit/browser/fileapi/syncable/local_file_change_tracker.h" |
22 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" | 22 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" |
23 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h" | 23 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h" |
24 #include "webkit/browser/fileapi/syncable/sync_file_system_backend.h" | |
24 | 25 |
25 using content::BrowserThread; | 26 using content::BrowserThread; |
26 using fileapi::FileSystemURL; | 27 using fileapi::FileSystemURL; |
27 | 28 |
28 namespace sync_file_system { | 29 namespace sync_file_system { |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 void PrepareForProcessRemoteChangeCallbackAdapter( | 33 void PrepareForProcessRemoteChangeCallbackAdapter( |
33 const RemoteChangeProcessor::PrepareChangeCallback& callback, | 34 const RemoteChangeProcessor::PrepareChangeCallback& callback, |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 // This could happen if this is called for apps/origins that haven't | 277 // This could happen if this is called for apps/origins that haven't |
277 // been initialized yet, or for apps/origins that are disabled. | 278 // been initialized yet, or for apps/origins that are disabled. |
278 // (Local change tracker could call this for uninitialized origins | 279 // (Local change tracker could call this for uninitialized origins |
279 // while it's reading dirty files from the database in the | 280 // while it's reading dirty files from the database in the |
280 // initialization phase.) | 281 // initialization phase.) |
281 pending_origins_with_changes_.insert(origin); | 282 pending_origins_with_changes_.insert(origin); |
282 continue; | 283 continue; |
283 } | 284 } |
284 need_notification = true; | 285 need_notification = true; |
285 fileapi::FileSystemContext* context = origin_to_contexts_[origin]; | 286 fileapi::FileSystemContext* context = origin_to_contexts_[origin]; |
286 DCHECK(context->change_tracker()); | 287 SyncFileSystemBackend* backend = SyncFileSystemBackend::GetBackend(context); |
288 DCHECK(backend); | |
289 DCHECK(backend->change_tracker()); | |
287 origin_change_map_.SetOriginChangeCount( | 290 origin_change_map_.SetOriginChangeCount( |
288 origin, context->change_tracker()->num_changes()); | 291 origin, backend->change_tracker()->num_changes()); |
kinuko
2013/07/17 15:01:30
I think these changes can be made later in a separ
nhiroki
2013/07/22 04:34:14
Hmm... these changes are needed for compiling succ
nhiroki
2013/07/22 06:33:38
Reverted. I'll make a separate CL.
| |
289 } | 292 } |
290 if (!need_notification) | 293 if (!need_notification) |
291 return; | 294 return; |
292 int64 num_changes = origin_change_map_.GetTotalChangeCount(); | 295 int64 num_changes = origin_change_map_.GetTotalChangeCount(); |
293 FOR_EACH_OBSERVER(Observer, change_observers_, | 296 FOR_EACH_OBSERVER(Observer, change_observers_, |
294 OnLocalChangeAvailable(num_changes)); | 297 OnLocalChangeAvailable(num_changes)); |
295 } | 298 } |
296 | 299 |
297 void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) { | 300 void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) { |
298 if (!ContainsKey(origin_to_contexts_, origin)) | 301 if (!ContainsKey(origin_to_contexts_, origin)) |
(...skipping 10 matching lines...) Expand all Loading... | |
309 callback.Run(status); | 312 callback.Run(status); |
310 return; | 313 return; |
311 } | 314 } |
312 DCHECK(file_system_context); | 315 DCHECK(file_system_context); |
313 origin_to_contexts_[app_origin] = file_system_context; | 316 origin_to_contexts_[app_origin] = file_system_context; |
314 | 317 |
315 if (pending_origins_with_changes_.find(app_origin) != | 318 if (pending_origins_with_changes_.find(app_origin) != |
316 pending_origins_with_changes_.end()) { | 319 pending_origins_with_changes_.end()) { |
317 // We have remaining changes for the origin. | 320 // We have remaining changes for the origin. |
318 pending_origins_with_changes_.erase(app_origin); | 321 pending_origins_with_changes_.erase(app_origin); |
319 DCHECK(file_system_context->change_tracker()); | 322 SyncFileSystemBackend* backend = |
323 SyncFileSystemBackend::GetBackend(file_system_context); | |
324 DCHECK(backend); | |
325 DCHECK(backend->change_tracker()); | |
320 origin_change_map_.SetOriginChangeCount( | 326 origin_change_map_.SetOriginChangeCount( |
321 app_origin, file_system_context->change_tracker()->num_changes()); | 327 app_origin, backend->change_tracker()->num_changes()); |
322 int64 num_changes = origin_change_map_.GetTotalChangeCount(); | 328 int64 num_changes = origin_change_map_.GetTotalChangeCount(); |
323 FOR_EACH_OBSERVER(Observer, change_observers_, | 329 FOR_EACH_OBSERVER(Observer, change_observers_, |
324 OnLocalChangeAvailable(num_changes)); | 330 OnLocalChangeAvailable(num_changes)); |
325 } | 331 } |
326 callback.Run(status); | 332 callback.Run(status); |
327 } | 333 } |
328 | 334 |
329 void LocalFileSyncService::DidInitializeForRemoteSync( | 335 void LocalFileSyncService::DidInitializeForRemoteSync( |
330 const FileSystemURL& url, | 336 const FileSystemURL& url, |
331 fileapi::FileSystemContext* file_system_context, | 337 fileapi::FileSystemContext* file_system_context, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 changes.front(), | 430 changes.front(), |
425 sync_file_info.local_file_path, | 431 sync_file_info.local_file_path, |
426 sync_file_info.metadata, | 432 sync_file_info.metadata, |
427 url, | 433 url, |
428 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, | 434 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, |
429 AsWeakPtr(), sync_file_info, | 435 AsWeakPtr(), sync_file_info, |
430 changes.front(), changes.PopAndGetNewList())); | 436 changes.front(), changes.PopAndGetNewList())); |
431 } | 437 } |
432 | 438 |
433 } // namespace sync_file_system | 439 } // namespace sync_file_system |
OLD | NEW |