| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/metrics/histogram.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob
server.h" | 16 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob
server.h" |
| 16 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he
lpers.h" | 17 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he
lpers.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
| 19 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 20 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" | 21 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" |
| 21 #include "chrome/browser/sync_file_system/logger.h" | 22 #include "chrome/browser/sync_file_system/logger.h" |
| 22 #include "chrome/browser/sync_file_system/sync_direction.h" | 23 #include "chrome/browser/sync_file_system/sync_direction.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 RemoteServiceState state) { | 55 RemoteServiceState state) { |
| 55 switch (state) { | 56 switch (state) { |
| 56 case REMOTE_SERVICE_OK: | 57 case REMOTE_SERVICE_OK: |
| 57 return SYNC_SERVICE_RUNNING; | 58 return SYNC_SERVICE_RUNNING; |
| 58 case REMOTE_SERVICE_TEMPORARY_UNAVAILABLE: | 59 case REMOTE_SERVICE_TEMPORARY_UNAVAILABLE: |
| 59 return SYNC_SERVICE_TEMPORARY_UNAVAILABLE; | 60 return SYNC_SERVICE_TEMPORARY_UNAVAILABLE; |
| 60 case REMOTE_SERVICE_AUTHENTICATION_REQUIRED: | 61 case REMOTE_SERVICE_AUTHENTICATION_REQUIRED: |
| 61 return SYNC_SERVICE_AUTHENTICATION_REQUIRED; | 62 return SYNC_SERVICE_AUTHENTICATION_REQUIRED; |
| 62 case REMOTE_SERVICE_DISABLED: | 63 case REMOTE_SERVICE_DISABLED: |
| 63 return SYNC_SERVICE_DISABLED; | 64 return SYNC_SERVICE_DISABLED; |
| 65 case REMOTE_SERVICE_STATE_MAX: |
| 66 NOTREACHED(); |
| 64 } | 67 } |
| 65 NOTREACHED() << "Unknown remote service state: " << state; | 68 NOTREACHED() << "Unknown remote service state: " << state; |
| 66 return SYNC_SERVICE_DISABLED; | 69 return SYNC_SERVICE_DISABLED; |
| 67 } | 70 } |
| 68 | 71 |
| 69 void DidHandleOriginForExtensionUnloadedEvent( | 72 void DidHandleOriginForExtensionUnloadedEvent( |
| 70 int type, | 73 int type, |
| 71 const GURL& origin, | 74 const GURL& origin, |
| 72 SyncStatusCode code) { | 75 SyncStatusCode code) { |
| 73 DCHECK(chrome::NOTIFICATION_EXTENSION_UNLOADED == type || | 76 DCHECK(chrome::NOTIFICATION_EXTENSION_UNLOADED == type || |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 385 } |
| 383 | 386 |
| 384 ConflictResolutionPolicy SyncFileSystemService::GetConflictResolutionPolicy( | 387 ConflictResolutionPolicy SyncFileSystemService::GetConflictResolutionPolicy( |
| 385 const GURL& origin) { | 388 const GURL& origin) { |
| 386 return GetRemoteService(origin)->GetConflictResolutionPolicy(origin); | 389 return GetRemoteService(origin)->GetConflictResolutionPolicy(origin); |
| 387 } | 390 } |
| 388 | 391 |
| 389 SyncStatusCode SyncFileSystemService::SetConflictResolutionPolicy( | 392 SyncStatusCode SyncFileSystemService::SetConflictResolutionPolicy( |
| 390 const GURL& origin, | 393 const GURL& origin, |
| 391 ConflictResolutionPolicy policy) { | 394 ConflictResolutionPolicy policy) { |
| 395 UMA_HISTOGRAM_ENUMERATION("SyncFileSystem.ConflictResolutionPolicy", |
| 396 policy, CONFLICT_RESOLUTION_POLICY_MAX); |
| 392 return GetRemoteService(origin)->SetConflictResolutionPolicy(origin, policy); | 397 return GetRemoteService(origin)->SetConflictResolutionPolicy(origin, policy); |
| 393 } | 398 } |
| 394 | 399 |
| 395 LocalChangeProcessor* SyncFileSystemService::GetLocalChangeProcessor( | 400 LocalChangeProcessor* SyncFileSystemService::GetLocalChangeProcessor( |
| 396 const GURL& origin) { | 401 const GURL& origin) { |
| 397 return GetRemoteService(origin)->GetLocalChangeProcessor(); | 402 return GetRemoteService(origin)->GetLocalChangeProcessor(); |
| 398 } | 403 } |
| 399 | 404 |
| 400 SyncFileSystemService::SyncFileSystemService(Profile* profile) | 405 SyncFileSystemService::SyncFileSystemService(Profile* profile) |
| 401 : profile_(profile), | 406 : profile_(profile), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 473 |
| 469 void SyncFileSystemService::DidRegisterOrigin( | 474 void SyncFileSystemService::DidRegisterOrigin( |
| 470 const GURL& app_origin, | 475 const GURL& app_origin, |
| 471 const SyncStatusCallback& callback, | 476 const SyncStatusCallback& callback, |
| 472 SyncStatusCode status) { | 477 SyncStatusCode status) { |
| 473 util::Log(logging::LOG_VERBOSE, FROM_HERE, | 478 util::Log(logging::LOG_VERBOSE, FROM_HERE, |
| 474 "DidInitializeForApp (registered the origin): %s: %s", | 479 "DidInitializeForApp (registered the origin): %s: %s", |
| 475 app_origin.spec().c_str(), | 480 app_origin.spec().c_str(), |
| 476 SyncStatusCodeToString(status)); | 481 SyncStatusCodeToString(status)); |
| 477 | 482 |
| 483 UMA_HISTOGRAM_ENUMERATION("SyncFileSystem.RegisterOriginResult", |
| 484 GetRemoteService(app_origin)->GetCurrentState(), |
| 485 REMOTE_SERVICE_STATE_MAX); |
| 486 |
| 478 if (status == SYNC_STATUS_FAILED) { | 487 if (status == SYNC_STATUS_FAILED) { |
| 479 // If we got generic error return the service status information. | 488 // If we got generic error return the service status information. |
| 480 switch (GetRemoteService(app_origin)->GetCurrentState()) { | 489 switch (GetRemoteService(app_origin)->GetCurrentState()) { |
| 481 case REMOTE_SERVICE_AUTHENTICATION_REQUIRED: | 490 case REMOTE_SERVICE_AUTHENTICATION_REQUIRED: |
| 482 callback.Run(SYNC_STATUS_AUTHENTICATION_FAILED); | 491 callback.Run(SYNC_STATUS_AUTHENTICATION_FAILED); |
| 483 return; | 492 return; |
| 484 case REMOTE_SERVICE_TEMPORARY_UNAVAILABLE: | 493 case REMOTE_SERVICE_TEMPORARY_UNAVAILABLE: |
| 485 callback.Run(SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE); | 494 callback.Run(SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE); |
| 486 return; | 495 return; |
| 487 default: | 496 default: |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); | 776 v2_remote_service_->SetRemoteChangeProcessor(local_service_.get()); |
| 768 v2_remote_service_->SetSyncEnabled(sync_enabled_); | 777 v2_remote_service_->SetSyncEnabled(sync_enabled_); |
| 769 v2_remote_service_->SetDefaultConflictResolutionPolicy( | 778 v2_remote_service_->SetDefaultConflictResolutionPolicy( |
| 770 remote_service_->GetDefaultConflictResolutionPolicy()); | 779 remote_service_->GetDefaultConflictResolutionPolicy()); |
| 771 remote_sync_runners_.push_back(v2_remote_syncer.release()); | 780 remote_sync_runners_.push_back(v2_remote_syncer.release()); |
| 772 } | 781 } |
| 773 return v2_remote_service_.get(); | 782 return v2_remote_service_.get(); |
| 774 } | 783 } |
| 775 | 784 |
| 776 } // namespace sync_file_system | 785 } // namespace sync_file_system |
| OLD | NEW |