Chromium Code Reviews| 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 "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/site_instance.h" | 15 #include "content/public/browser/site_instance.h" |
| 15 #include "content/public/browser/storage_partition.h" | 16 #include "content/public/browser/storage_partition.h" |
| 16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 17 #include "webkit/fileapi/file_system_context.h" | 18 #include "webkit/fileapi/file_system_context.h" |
| 18 #include "webkit/fileapi/file_system_url.h" | 19 #include "webkit/fileapi/file_system_url.h" |
| 19 #include "webkit/fileapi/syncable/file_change.h" | 20 #include "webkit/fileapi/syncable/file_change.h" |
| 20 #include "webkit/fileapi/syncable/local_file_change_tracker.h" | 21 #include "webkit/fileapi/syncable/local_file_change_tracker.h" |
| 21 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 22 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 if (!ContainsKey(origin_to_contexts_, url.origin())) { | 194 if (!ContainsKey(origin_to_contexts_, url.origin())) { |
| 194 // This could happen if a remote sync is triggered for the app that hasn't | 195 // This could happen if a remote sync is triggered for the app that hasn't |
| 195 // been initialized in this service. | 196 // been initialized in this service. |
| 196 DCHECK(profile_); | 197 DCHECK(profile_); |
| 197 // The given url.origin() must be for valid installed app. | 198 // The given url.origin() must be for valid installed app. |
| 198 ExtensionService* extension_service = | 199 ExtensionService* extension_service = |
| 199 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 200 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 200 const extensions::Extension* extension = extension_service->GetInstalledApp( | 201 const extensions::Extension* extension = extension_service->GetInstalledApp( |
| 201 url.origin()); | 202 url.origin()); |
| 202 if (!extension) { | 203 if (!extension) { |
| 203 LOG(WARNING) << "PrepareForProcessRemoteChange called for non-existing " | 204 std::string warn_msg = std::string( |
|
nhiroki
2013/05/22 05:42:40
How about using std::ostringstream?
calvinlo
2013/05/22 08:42:56
Done.
| |
| 204 << " origin:" << url.origin().spec(); | 205 "PrepareForProcessRemoteChange called for non-existing origin:") |
|
nhiroki
2013/05/22 05:42:40
super-nit: s/origin:/origin: / for readability
calvinlo
2013/05/22 08:42:56
Done.
| |
| 206 .append(url.origin().spec()); | |
| 207 util::Log(logging::LOG_WARNING, warn_msg); | |
| 208 | |
| 205 // The extension has been uninstalled and this method is called | 209 // The extension has been uninstalled and this method is called |
| 206 // before the remote changes for the origin are removed. | 210 // before the remote changes for the origin are removed. |
| 207 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, | 211 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, |
| 208 SyncFileMetadata(), FileChangeList()); | 212 SyncFileMetadata(), FileChangeList()); |
| 209 return; | 213 return; |
| 210 } | 214 } |
| 211 GURL site_url = extension_service->GetSiteForExtensionId(extension->id()); | 215 GURL site_url = extension_service->GetSiteForExtensionId(extension->id()); |
| 212 DCHECK(!site_url.is_empty()); | 216 DCHECK(!site_url.is_empty()); |
| 213 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 217 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
| 214 content::BrowserContext::GetStoragePartitionForSite( | 218 content::BrowserContext::GetStoragePartitionForSite( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 changes.front(), | 418 changes.front(), |
| 415 sync_file_info.local_file_path, | 419 sync_file_info.local_file_path, |
| 416 sync_file_info.metadata, | 420 sync_file_info.metadata, |
| 417 url, | 421 url, |
| 418 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, | 422 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, |
| 419 AsWeakPtr(), sync_file_info, | 423 AsWeakPtr(), sync_file_info, |
| 420 changes.front(), changes.PopAndGetNewList())); | 424 changes.front(), changes.PopAndGetNewList())); |
| 421 } | 425 } |
| 422 | 426 |
| 423 } // namespace sync_file_system | 427 } // namespace sync_file_system |
| OLD | NEW |