Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: components/browser_sync/profile_sync_service.cc

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

Powered by Google App Engine
This is Rietveld 408576698