| 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/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "extensions/browser/extension_registry.h" | 34 #include "extensions/browser/extension_registry.h" |
| 35 #include "extensions/common/extension.h" | 35 #include "extensions/common/extension.h" |
| 36 #include "extensions/common/manifest_constants.h" | 36 #include "extensions/common/manifest_constants.h" |
| 37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 38 #include "webkit/browser/fileapi/file_system_context.h" | 38 #include "webkit/browser/fileapi/file_system_context.h" |
| 39 | 39 |
| 40 using content::BrowserThread; | 40 using content::BrowserThread; |
| 41 using extensions::Extension; | 41 using extensions::Extension; |
| 42 using extensions::ExtensionPrefs; | 42 using extensions::ExtensionPrefs; |
| 43 using extensions::ExtensionRegistry; | 43 using extensions::ExtensionRegistry; |
| 44 using fileapi::FileSystemURL; | 44 using storage::FileSystemURL; |
| 45 using fileapi::FileSystemURLSet; | 45 using storage::FileSystemURLSet; |
| 46 | 46 |
| 47 namespace sync_file_system { | 47 namespace sync_file_system { |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 const char kLocalSyncName[] = "Local sync"; | 51 const char kLocalSyncName[] = "Local sync"; |
| 52 const char kRemoteSyncName[] = "Remote sync"; | 52 const char kRemoteSyncName[] = "Remote sync"; |
| 53 | 53 |
| 54 SyncServiceState RemoteStateToSyncServiceState( | 54 SyncServiceState RemoteStateToSyncServiceState( |
| 55 RemoteServiceState state) { | 55 RemoteServiceState state) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 profile_ = NULL; | 270 profile_ = NULL; |
| 271 } | 271 } |
| 272 | 272 |
| 273 SyncFileSystemService::~SyncFileSystemService() { | 273 SyncFileSystemService::~SyncFileSystemService() { |
| 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 275 DCHECK(!profile_); | 275 DCHECK(!profile_); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void SyncFileSystemService::InitializeForApp( | 278 void SyncFileSystemService::InitializeForApp( |
| 279 fileapi::FileSystemContext* file_system_context, | 279 storage::FileSystemContext* file_system_context, |
| 280 const GURL& app_origin, | 280 const GURL& app_origin, |
| 281 const SyncStatusCallback& callback) { | 281 const SyncStatusCallback& callback) { |
| 282 DCHECK(local_service_); | 282 DCHECK(local_service_); |
| 283 DCHECK(remote_service_); | 283 DCHECK(remote_service_); |
| 284 DCHECK(app_origin == app_origin.GetOrigin()); | 284 DCHECK(app_origin == app_origin.GetOrigin()); |
| 285 | 285 |
| 286 util::Log(logging::LOG_VERBOSE, FROM_HERE, | 286 util::Log(logging::LOG_VERBOSE, FROM_HERE, |
| 287 "Initializing for App: %s", app_origin.spec().c_str()); | 287 "Initializing for App: %s", app_origin.spec().c_str()); |
| 288 | 288 |
| 289 local_service_->MaybeInitializeFileSystemContext( | 289 local_service_->MaybeInitializeFileSystemContext( |
| 290 app_origin, file_system_context, | 290 app_origin, file_system_context, |
| 291 base::Bind(&SyncFileSystemService::DidInitializeFileSystem, | 291 base::Bind(&SyncFileSystemService::DidInitializeFileSystem, |
| 292 AsWeakPtr(), app_origin, callback)); | 292 AsWeakPtr(), app_origin, callback)); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void SyncFileSystemService::GetExtensionStatusMap( | 295 void SyncFileSystemService::GetExtensionStatusMap( |
| 296 const ExtensionStatusMapCallback& callback) { | 296 const ExtensionStatusMapCallback& callback) { |
| 297 remote_service_->GetOriginStatusMap( | 297 remote_service_->GetOriginStatusMap( |
| 298 base::Bind(&SyncFileSystemService::DidGetExtensionStatusMap, | 298 base::Bind(&SyncFileSystemService::DidGetExtensionStatusMap, |
| 299 AsWeakPtr(), callback)); | 299 AsWeakPtr(), callback)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void SyncFileSystemService::DumpFiles(const GURL& origin, | 302 void SyncFileSystemService::DumpFiles(const GURL& origin, |
| 303 const DumpFilesCallback& callback) { | 303 const DumpFilesCallback& callback) { |
| 304 DCHECK(!origin.is_empty()); | 304 DCHECK(!origin.is_empty()); |
| 305 | 305 |
| 306 content::StoragePartition* storage_partition = | 306 content::StoragePartition* storage_partition = |
| 307 content::BrowserContext::GetStoragePartitionForSite(profile_, origin); | 307 content::BrowserContext::GetStoragePartitionForSite(profile_, origin); |
| 308 fileapi::FileSystemContext* file_system_context = | 308 storage::FileSystemContext* file_system_context = |
| 309 storage_partition->GetFileSystemContext(); | 309 storage_partition->GetFileSystemContext(); |
| 310 local_service_->MaybeInitializeFileSystemContext( | 310 local_service_->MaybeInitializeFileSystemContext( |
| 311 origin, file_system_context, | 311 origin, file_system_context, |
| 312 base::Bind(&SyncFileSystemService::DidInitializeFileSystemForDump, | 312 base::Bind(&SyncFileSystemService::DidInitializeFileSystemForDump, |
| 313 AsWeakPtr(), origin, callback)); | 313 AsWeakPtr(), origin, callback)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void SyncFileSystemService::DumpDatabase(const DumpFilesCallback& callback) { | 316 void SyncFileSystemService::DumpDatabase(const DumpFilesCallback& callback) { |
| 317 remote_service_->DumpDatabase( | 317 remote_service_->DumpDatabase( |
| 318 base::Bind(&SyncFileSystemService::DidDumpDatabase, | 318 base::Bind(&SyncFileSystemService::DidDumpDatabase, |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 iter != remote_sync_runners_.end(); ++iter) | 747 iter != remote_sync_runners_.end(); ++iter) |
| 748 ((*iter)->*method)(); | 748 ((*iter)->*method)(); |
| 749 } | 749 } |
| 750 | 750 |
| 751 RemoteFileSyncService* SyncFileSystemService::GetRemoteService( | 751 RemoteFileSyncService* SyncFileSystemService::GetRemoteService( |
| 752 const GURL& origin) { | 752 const GURL& origin) { |
| 753 return remote_service_.get(); | 753 return remote_service_.get(); |
| 754 } | 754 } |
| 755 | 755 |
| 756 } // namespace sync_file_system | 756 } // namespace sync_file_system |
| OLD | NEW |