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 "components/browser_sync/browser/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/feature_list.h" | 19 #include "base/feature_list.h" |
20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
24 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
25 #include "base/metrics/histogram.h" | 25 #include "base/metrics/histogram.h" |
26 #include "base/profiler/scoped_tracker.h" | 26 #include "base/profiler/scoped_tracker.h" |
27 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
28 #include "base/strings/string16.h" | 28 #include "base/strings/string16.h" |
29 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
30 #include "base/threading/thread_restrictions.h" | 30 #include "base/threading/thread_restrictions.h" |
31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" |
32 #include "base/time/time.h" | 32 #include "base/time/time.h" |
33 #include "build/build_config.h" | 33 #include "build/build_config.h" |
34 #include "components/autofill/core/common/autofill_pref_names.h" | 34 #include "components/autofill/core/common/autofill_pref_names.h" |
35 #include "components/browser_sync/common/browser_sync_switches.h" | 35 #include "components/browser_sync/browser_sync_switches.h" |
36 #include "components/history/core/browser/typed_url_data_type_controller.h" | 36 #include "components/history/core/browser/typed_url_data_type_controller.h" |
37 #include "components/invalidation/impl/invalidation_prefs.h" | 37 #include "components/invalidation/impl/invalidation_prefs.h" |
38 #include "components/invalidation/public/invalidation_service.h" | 38 #include "components/invalidation/public/invalidation_service.h" |
39 #include "components/pref_registry/pref_registry_syncable.h" | 39 #include "components/pref_registry/pref_registry_syncable.h" |
40 #include "components/prefs/json_pref_store.h" | 40 #include "components/prefs/json_pref_store.h" |
41 #include "components/signin/core/browser/about_signin_internals.h" | 41 #include "components/signin/core/browser/about_signin_internals.h" |
42 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 42 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
43 #include "components/signin/core/browser/signin_manager.h" | 43 #include "components/signin/core/browser/signin_manager.h" |
44 #include "components/signin/core/browser/signin_metrics.h" | 44 #include "components/signin/core/browser/signin_metrics.h" |
45 #include "components/strings/grit/components_strings.h" | 45 #include "components/strings/grit/components_strings.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 using syncer::JsEventHandler; | 116 using syncer::JsEventHandler; |
117 using syncer::ModelSafeRoutingInfo; | 117 using syncer::ModelSafeRoutingInfo; |
118 using syncer::SyncCredentials; | 118 using syncer::SyncCredentials; |
119 using syncer::SyncProtocolError; | 119 using syncer::SyncProtocolError; |
120 using syncer::WeakHandle; | 120 using syncer::WeakHandle; |
121 using syncer_v2::ModelTypeStore; | 121 using syncer_v2::ModelTypeStore; |
122 using syncer_v2::SharedModelTypeProcessor; | 122 using syncer_v2::SharedModelTypeProcessor; |
123 | 123 |
124 typedef GoogleServiceAuthError AuthError; | 124 typedef GoogleServiceAuthError AuthError; |
125 | 125 |
126 const char kSyncUnrecoverableErrorHistogram[] = | 126 const char kSyncUnrecoverableErrorHistogram[] = "Sync.UnrecoverableErrors"; |
127 "Sync.UnrecoverableErrors"; | |
128 | 127 |
129 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { | 128 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { |
130 // Number of initial errors (in sequence) to ignore before applying | 129 // Number of initial errors (in sequence) to ignore before applying |
131 // exponential back-off rules. | 130 // exponential back-off rules. |
132 0, | 131 0, |
133 | 132 |
134 // Initial delay for exponential back-off in ms. | 133 // Initial delay for exponential back-off in ms. |
135 2000, | 134 2000, |
136 | 135 |
137 // Factor by which the waiting time will be multiplied. | 136 // Factor by which the waiting time will be multiplied. |
(...skipping 27 matching lines...) Expand all Loading... |
165 // This should only be called on the sync thread. | 164 // This should only be called on the sync thread. |
166 void DeleteSyncDataFolder(const base::FilePath& directory_path) { | 165 void DeleteSyncDataFolder(const base::FilePath& directory_path) { |
167 if (base::DirectoryExists(directory_path)) { | 166 if (base::DirectoryExists(directory_path)) { |
168 if (!base::DeleteFile(directory_path, true)) | 167 if (!base::DeleteFile(directory_path, true)) |
169 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 168 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
170 } | 169 } |
171 } | 170 } |
172 | 171 |
173 } // namespace | 172 } // namespace |
174 | 173 |
175 bool ShouldShowActionOnUI( | 174 bool ShouldShowActionOnUI(const syncer::SyncProtocolError& error) { |
176 const syncer::SyncProtocolError& error) { | |
177 return (error.action != syncer::UNKNOWN_ACTION && | 175 return (error.action != syncer::UNKNOWN_ACTION && |
178 error.action != syncer::DISABLE_SYNC_ON_CLIENT && | 176 error.action != syncer::DISABLE_SYNC_ON_CLIENT && |
179 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT && | 177 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT && |
180 error.action != syncer::RESET_LOCAL_SYNC_DATA); | 178 error.action != syncer::RESET_LOCAL_SYNC_DATA); |
181 } | 179 } |
182 | 180 |
183 ProfileSyncService::InitParams::InitParams() = default; | 181 ProfileSyncService::InitParams::InitParams() = default; |
184 ProfileSyncService::InitParams::~InitParams() = default; | 182 ProfileSyncService::InitParams::~InitParams() = default; |
185 ProfileSyncService::InitParams::InitParams(InitParams&& other) // NOLINT | 183 ProfileSyncService::InitParams::InitParams(InitParams&& other) // NOLINT |
186 : sync_client(std::move(other.sync_client)), | 184 : sync_client(std::move(other.sync_client)), |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 return device_info_sync_service_.get(); | 455 return device_info_sync_service_.get(); |
458 } | 456 } |
459 } | 457 } |
460 | 458 |
461 sync_driver::LocalDeviceInfoProvider* | 459 sync_driver::LocalDeviceInfoProvider* |
462 ProfileSyncService::GetLocalDeviceInfoProvider() const { | 460 ProfileSyncService::GetLocalDeviceInfoProvider() const { |
463 return local_device_.get(); | 461 return local_device_.get(); |
464 } | 462 } |
465 | 463 |
466 void ProfileSyncService::GetDataTypeControllerStates( | 464 void ProfileSyncService::GetDataTypeControllerStates( |
467 DataTypeController::StateMap* state_map) const { | 465 DataTypeController::StateMap* state_map) const { |
468 for (DataTypeController::TypeMap::const_iterator iter = | 466 for (DataTypeController::TypeMap::const_iterator iter = |
469 data_type_controllers_.begin(); | 467 data_type_controllers_.begin(); |
470 iter != data_type_controllers_.end(); ++iter) | 468 iter != data_type_controllers_.end(); ++iter) |
471 (*state_map)[iter->first] = iter->second.get()->state(); | 469 (*state_map)[iter->first] = iter->second.get()->state(); |
472 } | 470 } |
473 | 471 |
474 void ProfileSyncService::OnSessionRestoreComplete() { | 472 void ProfileSyncService::OnSessionRestoreComplete() { |
475 DataTypeController::TypeMap::const_iterator iter = | 473 DataTypeController::TypeMap::const_iterator iter = |
476 data_type_controllers_.find(syncer::SESSIONS); | 474 data_type_controllers_.find(syncer::SESSIONS); |
477 if (iter == data_type_controllers_.end()) { | 475 if (iter == data_type_controllers_.end()) { |
478 return; | 476 return; |
479 } | 477 } |
480 DCHECK(iter->second); | 478 DCHECK(iter->second); |
481 | 479 |
(...skipping 28 matching lines...) Expand all Loading... |
510 | 508 |
511 SyncCredentials credentials = GetCredentials(); | 509 SyncCredentials credentials = GetCredentials(); |
512 | 510 |
513 if (delete_stale_data) | 511 if (delete_stale_data) |
514 ClearStaleErrors(); | 512 ClearStaleErrors(); |
515 | 513 |
516 SyncBackendHost::HttpPostProviderFactoryGetter | 514 SyncBackendHost::HttpPostProviderFactoryGetter |
517 http_post_provider_factory_getter = | 515 http_post_provider_factory_getter = |
518 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory, | 516 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory, |
519 base::Unretained(network_resources_.get()), | 517 base::Unretained(network_resources_.get()), |
520 url_request_context_, | 518 url_request_context_, network_time_update_callback_); |
521 network_time_update_callback_); | |
522 | 519 |
523 backend_->Initialize( | 520 backend_->Initialize( |
524 this, std::move(sync_thread_), db_thread_, file_thread_, | 521 this, std::move(sync_thread_), db_thread_, file_thread_, |
525 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), | 522 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), |
526 credentials, delete_stale_data, | 523 credentials, delete_stale_data, |
527 std::unique_ptr<syncer::SyncManagerFactory>( | 524 std::unique_ptr<syncer::SyncManagerFactory>( |
528 new syncer::SyncManagerFactory()), | 525 new syncer::SyncManagerFactory()), |
529 MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()), | 526 MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()), |
530 base::Bind(browser_sync::ChromeReportUnrecoverableError, channel_), | 527 base::Bind(browser_sync::ChromeReportUnrecoverableError, channel_), |
531 http_post_provider_factory_getter, std::move(saved_nigori_state_)); | 528 http_post_provider_factory_getter, std::move(saved_nigori_state_)); |
532 } | 529 } |
533 | 530 |
534 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 531 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
535 if (encryption_pending()) | 532 if (encryption_pending()) |
536 return true; | 533 return true; |
537 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); | 534 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); |
538 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); | 535 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); |
539 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); | 536 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); |
540 return !Intersection(preferred_types, encrypted_types).Empty(); | 537 return !Intersection(preferred_types, encrypted_types).Empty(); |
541 } | 538 } |
542 | 539 |
543 void ProfileSyncService::OnProtocolEvent( | 540 void ProfileSyncService::OnProtocolEvent(const syncer::ProtocolEvent& event) { |
544 const syncer::ProtocolEvent& event) { | |
545 FOR_EACH_OBSERVER(browser_sync::ProtocolEventObserver, | 541 FOR_EACH_OBSERVER(browser_sync::ProtocolEventObserver, |
546 protocol_event_observers_, | 542 protocol_event_observers_, OnProtocolEvent(event)); |
547 OnProtocolEvent(event)); | |
548 } | 543 } |
549 | 544 |
550 void ProfileSyncService::OnDirectoryTypeCommitCounterUpdated( | 545 void ProfileSyncService::OnDirectoryTypeCommitCounterUpdated( |
551 syncer::ModelType type, | 546 syncer::ModelType type, |
552 const syncer::CommitCounters& counters) { | 547 const syncer::CommitCounters& counters) { |
553 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, | 548 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
554 type_debug_info_observers_, | |
555 OnCommitCountersUpdated(type, counters)); | 549 OnCommitCountersUpdated(type, counters)); |
556 } | 550 } |
557 | 551 |
558 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( | 552 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( |
559 syncer::ModelType type, | 553 syncer::ModelType type, |
560 const syncer::UpdateCounters& counters) { | 554 const syncer::UpdateCounters& counters) { |
561 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, | 555 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
562 type_debug_info_observers_, | |
563 OnUpdateCountersUpdated(type, counters)); | 556 OnUpdateCountersUpdated(type, counters)); |
564 } | 557 } |
565 | 558 |
566 void ProfileSyncService::OnDirectoryTypeStatusCounterUpdated( | 559 void ProfileSyncService::OnDirectoryTypeStatusCounterUpdated( |
567 syncer::ModelType type, | 560 syncer::ModelType type, |
568 const syncer::StatusCounters& counters) { | 561 const syncer::StatusCounters& counters) { |
569 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, | 562 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
570 type_debug_info_observers_, | |
571 OnStatusCountersUpdated(type, counters)); | 563 OnStatusCountersUpdated(type, counters)); |
572 } | 564 } |
573 | 565 |
574 void ProfileSyncService::OnDataTypeRequestsSyncStartup( | 566 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) { |
575 syncer::ModelType type) { | |
576 DCHECK(syncer::UserTypes().Has(type)); | 567 DCHECK(syncer::UserTypes().Has(type)); |
577 | 568 |
578 if (!GetPreferredDataTypes().Has(type)) { | 569 if (!GetPreferredDataTypes().Has(type)) { |
579 // We can get here as datatype SyncableServices are typically wired up | 570 // We can get here as datatype SyncableServices are typically wired up |
580 // to the native datatype even if sync isn't enabled. | 571 // to the native datatype even if sync isn't enabled. |
581 DVLOG(1) << "Dropping sync startup request because type " | 572 DVLOG(1) << "Dropping sync startup request because type " |
582 << syncer::ModelTypeToString(type) << "not enabled."; | 573 << syncer::ModelTypeToString(type) << "not enabled."; |
583 return; | 574 return; |
584 } | 575 } |
585 | 576 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 DCHECK_NE(error.state(), GoogleServiceAuthError::NONE); | 639 DCHECK_NE(error.state(), GoogleServiceAuthError::NONE); |
649 access_token_request_.reset(); | 640 access_token_request_.reset(); |
650 last_get_token_error_ = error; | 641 last_get_token_error_ = error; |
651 switch (error.state()) { | 642 switch (error.state()) { |
652 case GoogleServiceAuthError::CONNECTION_FAILED: | 643 case GoogleServiceAuthError::CONNECTION_FAILED: |
653 case GoogleServiceAuthError::REQUEST_CANCELED: | 644 case GoogleServiceAuthError::REQUEST_CANCELED: |
654 case GoogleServiceAuthError::SERVICE_ERROR: | 645 case GoogleServiceAuthError::SERVICE_ERROR: |
655 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: { | 646 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: { |
656 // Transient error. Retry after some time. | 647 // Transient error. Retry after some time. |
657 request_access_token_backoff_.InformOfRequest(false); | 648 request_access_token_backoff_.InformOfRequest(false); |
658 next_token_request_time_ = base::Time::Now() + | 649 next_token_request_time_ = |
| 650 base::Time::Now() + |
659 request_access_token_backoff_.GetTimeUntilRelease(); | 651 request_access_token_backoff_.GetTimeUntilRelease(); |
660 request_access_token_retry_timer_.Start( | 652 request_access_token_retry_timer_.Start( |
661 FROM_HERE, request_access_token_backoff_.GetTimeUntilRelease(), | 653 FROM_HERE, request_access_token_backoff_.GetTimeUntilRelease(), |
662 base::Bind(&ProfileSyncService::RequestAccessToken, | 654 base::Bind(&ProfileSyncService::RequestAccessToken, |
663 sync_enabled_weak_factory_.GetWeakPtr())); | 655 sync_enabled_weak_factory_.GetWeakPtr())); |
664 NotifyObservers(); | 656 NotifyObservers(); |
665 break; | 657 break; |
666 } | 658 } |
667 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: { | 659 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: { |
668 if (!sync_prefs_.SyncHasAuthError()) { | 660 if (!sync_prefs_.SyncHasAuthError()) { |
669 sync_prefs_.SetSyncAuthError(true); | 661 sync_prefs_.SetSyncAuthError(true); |
670 UMA_HISTOGRAM_ENUMERATION("Sync.SyncAuthError", | 662 UMA_HISTOGRAM_ENUMERATION("Sync.SyncAuthError", AUTH_ERROR_ENCOUNTERED, |
671 AUTH_ERROR_ENCOUNTERED, | |
672 AUTH_ERROR_LIMIT); | 663 AUTH_ERROR_LIMIT); |
673 } | 664 } |
674 // Fallthrough. | 665 // Fallthrough. |
675 } | 666 } |
676 default: { | 667 default: { |
677 if (error.state() != GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) { | 668 if (error.state() != GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) { |
678 LOG(ERROR) << "Unexpected persistent error: " << error.ToString(); | 669 LOG(ERROR) << "Unexpected persistent error: " << error.ToString(); |
679 } | 670 } |
680 // Show error to user. | 671 // Show error to user. |
681 UpdateAuthErrorState(error); | 672 UpdateAuthErrorState(error); |
682 } | 673 } |
683 } | 674 } |
684 } | 675 } |
685 | 676 |
686 void ProfileSyncService::OnRefreshTokenAvailable( | 677 void ProfileSyncService::OnRefreshTokenAvailable( |
687 const std::string& account_id) { | 678 const std::string& account_id) { |
688 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 679 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
689 // fixed. | 680 // fixed. |
690 tracked_objects::ScopedTracker tracking_profile( | 681 tracked_objects::ScopedTracker tracking_profile( |
691 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 682 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
692 "422460 ProfileSyncService::OnRefreshTokenAvailable")); | 683 "422460 ProfileSyncService::OnRefreshTokenAvailable")); |
693 | 684 |
694 if (account_id == signin_->GetAccountIdToUse()) | 685 if (account_id == signin_->GetAccountIdToUse()) |
695 OnRefreshTokensLoaded(); | 686 OnRefreshTokensLoaded(); |
696 } | 687 } |
697 | 688 |
698 void ProfileSyncService::OnRefreshTokenRevoked( | 689 void ProfileSyncService::OnRefreshTokenRevoked(const std::string& account_id) { |
699 const std::string& account_id) { | |
700 if (account_id == signin_->GetAccountIdToUse()) { | 690 if (account_id == signin_->GetAccountIdToUse()) { |
701 access_token_.clear(); | 691 access_token_.clear(); |
702 UpdateAuthErrorState( | 692 UpdateAuthErrorState( |
703 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); | 693 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); |
704 } | 694 } |
705 } | 695 } |
706 | 696 |
707 void ProfileSyncService::OnRefreshTokensLoaded() { | 697 void ProfileSyncService::OnRefreshTokensLoaded() { |
708 // This notification gets fired when OAuth2TokenService loads the tokens | 698 // This notification gets fired when OAuth2TokenService loads the tokens |
709 // from storage. | 699 // from storage. |
(...skipping 25 matching lines...) Expand all Loading... |
735 if (!backend_) { | 725 if (!backend_) { |
736 if (reason == syncer::ShutdownReason::DISABLE_SYNC && sync_thread_) { | 726 if (reason == syncer::ShutdownReason::DISABLE_SYNC && sync_thread_) { |
737 // If the backend is already shut down when a DISABLE_SYNC happens, | 727 // If the backend is already shut down when a DISABLE_SYNC happens, |
738 // the data directory needs to be cleaned up here. | 728 // the data directory needs to be cleaned up here. |
739 sync_thread_->task_runner()->PostTask( | 729 sync_thread_->task_runner()->PostTask( |
740 FROM_HERE, base::Bind(&DeleteSyncDataFolder, directory_path_)); | 730 FROM_HERE, base::Bind(&DeleteSyncDataFolder, directory_path_)); |
741 } | 731 } |
742 return; | 732 return; |
743 } | 733 } |
744 | 734 |
745 if (reason == syncer::ShutdownReason::STOP_SYNC | 735 if (reason == syncer::ShutdownReason::STOP_SYNC || |
746 || reason == syncer::ShutdownReason::DISABLE_SYNC) { | 736 reason == syncer::ShutdownReason::DISABLE_SYNC) { |
747 RemoveClientFromServer(); | 737 RemoveClientFromServer(); |
748 } | 738 } |
749 | 739 |
750 // First, we spin down the backend to stop change processing as soon as | 740 // First, we spin down the backend to stop change processing as soon as |
751 // possible. | 741 // possible. |
752 base::Time shutdown_start_time = base::Time::Now(); | 742 base::Time shutdown_start_time = base::Time::Now(); |
753 backend_->StopSyncingForShutdown(); | 743 backend_->StopSyncingForShutdown(); |
754 | 744 |
755 // Stop all data type controllers, if needed. Note that until Stop | 745 // Stop all data type controllers, if needed. Note that until Stop |
756 // completes, it is possible in theory to have a ChangeProcessor apply a | 746 // completes, it is possible in theory to have a ChangeProcessor apply a |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 881 |
892 void ProfileSyncService::OnUnrecoverableErrorImpl( | 882 void ProfileSyncService::OnUnrecoverableErrorImpl( |
893 const tracked_objects::Location& from_here, | 883 const tracked_objects::Location& from_here, |
894 const std::string& message, | 884 const std::string& message, |
895 bool delete_sync_database) { | 885 bool delete_sync_database) { |
896 DCHECK(HasUnrecoverableError()); | 886 DCHECK(HasUnrecoverableError()); |
897 unrecoverable_error_message_ = message; | 887 unrecoverable_error_message_ = message; |
898 unrecoverable_error_location_ = from_here; | 888 unrecoverable_error_location_ = from_here; |
899 | 889 |
900 UMA_HISTOGRAM_ENUMERATION(kSyncUnrecoverableErrorHistogram, | 890 UMA_HISTOGRAM_ENUMERATION(kSyncUnrecoverableErrorHistogram, |
901 unrecoverable_error_reason_, | 891 unrecoverable_error_reason_, ERROR_REASON_LIMIT); |
902 ERROR_REASON_LIMIT); | |
903 std::string location; | 892 std::string location; |
904 from_here.Write(true, true, &location); | 893 from_here.Write(true, true, &location); |
905 LOG(ERROR) | 894 LOG(ERROR) << "Unrecoverable error detected at " << location |
906 << "Unrecoverable error detected at " << location | 895 << " -- ProfileSyncService unusable: " << message; |
907 << " -- ProfileSyncService unusable: " << message; | |
908 | 896 |
909 // Shut all data types down. | 897 // Shut all data types down. |
910 base::ThreadTaskRunnerHandle::Get()->PostTask( | 898 base::ThreadTaskRunnerHandle::Get()->PostTask( |
911 FROM_HERE, base::Bind(&ProfileSyncService::ShutdownImpl, | 899 FROM_HERE, base::Bind(&ProfileSyncService::ShutdownImpl, |
912 sync_enabled_weak_factory_.GetWeakPtr(), | 900 sync_enabled_weak_factory_.GetWeakPtr(), |
913 delete_sync_database ? syncer::DISABLE_SYNC | 901 delete_sync_database ? syncer::DISABLE_SYNC |
914 : syncer::STOP_SYNC)); | 902 : syncer::STOP_SYNC)); |
915 } | 903 } |
916 | 904 |
917 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { | 905 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { |
918 if (!backend_initialized_ || !data_type_manager_) | 906 if (!backend_initialized_ || !data_type_manager_) |
919 return; | 907 return; |
920 data_type_manager_->ReenableType(type); | 908 data_type_manager_->ReenableType(type); |
921 } | 909 } |
922 | 910 |
923 void ProfileSyncService::UpdateBackendInitUMA(bool success) { | 911 void ProfileSyncService::UpdateBackendInitUMA(bool success) { |
924 is_first_time_sync_configure_ = !IsFirstSetupComplete(); | 912 is_first_time_sync_configure_ = !IsFirstSetupComplete(); |
925 | 913 |
926 if (is_first_time_sync_configure_) { | 914 if (is_first_time_sync_configure_) { |
927 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); | 915 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); |
928 } else { | 916 } else { |
929 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); | 917 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); |
930 } | 918 } |
931 | 919 |
932 base::Time on_backend_initialized_time = base::Time::Now(); | 920 base::Time on_backend_initialized_time = base::Time::Now(); |
933 base::TimeDelta delta = on_backend_initialized_time - | 921 base::TimeDelta delta = |
934 startup_controller_->start_backend_time(); | 922 on_backend_initialized_time - startup_controller_->start_backend_time(); |
935 if (is_first_time_sync_configure_) { | 923 if (is_first_time_sync_configure_) { |
936 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeFirstTime", delta); | 924 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeFirstTime", delta); |
937 } else { | 925 } else { |
938 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeRestoreTime", delta); | 926 UMA_HISTOGRAM_LONG_TIMES("Sync.BackendInitializeRestoreTime", delta); |
939 } | 927 } |
940 } | 928 } |
941 | 929 |
942 void ProfileSyncService::PostBackendInitialization() { | 930 void ProfileSyncService::PostBackendInitialization() { |
943 if (protocol_event_observers_.might_have_observers()) { | 931 if (protocol_event_observers_.might_have_observers()) { |
944 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); | 932 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 // Keep the directory around for now so that on restart we will retry | 983 // Keep the directory around for now so that on restart we will retry |
996 // again and potentially succeed in presence of transient file IO failures | 984 // again and potentially succeed in presence of transient file IO failures |
997 // or permissions issues, etc. | 985 // or permissions issues, etc. |
998 // | 986 // |
999 // TODO(rlarocque): Consider making this UnrecoverableError less special. | 987 // TODO(rlarocque): Consider making this UnrecoverableError less special. |
1000 // Unlike every other UnrecoverableError, it does not delete our sync data. | 988 // Unlike every other UnrecoverableError, it does not delete our sync data. |
1001 // This exception made sense at the time it was implemented, but our new | 989 // This exception made sense at the time it was implemented, but our new |
1002 // directory corruption recovery mechanism makes it obsolete. By the time | 990 // directory corruption recovery mechanism makes it obsolete. By the time |
1003 // we get here, we will have already tried and failed to delete the | 991 // we get here, we will have already tried and failed to delete the |
1004 // directory. It would be no big deal if we tried to delete it again. | 992 // directory. It would be no big deal if we tried to delete it again. |
1005 OnInternalUnrecoverableError(FROM_HERE, | 993 OnInternalUnrecoverableError(FROM_HERE, "BackendInitialize failure", false, |
1006 "BackendInitialize failure", | |
1007 false, | |
1008 ERROR_REASON_BACKEND_INIT_FAILURE); | 994 ERROR_REASON_BACKEND_INIT_FAILURE); |
1009 return; | 995 return; |
1010 } | 996 } |
1011 | 997 |
1012 backend_initialized_ = true; | 998 backend_initialized_ = true; |
1013 | 999 |
1014 sync_js_controller_.AttachJsBackend(js_backend); | 1000 sync_js_controller_.AttachJsBackend(js_backend); |
1015 debug_info_listener_ = debug_info_listener; | 1001 debug_info_listener_ = debug_info_listener; |
1016 | 1002 |
1017 SigninClient* signin_client = signin_->GetOriginal()->signin_client(); | 1003 SigninClient* signin_client = signin_->GetOriginal()->signin_client(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1043 |
1058 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { | 1044 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { |
1059 is_auth_in_progress_ = false; | 1045 is_auth_in_progress_ = false; |
1060 last_auth_error_ = error; | 1046 last_auth_error_ = error; |
1061 | 1047 |
1062 NotifyObservers(); | 1048 NotifyObservers(); |
1063 } | 1049 } |
1064 | 1050 |
1065 namespace { | 1051 namespace { |
1066 | 1052 |
1067 AuthError ConnectionStatusToAuthError( | 1053 AuthError ConnectionStatusToAuthError(syncer::ConnectionStatus status) { |
1068 syncer::ConnectionStatus status) { | |
1069 switch (status) { | 1054 switch (status) { |
1070 case syncer::CONNECTION_OK: | 1055 case syncer::CONNECTION_OK: |
1071 return AuthError::AuthErrorNone(); | 1056 return AuthError::AuthErrorNone(); |
1072 break; | 1057 break; |
1073 case syncer::CONNECTION_AUTH_ERROR: | 1058 case syncer::CONNECTION_AUTH_ERROR: |
1074 return AuthError(AuthError::INVALID_GAIA_CREDENTIALS); | 1059 return AuthError(AuthError::INVALID_GAIA_CREDENTIALS); |
1075 break; | 1060 break; |
1076 case syncer::CONNECTION_SERVER_ERROR: | 1061 case syncer::CONNECTION_SERVER_ERROR: |
1077 return AuthError(AuthError::CONNECTION_FAILED); | 1062 return AuthError(AuthError::CONNECTION_FAILED); |
1078 break; | 1063 break; |
(...skipping 30 matching lines...) Expand all Loading... |
1109 // schedule request if this happens. | 1094 // schedule request if this happens. |
1110 if (request_access_token_retry_timer_.IsRunning()) { | 1095 if (request_access_token_retry_timer_.IsRunning()) { |
1111 // The timer to perform a request later is already running; nothing | 1096 // The timer to perform a request later is already running; nothing |
1112 // further needs to be done at this point. | 1097 // further needs to be done at this point. |
1113 } else if (request_access_token_backoff_.failure_count() == 0) { | 1098 } else if (request_access_token_backoff_.failure_count() == 0) { |
1114 // First time request without delay. Currently invalid token is used | 1099 // First time request without delay. Currently invalid token is used |
1115 // to initialize sync backend and we'll always end up here. We don't | 1100 // to initialize sync backend and we'll always end up here. We don't |
1116 // want to delay initialization. | 1101 // want to delay initialization. |
1117 request_access_token_backoff_.InformOfRequest(false); | 1102 request_access_token_backoff_.InformOfRequest(false); |
1118 RequestAccessToken(); | 1103 RequestAccessToken(); |
1119 } else { | 1104 } else { |
1120 request_access_token_backoff_.InformOfRequest(false); | 1105 request_access_token_backoff_.InformOfRequest(false); |
1121 request_access_token_retry_timer_.Start( | 1106 request_access_token_retry_timer_.Start( |
1122 FROM_HERE, request_access_token_backoff_.GetTimeUntilRelease(), | 1107 FROM_HERE, request_access_token_backoff_.GetTimeUntilRelease(), |
1123 base::Bind(&ProfileSyncService::RequestAccessToken, | 1108 base::Bind(&ProfileSyncService::RequestAccessToken, |
1124 sync_enabled_weak_factory_.GetWeakPtr())); | 1109 sync_enabled_weak_factory_.GetWeakPtr())); |
1125 } | 1110 } |
1126 } else { | 1111 } else { |
1127 // Reset backoff time after successful connection. | 1112 // Reset backoff time after successful connection. |
1128 if (status == syncer::CONNECTION_OK) { | 1113 if (status == syncer::CONNECTION_OK) { |
1129 // Request shouldn't be scheduled at this time. But if it is, it's | 1114 // Request shouldn't be scheduled at this time. But if it is, it's |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 void ProfileSyncService::OnEncryptionComplete() { | 1200 void ProfileSyncService::OnEncryptionComplete() { |
1216 DVLOG(1) << "Encryption complete"; | 1201 DVLOG(1) << "Encryption complete"; |
1217 if (encryption_pending_ && encrypt_everything_) { | 1202 if (encryption_pending_ && encrypt_everything_) { |
1218 encryption_pending_ = false; | 1203 encryption_pending_ = false; |
1219 // This is to nudge the integration tests when encryption is | 1204 // This is to nudge the integration tests when encryption is |
1220 // finished. | 1205 // finished. |
1221 NotifyObservers(); | 1206 NotifyObservers(); |
1222 } | 1207 } |
1223 } | 1208 } |
1224 | 1209 |
1225 void ProfileSyncService::OnMigrationNeededForTypes( | 1210 void ProfileSyncService::OnMigrationNeededForTypes(syncer::ModelTypeSet types) { |
1226 syncer::ModelTypeSet types) { | |
1227 DCHECK(backend_initialized_); | 1211 DCHECK(backend_initialized_); |
1228 DCHECK(data_type_manager_.get()); | 1212 DCHECK(data_type_manager_.get()); |
1229 | 1213 |
1230 // Migrator must be valid, because we don't sync until it is created and this | 1214 // Migrator must be valid, because we don't sync until it is created and this |
1231 // callback originates from a sync cycle. | 1215 // callback originates from a sync cycle. |
1232 migrator_->MigrateTypes(types); | 1216 migrator_->MigrateTypes(types); |
1233 } | 1217 } |
1234 | 1218 |
1235 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { | 1219 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { |
1236 last_actionable_error_ = error; | 1220 last_actionable_error_ = error; |
1237 DCHECK_NE(last_actionable_error_.action, | 1221 DCHECK_NE(last_actionable_error_.action, syncer::UNKNOWN_ACTION); |
1238 syncer::UNKNOWN_ACTION); | |
1239 switch (error.action) { | 1222 switch (error.action) { |
1240 case syncer::UPGRADE_CLIENT: | 1223 case syncer::UPGRADE_CLIENT: |
1241 case syncer::CLEAR_USER_DATA_AND_RESYNC: | 1224 case syncer::CLEAR_USER_DATA_AND_RESYNC: |
1242 case syncer::ENABLE_SYNC_ON_ACCOUNT: | 1225 case syncer::ENABLE_SYNC_ON_ACCOUNT: |
1243 case syncer::STOP_AND_RESTART_SYNC: | 1226 case syncer::STOP_AND_RESTART_SYNC: |
1244 // TODO(lipalani) : if setup in progress we want to display these | 1227 // TODO(lipalani) : if setup in progress we want to display these |
1245 // actions in the popup. The current experience might not be optimal for | 1228 // actions in the popup. The current experience might not be optimal for |
1246 // the user. We just dismiss the dialog. | 1229 // the user. We just dismiss the dialog. |
1247 if (startup_controller_->IsSetupInProgress()) { | 1230 if (startup_controller_->IsSetupInProgress()) { |
1248 RequestStop(CLEAR_DATA); | 1231 RequestStop(CLEAR_DATA); |
1249 expect_sync_configuration_aborted_ = true; | 1232 expect_sync_configuration_aborted_ = true; |
1250 } | 1233 } |
1251 // Trigger an unrecoverable error to stop syncing. | 1234 // Trigger an unrecoverable error to stop syncing. |
1252 OnInternalUnrecoverableError(FROM_HERE, | 1235 OnInternalUnrecoverableError(FROM_HERE, |
1253 last_actionable_error_.error_description, | 1236 last_actionable_error_.error_description, |
1254 true, | 1237 true, ERROR_REASON_ACTIONABLE_ERROR); |
1255 ERROR_REASON_ACTIONABLE_ERROR); | |
1256 break; | 1238 break; |
1257 case syncer::DISABLE_SYNC_ON_CLIENT: | 1239 case syncer::DISABLE_SYNC_ON_CLIENT: |
1258 if (error.error_type == syncer::NOT_MY_BIRTHDAY) { | 1240 if (error.error_type == syncer::NOT_MY_BIRTHDAY) { |
1259 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::BIRTHDAY_ERROR, | 1241 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::BIRTHDAY_ERROR, |
1260 syncer::STOP_SOURCE_LIMIT); | 1242 syncer::STOP_SOURCE_LIMIT); |
1261 } | 1243 } |
1262 RequestStop(CLEAR_DATA); | 1244 RequestStop(CLEAR_DATA); |
1263 #if !defined(OS_CHROMEOS) | 1245 #if !defined(OS_CHROMEOS) |
1264 // On every platform except ChromeOS, sign out the user after a dashboard | 1246 // On every platform except ChromeOS, sign out the user after a dashboard |
1265 // clear. | 1247 // clear. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 configure_status_ = result.status; | 1318 configure_status_ = result.status; |
1337 data_type_status_table_ = result.data_type_status_table; | 1319 data_type_status_table_ = result.data_type_status_table; |
1338 | 1320 |
1339 // We should have cleared our cached passphrase before we get here (in | 1321 // We should have cleared our cached passphrase before we get here (in |
1340 // OnBackendInitialized()). | 1322 // OnBackendInitialized()). |
1341 DCHECK(cached_passphrase_.empty()); | 1323 DCHECK(cached_passphrase_.empty()); |
1342 | 1324 |
1343 if (!sync_configure_start_time_.is_null()) { | 1325 if (!sync_configure_start_time_.is_null()) { |
1344 if (result.status == DataTypeManager::OK) { | 1326 if (result.status == DataTypeManager::OK) { |
1345 base::Time sync_configure_stop_time = base::Time::Now(); | 1327 base::Time sync_configure_stop_time = base::Time::Now(); |
1346 base::TimeDelta delta = sync_configure_stop_time - | 1328 base::TimeDelta delta = |
1347 sync_configure_start_time_; | 1329 sync_configure_stop_time - sync_configure_start_time_; |
1348 if (is_first_time_sync_configure_) { | 1330 if (is_first_time_sync_configure_) { |
1349 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); | 1331 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); |
1350 } else { | 1332 } else { |
1351 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", | 1333 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta); |
1352 delta); | |
1353 } | 1334 } |
1354 } | 1335 } |
1355 sync_configure_start_time_ = base::Time(); | 1336 sync_configure_start_time_ = base::Time(); |
1356 } | 1337 } |
1357 | 1338 |
1358 // Notify listeners that configuration is done. | 1339 // Notify listeners that configuration is done. |
1359 FOR_EACH_OBSERVER(sync_driver::SyncServiceObserver, observers_, | 1340 FOR_EACH_OBSERVER(sync_driver::SyncServiceObserver, observers_, |
1360 OnSyncConfigurationCompleted()); | 1341 OnSyncConfigurationCompleted()); |
1361 | 1342 |
1362 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; | 1343 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; |
1363 // The possible status values: | 1344 // The possible status values: |
1364 // ABORT - Configuration was aborted. This is not an error, if | 1345 // ABORT - Configuration was aborted. This is not an error, if |
1365 // initiated by user. | 1346 // initiated by user. |
1366 // OK - Some or all types succeeded. | 1347 // OK - Some or all types succeeded. |
1367 // Everything else is an UnrecoverableError. So treat it as such. | 1348 // Everything else is an UnrecoverableError. So treat it as such. |
1368 | 1349 |
1369 // First handle the abort case. | 1350 // First handle the abort case. |
1370 if (configure_status_ == DataTypeManager::ABORTED && | 1351 if (configure_status_ == DataTypeManager::ABORTED && |
1371 expect_sync_configuration_aborted_) { | 1352 expect_sync_configuration_aborted_) { |
1372 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; | 1353 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; |
1373 expect_sync_configuration_aborted_ = false; | 1354 expect_sync_configuration_aborted_ = false; |
1374 return; | 1355 return; |
1375 } | 1356 } |
1376 | 1357 |
1377 // Handle unrecoverable error. | 1358 // Handle unrecoverable error. |
1378 if (configure_status_ != DataTypeManager::OK) { | 1359 if (configure_status_ != DataTypeManager::OK) { |
1379 // Something catastrophic had happened. We should only have one | 1360 // Something catastrophic had happened. We should only have one |
1380 // error representing it. | 1361 // error representing it. |
1381 syncer::SyncError error = | 1362 syncer::SyncError error = data_type_status_table_.GetUnrecoverableError(); |
1382 data_type_status_table_.GetUnrecoverableError(); | |
1383 DCHECK(error.IsSet()); | 1363 DCHECK(error.IsSet()); |
1384 std::string message = | 1364 std::string message = |
1385 "Sync configuration failed with status " + | 1365 "Sync configuration failed with status " + |
1386 DataTypeManager::ConfigureStatusToString(configure_status_) + | 1366 DataTypeManager::ConfigureStatusToString(configure_status_) + |
1387 " caused by " + | 1367 " caused by " + |
1388 syncer::ModelTypeSetToString( | 1368 syncer::ModelTypeSetToString( |
1389 data_type_status_table_.GetUnrecoverableErrorTypes()) + | 1369 data_type_status_table_.GetUnrecoverableErrorTypes()) + |
1390 ": " + error.message(); | 1370 ": " + error.message(); |
1391 LOG(ERROR) << "ProfileSyncService error: " << message; | 1371 LOG(ERROR) << "ProfileSyncService error: " << message; |
1392 OnInternalUnrecoverableError(error.location(), | 1372 OnInternalUnrecoverableError(error.location(), message, true, |
1393 message, | |
1394 true, | |
1395 ERROR_REASON_CONFIGURATION_FAILURE); | 1373 ERROR_REASON_CONFIGURATION_FAILURE); |
1396 return; | 1374 return; |
1397 } | 1375 } |
1398 | 1376 |
1399 DCHECK_EQ(DataTypeManager::OK, configure_status_); | 1377 DCHECK_EQ(DataTypeManager::OK, configure_status_); |
1400 | 1378 |
1401 // We should never get in a state where we have no encrypted datatypes | 1379 // We should never get in a state where we have no encrypted datatypes |
1402 // enabled, and yet we still think we require a passphrase for decryption. | 1380 // enabled, and yet we still think we require a passphrase for decryption. |
1403 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1381 DCHECK( |
1404 !IsEncryptedDatatypeEnabled())); | 1382 !(IsPassphraseRequiredForDecryption() && !IsEncryptedDatatypeEnabled())); |
1405 | 1383 |
1406 // This must be done before we start syncing with the server to avoid | 1384 // This must be done before we start syncing with the server to avoid |
1407 // sending unencrypted data up on a first time sync. | 1385 // sending unencrypted data up on a first time sync. |
1408 if (encryption_pending_) | 1386 if (encryption_pending_) |
1409 backend_->EnableEncryptEverything(); | 1387 backend_->EnableEncryptEverything(); |
1410 NotifyObservers(); | 1388 NotifyObservers(); |
1411 | 1389 |
1412 if (migrator_.get() && | 1390 if (migrator_.get() && |
1413 migrator_->state() != browser_sync::BackendMigrator::IDLE) { | 1391 migrator_->state() != browser_sync::BackendMigrator::IDLE) { |
1414 // Migration in progress. Let the migrator know we just finished | 1392 // Migration in progress. Let the migrator know we just finished |
(...skipping 11 matching lines...) Expand all Loading... |
1426 | 1404 |
1427 StartSyncingWithServer(); | 1405 StartSyncingWithServer(); |
1428 } | 1406 } |
1429 | 1407 |
1430 void ProfileSyncService::OnConfigureStart() { | 1408 void ProfileSyncService::OnConfigureStart() { |
1431 sync_configure_start_time_ = base::Time::Now(); | 1409 sync_configure_start_time_ = base::Time::Now(); |
1432 NotifyObservers(); | 1410 NotifyObservers(); |
1433 } | 1411 } |
1434 | 1412 |
1435 ProfileSyncService::SyncStatusSummary | 1413 ProfileSyncService::SyncStatusSummary |
1436 ProfileSyncService::QuerySyncStatusSummary() { | 1414 ProfileSyncService::QuerySyncStatusSummary() { |
1437 if (HasUnrecoverableError()) { | 1415 if (HasUnrecoverableError()) { |
1438 return UNRECOVERABLE_ERROR; | 1416 return UNRECOVERABLE_ERROR; |
1439 } else if (!backend_) { | 1417 } else if (!backend_) { |
1440 return NOT_ENABLED; | 1418 return NOT_ENABLED; |
1441 } else if (backend_.get() && !IsFirstSetupComplete()) { | 1419 } else if (backend_.get() && !IsFirstSetupComplete()) { |
1442 return SETUP_INCOMPLETE; | 1420 return SETUP_INCOMPLETE; |
1443 } else if (backend_ && IsFirstSetupComplete() && data_type_manager_ && | 1421 } else if (backend_ && IsFirstSetupComplete() && data_type_manager_ && |
1444 data_type_manager_->state() == DataTypeManager::STOPPED) { | 1422 data_type_manager_->state() == DataTypeManager::STOPPED) { |
1445 return DATATYPES_NOT_INITIALIZED; | 1423 return DATATYPES_NOT_INITIALIZED; |
1446 } else if (IsSyncActive()) { | 1424 } else if (IsSyncActive()) { |
1447 return INITIALIZED; | 1425 return INITIALIZED; |
1448 } | 1426 } |
1449 return UNKNOWN_ERROR; | 1427 return UNKNOWN_ERROR; |
1450 } | 1428 } |
1451 | 1429 |
1452 std::string ProfileSyncService::QuerySyncStatusSummaryString() { | 1430 std::string ProfileSyncService::QuerySyncStatusSummaryString() { |
1453 SyncStatusSummary status = QuerySyncStatusSummary(); | 1431 SyncStatusSummary status = QuerySyncStatusSummary(); |
1454 | 1432 |
1455 std::string config_status_str = | 1433 std::string config_status_str = |
1456 configure_status_ != DataTypeManager::UNKNOWN ? | 1434 configure_status_ != DataTypeManager::UNKNOWN |
1457 DataTypeManager::ConfigureStatusToString(configure_status_) : ""; | 1435 ? DataTypeManager::ConfigureStatusToString(configure_status_) |
| 1436 : ""; |
1458 | 1437 |
1459 switch (status) { | 1438 switch (status) { |
1460 case UNRECOVERABLE_ERROR: | 1439 case UNRECOVERABLE_ERROR: |
1461 return "Unrecoverable error detected"; | 1440 return "Unrecoverable error detected"; |
1462 case NOT_ENABLED: | 1441 case NOT_ENABLED: |
1463 return "Syncing not enabled"; | 1442 return "Syncing not enabled"; |
1464 case SETUP_INCOMPLETE: | 1443 case SETUP_INCOMPLETE: |
1465 return "First time sync setup incomplete"; | 1444 return "First time sync setup incomplete"; |
1466 case DATATYPES_NOT_INITIALIZED: | 1445 case DATATYPES_NOT_INITIALIZED: |
1467 return "Datatypes not fully initialized"; | 1446 return "Datatypes not fully initialized"; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 | 1539 |
1561 const syncer::Experiments& ProfileSyncService::current_experiments() const { | 1540 const syncer::Experiments& ProfileSyncService::current_experiments() const { |
1562 return current_experiments_; | 1541 return current_experiments_; |
1563 } | 1542 } |
1564 | 1543 |
1565 bool ProfileSyncService::HasUnrecoverableError() const { | 1544 bool ProfileSyncService::HasUnrecoverableError() const { |
1566 return unrecoverable_error_reason_ != ERROR_REASON_UNSET; | 1545 return unrecoverable_error_reason_ != ERROR_REASON_UNSET; |
1567 } | 1546 } |
1568 | 1547 |
1569 bool ProfileSyncService::IsPassphraseRequired() const { | 1548 bool ProfileSyncService::IsPassphraseRequired() const { |
1570 return passphrase_required_reason_ != | 1549 return passphrase_required_reason_ != syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
1571 syncer::REASON_PASSPHRASE_NOT_REQUIRED; | |
1572 } | 1550 } |
1573 | 1551 |
1574 bool ProfileSyncService::IsPassphraseRequiredForDecryption() const { | 1552 bool ProfileSyncService::IsPassphraseRequiredForDecryption() const { |
1575 // If there is an encrypted datatype enabled and we don't have the proper | 1553 // If there is an encrypted datatype enabled and we don't have the proper |
1576 // passphrase, we must prompt the user for a passphrase. The only way for the | 1554 // passphrase, we must prompt the user for a passphrase. The only way for the |
1577 // user to avoid entering their passphrase is to disable the encrypted types. | 1555 // user to avoid entering their passphrase is to disable the encrypted types. |
1578 return IsEncryptedDatatypeEnabled() && IsPassphraseRequired(); | 1556 return IsEncryptedDatatypeEnabled() && IsPassphraseRequired(); |
1579 } | 1557 } |
1580 | 1558 |
1581 base::string16 ProfileSyncService::GetLastSyncedTimeString() const { | 1559 base::string16 ProfileSyncService::GetLastSyncedTimeString() const { |
1582 const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime(); | 1560 const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime(); |
1583 if (last_synced_time.is_null()) | 1561 if (last_synced_time.is_null()) |
1584 return l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER); | 1562 return l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER); |
1585 | 1563 |
1586 base::TimeDelta time_since_last_sync = base::Time::Now() - last_synced_time; | 1564 base::TimeDelta time_since_last_sync = base::Time::Now() - last_synced_time; |
1587 | 1565 |
1588 if (time_since_last_sync < base::TimeDelta::FromMinutes(1)) | 1566 if (time_since_last_sync < base::TimeDelta::FromMinutes(1)) |
1589 return l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW); | 1567 return l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW); |
1590 | 1568 |
1591 return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, | 1569 return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, |
1592 ui::TimeFormat::LENGTH_SHORT, | 1570 ui::TimeFormat::LENGTH_SHORT, |
1593 time_since_last_sync); | 1571 time_since_last_sync); |
1594 } | 1572 } |
1595 | 1573 |
1596 void ProfileSyncService::UpdateSelectedTypesHistogram( | 1574 void ProfileSyncService::UpdateSelectedTypesHistogram( |
1597 bool sync_everything, const syncer::ModelTypeSet chosen_types) const { | 1575 bool sync_everything, |
| 1576 const syncer::ModelTypeSet chosen_types) const { |
1598 if (!IsFirstSetupComplete() || | 1577 if (!IsFirstSetupComplete() || |
1599 sync_everything != sync_prefs_.HasKeepEverythingSynced()) { | 1578 sync_everything != sync_prefs_.HasKeepEverythingSynced()) { |
1600 UMA_HISTOGRAM_BOOLEAN("Sync.SyncEverything", sync_everything); | 1579 UMA_HISTOGRAM_BOOLEAN("Sync.SyncEverything", sync_everything); |
1601 } | 1580 } |
1602 | 1581 |
1603 // Only log the data types that are shown in the sync settings ui. | 1582 // Only log the data types that are shown in the sync settings ui. |
1604 // Note: the order of these types must match the ordering of | 1583 // Note: the order of these types must match the ordering of |
1605 // the respective types in ModelType | 1584 // the respective types in ModelType |
1606 const sync_driver::user_selectable_type::UserSelectableSyncType | 1585 const sync_driver::user_selectable_type::UserSelectableSyncType |
1607 user_selectable_types[] = { | 1586 user_selectable_types[] = { |
1608 sync_driver::user_selectable_type::BOOKMARKS, | 1587 sync_driver::user_selectable_type::BOOKMARKS, |
1609 sync_driver::user_selectable_type::PREFERENCES, | 1588 sync_driver::user_selectable_type::PREFERENCES, |
1610 sync_driver::user_selectable_type::PASSWORDS, | 1589 sync_driver::user_selectable_type::PASSWORDS, |
1611 sync_driver::user_selectable_type::AUTOFILL, | 1590 sync_driver::user_selectable_type::AUTOFILL, |
1612 sync_driver::user_selectable_type::THEMES, | 1591 sync_driver::user_selectable_type::THEMES, |
1613 sync_driver::user_selectable_type::TYPED_URLS, | 1592 sync_driver::user_selectable_type::TYPED_URLS, |
1614 sync_driver::user_selectable_type::EXTENSIONS, | 1593 sync_driver::user_selectable_type::EXTENSIONS, |
1615 sync_driver::user_selectable_type::APPS, | 1594 sync_driver::user_selectable_type::APPS, |
1616 sync_driver::user_selectable_type::PROXY_TABS, | 1595 sync_driver::user_selectable_type::PROXY_TABS, |
1617 }; | 1596 }; |
1618 | 1597 |
1619 static_assert(38 == syncer::MODEL_TYPE_COUNT, | 1598 static_assert(38 == syncer::MODEL_TYPE_COUNT, |
1620 "custom config histogram must be updated"); | 1599 "custom config histogram must be updated"); |
1621 | 1600 |
1622 if (!sync_everything) { | 1601 if (!sync_everything) { |
1623 const syncer::ModelTypeSet current_types = GetPreferredDataTypes(); | 1602 const syncer::ModelTypeSet current_types = GetPreferredDataTypes(); |
1624 | 1603 |
1625 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes(); | 1604 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes(); |
1626 syncer::ModelTypeSet::Iterator it = type_set.First(); | 1605 syncer::ModelTypeSet::Iterator it = type_set.First(); |
1627 | 1606 |
1628 DCHECK_EQ(arraysize(user_selectable_types), type_set.Size()); | 1607 DCHECK_EQ(arraysize(user_selectable_types), type_set.Size()); |
1629 | 1608 |
1630 for (size_t i = 0; i < arraysize(user_selectable_types) && it.Good(); | 1609 for (size_t i = 0; i < arraysize(user_selectable_types) && it.Good(); |
1631 ++i, it.Inc()) { | 1610 ++i, it.Inc()) { |
1632 const syncer::ModelType type = it.Get(); | 1611 const syncer::ModelType type = it.Get(); |
1633 if (chosen_types.Has(type) && | 1612 if (chosen_types.Has(type) && |
1634 (!IsFirstSetupComplete() || !current_types.Has(type))) { | 1613 (!IsFirstSetupComplete() || !current_types.Has(type))) { |
1635 // Selected type has changed - log it. | 1614 // Selected type has changed - log it. |
1636 UMA_HISTOGRAM_ENUMERATION( | 1615 UMA_HISTOGRAM_ENUMERATION( |
1637 "Sync.CustomSync", | 1616 "Sync.CustomSync", user_selectable_types[i], |
1638 user_selectable_types[i], | |
1639 sync_driver::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); | 1617 sync_driver::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); |
1640 } | 1618 } |
1641 } | 1619 } |
1642 } | 1620 } |
1643 } | 1621 } |
1644 | 1622 |
1645 #if defined(OS_CHROMEOS) | 1623 #if defined(OS_CHROMEOS) |
1646 void ProfileSyncService::RefreshSpareBootstrapToken( | 1624 void ProfileSyncService::RefreshSpareBootstrapToken( |
1647 const std::string& passphrase) { | 1625 const std::string& passphrase) { |
1648 sync_driver::SystemEncryptor encryptor; | 1626 sync_driver::SystemEncryptor encryptor; |
(...skipping 23 matching lines...) Expand all Loading... |
1672 UpdateSelectedTypesHistogram(sync_everything, chosen_types); | 1650 UpdateSelectedTypesHistogram(sync_everything, chosen_types); |
1673 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1651 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
1674 | 1652 |
1675 if (data_type_manager_) | 1653 if (data_type_manager_) |
1676 data_type_manager_->ResetDataTypeErrors(); | 1654 data_type_manager_->ResetDataTypeErrors(); |
1677 ChangePreferredDataTypes(chosen_types); | 1655 ChangePreferredDataTypes(chosen_types); |
1678 } | 1656 } |
1679 | 1657 |
1680 void ProfileSyncService::ChangePreferredDataTypes( | 1658 void ProfileSyncService::ChangePreferredDataTypes( |
1681 syncer::ModelTypeSet preferred_types) { | 1659 syncer::ModelTypeSet preferred_types) { |
1682 | |
1683 DVLOG(1) << "ChangePreferredDataTypes invoked"; | 1660 DVLOG(1) << "ChangePreferredDataTypes invoked"; |
1684 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); | 1661 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); |
1685 // Will only enable those types that are registered and preferred. | 1662 // Will only enable those types that are registered and preferred. |
1686 sync_prefs_.SetPreferredDataTypes(registered_types, preferred_types); | 1663 sync_prefs_.SetPreferredDataTypes(registered_types, preferred_types); |
1687 | 1664 |
1688 // Now reconfigure the DTM. | 1665 // Now reconfigure the DTM. |
1689 ReconfigureDatatypeManager(); | 1666 ReconfigureDatatypeManager(); |
1690 } | 1667 } |
1691 | 1668 |
1692 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const { | 1669 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 } | 1801 } |
1825 | 1802 |
1826 bool ProfileSyncService::HasUnsyncedItems() const { | 1803 bool ProfileSyncService::HasUnsyncedItems() const { |
1827 if (HasSyncingBackend() && backend_initialized_) { | 1804 if (HasSyncingBackend() && backend_initialized_) { |
1828 return backend_->HasUnsyncedItems(); | 1805 return backend_->HasUnsyncedItems(); |
1829 } | 1806 } |
1830 NOTREACHED(); | 1807 NOTREACHED(); |
1831 return false; | 1808 return false; |
1832 } | 1809 } |
1833 | 1810 |
1834 browser_sync::BackendMigrator* | 1811 browser_sync::BackendMigrator* ProfileSyncService::GetBackendMigratorForTest() { |
1835 ProfileSyncService::GetBackendMigratorForTest() { | |
1836 return migrator_.get(); | 1812 return migrator_.get(); |
1837 } | 1813 } |
1838 | 1814 |
1839 void ProfileSyncService::GetModelSafeRoutingInfo( | 1815 void ProfileSyncService::GetModelSafeRoutingInfo( |
1840 syncer::ModelSafeRoutingInfo* out) const { | 1816 syncer::ModelSafeRoutingInfo* out) const { |
1841 if (backend_.get() && backend_initialized_) { | 1817 if (backend_.get() && backend_initialized_) { |
1842 backend_->GetModelSafeRoutingInfo(out); | 1818 backend_->GetModelSafeRoutingInfo(out); |
1843 } else { | 1819 } else { |
1844 NOTREACHED(); | 1820 NOTREACHED(); |
1845 } | 1821 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 result->Append(std::move(type_status_header)); | 1857 result->Append(std::move(type_status_header)); |
1882 | 1858 |
1883 std::unique_ptr<base::DictionaryValue> type_status; | 1859 std::unique_ptr<base::DictionaryValue> type_status; |
1884 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { | 1860 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { |
1885 ModelType type = it.Get(); | 1861 ModelType type = it.Get(); |
1886 | 1862 |
1887 type_status.reset(new base::DictionaryValue()); | 1863 type_status.reset(new base::DictionaryValue()); |
1888 type_status->SetString("name", ModelTypeToString(type)); | 1864 type_status->SetString("name", ModelTypeToString(type)); |
1889 | 1865 |
1890 if (error_map.find(type) != error_map.end()) { | 1866 if (error_map.find(type) != error_map.end()) { |
1891 const syncer::SyncError &error = error_map.find(type)->second; | 1867 const syncer::SyncError& error = error_map.find(type)->second; |
1892 DCHECK(error.IsSet()); | 1868 DCHECK(error.IsSet()); |
1893 switch (error.GetSeverity()) { | 1869 switch (error.GetSeverity()) { |
1894 case syncer::SyncError::SYNC_ERROR_SEVERITY_ERROR: { | 1870 case syncer::SyncError::SYNC_ERROR_SEVERITY_ERROR: |
1895 std::string error_text = "Error: " + error.location().ToString() + | 1871 type_status->SetString("status", "error"); |
1896 ", " + error.GetMessagePrefix() + error.message(); | 1872 type_status->SetString( |
1897 type_status->SetString("status", "error"); | 1873 "value", "Error: " + error.location().ToString() + ", " + |
1898 type_status->SetString("value", error_text); | 1874 error.GetMessagePrefix() + error.message()); |
1899 } | |
1900 break; | 1875 break; |
1901 case syncer::SyncError::SYNC_ERROR_SEVERITY_INFO: | 1876 case syncer::SyncError::SYNC_ERROR_SEVERITY_INFO: |
1902 type_status->SetString("status", "disabled"); | 1877 type_status->SetString("status", "disabled"); |
1903 type_status->SetString("value", error.message()); | 1878 type_status->SetString("value", error.message()); |
1904 break; | 1879 break; |
1905 default: | 1880 default: |
1906 NOTREACHED() << "Unexpected error severity."; | 1881 NOTREACHED() << "Unexpected error severity."; |
1907 break; | 1882 break; |
1908 } | 1883 } |
1909 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) { | 1884 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) { |
1910 // Show a proxy type in "ok" state unless it is disabled by user. | 1885 // Show a proxy type in "ok" state unless it is disabled by user. |
1911 DCHECK(!throttled_types.Has(type)); | 1886 DCHECK(!throttled_types.Has(type)); |
1912 type_status->SetString("status", "ok"); | 1887 type_status->SetString("status", "ok"); |
1913 type_status->SetString("value", "Passive"); | 1888 type_status->SetString("value", "Passive"); |
1914 } else if (throttled_types.Has(type) && passive_types.Has(type)) { | 1889 } else if (throttled_types.Has(type) && passive_types.Has(type)) { |
1915 type_status->SetString("status", "warning"); | 1890 type_status->SetString("status", "warning"); |
1916 type_status->SetString("value", "Passive, Throttled"); | 1891 type_status->SetString("value", "Passive, Throttled"); |
1917 } else if (passive_types.Has(type)) { | 1892 } else if (passive_types.Has(type)) { |
1918 type_status->SetString("status", "warning"); | 1893 type_status->SetString("status", "warning"); |
1919 type_status->SetString("value", "Passive"); | 1894 type_status->SetString("value", "Passive"); |
1920 } else if (throttled_types.Has(type)) { | 1895 } else if (throttled_types.Has(type)) { |
1921 type_status->SetString("status", "warning"); | 1896 type_status->SetString("status", "warning"); |
1922 type_status->SetString("value", "Throttled"); | 1897 type_status->SetString("value", "Throttled"); |
1923 } else if (active_types.Has(type)) { | 1898 } else if (active_types.Has(type)) { |
1924 type_status->SetString("status", "ok"); | 1899 type_status->SetString("status", "ok"); |
1925 type_status->SetString("value", "Active: " + | 1900 type_status->SetString( |
1926 ModelSafeGroupToString(routing_info[type])); | 1901 "value", "Active: " + ModelSafeGroupToString(routing_info[type])); |
1927 } else { | 1902 } else { |
1928 type_status->SetString("status", "warning"); | 1903 type_status->SetString("status", "warning"); |
1929 type_status->SetString("value", "Disabled by User"); | 1904 type_status->SetString("value", "Disabled by User"); |
1930 } | 1905 } |
1931 | 1906 |
1932 int live_count = detailed_status.num_entries_by_type[type] - | 1907 int live_count = detailed_status.num_entries_by_type[type] - |
1933 detailed_status.num_to_delete_entries_by_type[type]; | 1908 detailed_status.num_to_delete_entries_by_type[type]; |
1934 type_status->SetInteger("num_entries", | 1909 type_status->SetInteger("num_entries", |
1935 detailed_status.num_entries_by_type[type]); | 1910 detailed_status.num_entries_by_type[type]); |
1936 type_status->SetInteger("num_live", live_count); | 1911 type_status->SetInteger("num_live", live_count); |
1937 | 1912 |
1938 result->Append(std::move(type_status)); | 1913 result->Append(std::move(type_status)); |
1939 } | 1914 } |
1940 return result.release(); | 1915 return result.release(); |
1941 } | 1916 } |
1942 | 1917 |
1943 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { | 1918 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 token_receive_time_ = base::Time(); | 1963 token_receive_time_ = base::Time(); |
1989 next_token_request_time_ = base::Time(); | 1964 next_token_request_time_ = base::Time(); |
1990 access_token_request_ = | 1965 access_token_request_ = |
1991 oauth2_token_service_->StartRequest(account_id, oauth2_scopes, this); | 1966 oauth2_token_service_->StartRequest(account_id, oauth2_scopes, this); |
1992 } | 1967 } |
1993 | 1968 |
1994 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, | 1969 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, |
1995 PassphraseType type) { | 1970 PassphraseType type) { |
1996 // This should only be called when the backend has been initialized. | 1971 // This should only be called when the backend has been initialized. |
1997 DCHECK(IsBackendInitialized()); | 1972 DCHECK(IsBackendInitialized()); |
1998 DCHECK(!(type == IMPLICIT && IsUsingSecondaryPassphrase())) << | 1973 DCHECK(!(type == IMPLICIT && IsUsingSecondaryPassphrase())) |
1999 "Data is already encrypted using an explicit passphrase"; | 1974 << "Data is already encrypted using an explicit passphrase"; |
2000 DCHECK(!(type == EXPLICIT && | 1975 DCHECK(!(type == EXPLICIT && |
2001 passphrase_required_reason_ == syncer::REASON_DECRYPTION)) << | 1976 passphrase_required_reason_ == syncer::REASON_DECRYPTION)) |
2002 "Can not set explicit passphrase when decryption is needed."; | 1977 << "Can not set explicit passphrase when decryption is needed."; |
2003 | 1978 |
2004 DVLOG(1) << "Setting " << (type == EXPLICIT ? "explicit" : "implicit") | 1979 DVLOG(1) << "Setting " << (type == EXPLICIT ? "explicit" : "implicit") |
2005 << " passphrase for encryption."; | 1980 << " passphrase for encryption."; |
2006 if (passphrase_required_reason_ == syncer::REASON_ENCRYPTION) { | 1981 if (passphrase_required_reason_ == syncer::REASON_ENCRYPTION) { |
2007 // REASON_ENCRYPTION implies that the cryptographer does not have pending | 1982 // REASON_ENCRYPTION implies that the cryptographer does not have pending |
2008 // keys. Hence, as long as we're not trying to do an invalid passphrase | 1983 // keys. Hence, as long as we're not trying to do an invalid passphrase |
2009 // change (e.g. explicit -> explicit or explicit -> implicit), we know this | 1984 // change (e.g. explicit -> explicit or explicit -> implicit), we know this |
2010 // will succeed. If for some reason a new encryption key arrives via | 1985 // will succeed. If for some reason a new encryption key arrives via |
2011 // sync later, the SBH will trigger another OnPassphraseRequired(). | 1986 // sync later, the SBH will trigger another OnPassphraseRequired(). |
2012 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; | 1987 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " | 2332 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " |
2358 << "initialized"; | 2333 << "initialized"; |
2359 } | 2334 } |
2360 } | 2335 } |
2361 | 2336 |
2362 syncer::ModelTypeSet ProfileSyncService::GetDataTypesFromPreferenceProviders() | 2337 syncer::ModelTypeSet ProfileSyncService::GetDataTypesFromPreferenceProviders() |
2363 const { | 2338 const { |
2364 syncer::ModelTypeSet types; | 2339 syncer::ModelTypeSet types; |
2365 for (std::set<SyncTypePreferenceProvider*>::const_iterator it = | 2340 for (std::set<SyncTypePreferenceProvider*>::const_iterator it = |
2366 preference_providers_.begin(); | 2341 preference_providers_.begin(); |
2367 it != preference_providers_.end(); | 2342 it != preference_providers_.end(); ++it) { |
2368 ++it) { | |
2369 types.PutAll((*it)->GetPreferredDataTypes()); | 2343 types.PutAll((*it)->GetPreferredDataTypes()); |
2370 } | 2344 } |
2371 return types; | 2345 return types; |
2372 } | 2346 } |
2373 | 2347 |
2374 const DataTypeStatusTable& ProfileSyncService::data_type_status_table() | 2348 const DataTypeStatusTable& ProfileSyncService::data_type_status_table() const { |
2375 const { | |
2376 return data_type_status_table_; | 2349 return data_type_status_table_; |
2377 } | 2350 } |
2378 | 2351 |
2379 void ProfileSyncService::OnInternalUnrecoverableError( | 2352 void ProfileSyncService::OnInternalUnrecoverableError( |
2380 const tracked_objects::Location& from_here, | 2353 const tracked_objects::Location& from_here, |
2381 const std::string& message, | 2354 const std::string& message, |
2382 bool delete_sync_database, | 2355 bool delete_sync_database, |
2383 UnrecoverableErrorReason reason) { | 2356 UnrecoverableErrorReason reason) { |
2384 DCHECK(!HasUnrecoverableError()); | 2357 DCHECK(!HasUnrecoverableError()); |
2385 unrecoverable_error_reason_ = reason; | 2358 unrecoverable_error_reason_ = reason; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 return NULL; | 2434 return NULL; |
2462 } | 2435 } |
2463 } | 2436 } |
2464 | 2437 |
2465 void ProfileSyncService::RefreshTypesForTest(syncer::ModelTypeSet types) { | 2438 void ProfileSyncService::RefreshTypesForTest(syncer::ModelTypeSet types) { |
2466 if (backend_initialized_) | 2439 if (backend_initialized_) |
2467 backend_->RefreshTypesForTest(types); | 2440 backend_->RefreshTypesForTest(types); |
2468 } | 2441 } |
2469 | 2442 |
2470 void ProfileSyncService::RemoveClientFromServer() const { | 2443 void ProfileSyncService::RemoveClientFromServer() const { |
2471 if (!backend_initialized_) return; | 2444 if (!backend_initialized_) |
| 2445 return; |
2472 const std::string cache_guid = local_device_->GetLocalSyncCacheGUID(); | 2446 const std::string cache_guid = local_device_->GetLocalSyncCacheGUID(); |
2473 std::string birthday; | 2447 std::string birthday; |
2474 syncer::UserShare* user_share = GetUserShare(); | 2448 syncer::UserShare* user_share = GetUserShare(); |
2475 if (user_share && user_share->directory.get()) { | 2449 if (user_share && user_share->directory.get()) { |
2476 birthday = user_share->directory->store_birthday(); | 2450 birthday = user_share->directory->store_birthday(); |
2477 } | 2451 } |
2478 if (!access_token_.empty() && !cache_guid.empty() && !birthday.empty()) { | 2452 if (!access_token_.empty() && !cache_guid.empty() && !birthday.empty()) { |
2479 sync_stopped_reporter_->ReportSyncStopped( | 2453 sync_stopped_reporter_->ReportSyncStopped(access_token_, cache_guid, |
2480 access_token_, cache_guid, birthday); | 2454 birthday); |
2481 } | 2455 } |
2482 } | 2456 } |
2483 | 2457 |
2484 void ProfileSyncService::OnMemoryPressure( | 2458 void ProfileSyncService::OnMemoryPressure( |
2485 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { | 2459 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { |
2486 if (memory_pressure_level == | 2460 if (memory_pressure_level == |
2487 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | 2461 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { |
2488 sync_prefs_.SetMemoryPressureWarningCount( | 2462 sync_prefs_.SetMemoryPressureWarningCount( |
2489 sync_prefs_.GetMemoryPressureWarningCount() + 1); | 2463 sync_prefs_.GetMemoryPressureWarningCount() + 1); |
2490 } | 2464 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2529 if (--outstanding_setup_in_progress_handles_ != 0) | 2503 if (--outstanding_setup_in_progress_handles_ != 0) |
2530 return; | 2504 return; |
2531 | 2505 |
2532 DCHECK(startup_controller_->IsSetupInProgress()); | 2506 DCHECK(startup_controller_->IsSetupInProgress()); |
2533 startup_controller_->SetSetupInProgress(false); | 2507 startup_controller_->SetSetupInProgress(false); |
2534 | 2508 |
2535 if (IsBackendInitialized()) | 2509 if (IsBackendInitialized()) |
2536 ReconfigureDatatypeManager(); | 2510 ReconfigureDatatypeManager(); |
2537 NotifyObservers(); | 2511 NotifyObservers(); |
2538 } | 2512 } |
OLD | NEW |