| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/settings/people_handler.h" | 5 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 engine_start_timer_.reset(new base::OneShotTimer()); | 321 engine_start_timer_.reset(new base::OneShotTimer()); |
| 322 engine_start_timer_->Start(FROM_HERE, | 322 engine_start_timer_->Start(FROM_HERE, |
| 323 base::TimeDelta::FromSeconds(kTimeoutSec), this, | 323 base::TimeDelta::FromSeconds(kTimeoutSec), this, |
| 324 &PeopleHandler::DisplayTimeout); | 324 &PeopleHandler::DisplayTimeout); |
| 325 | 325 |
| 326 CallJavascriptFunction("cr.webUIListenerCallback", | 326 CallJavascriptFunction("cr.webUIListenerCallback", |
| 327 base::StringValue("page-status-changed"), | 327 base::StringValue("page-status-changed"), |
| 328 base::StringValue(kSpinnerPageStatus)); | 328 base::StringValue(kSpinnerPageStatus)); |
| 329 } | 329 } |
| 330 | 330 |
| 331 // TODO(kochi): Handle error conditions other than timeout. | |
| 332 // http://crbug.com/128692 | |
| 333 void PeopleHandler::DisplayTimeout() { | 331 void PeopleHandler::DisplayTimeout() { |
| 334 // Stop a timer to handle timeout in waiting for checking network connection. | 332 // Stop a timer to handle timeout in waiting for checking network connection. |
| 335 engine_start_timer_.reset(); | 333 engine_start_timer_.reset(); |
| 336 | 334 |
| 337 // Do not listen to sync startup events. | 335 // Do not listen to sync startup events. |
| 338 sync_startup_tracker_.reset(); | 336 sync_startup_tracker_.reset(); |
| 339 | 337 |
| 340 CallJavascriptFunction("cr.webUIListenerCallback", | 338 CallJavascriptFunction("cr.webUIListenerCallback", |
| 341 base::StringValue("page-status-changed"), | 339 base::StringValue("page-status-changed"), |
| 342 base::StringValue(kTimeoutPageStatus)); | 340 base::StringValue(kTimeoutPageStatus)); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 } | 770 } |
| 773 #endif | 771 #endif |
| 774 | 772 |
| 775 // Early exit if there is already a preferences push pending sync startup. | 773 // Early exit if there is already a preferences push pending sync startup. |
| 776 if (sync_startup_tracker_) | 774 if (sync_startup_tracker_) |
| 777 return; | 775 return; |
| 778 | 776 |
| 779 ProfileSyncService* service = GetSyncService(); | 777 ProfileSyncService* service = GetSyncService(); |
| 780 DCHECK(service); | 778 DCHECK(service); |
| 781 if (!service->IsEngineInitialized()) { | 779 if (!service->IsEngineInitialized()) { |
| 780 // Requesting the sync service to start may trigger another reentrant call |
| 781 // to PushSyncPrefs. Setting up the startup tracker beforehand correctly |
| 782 // signals the re-entrant call to early exit. |
| 783 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); |
| 782 service->RequestStart(); | 784 service->RequestStart(); |
| 783 | 785 |
| 784 // See if it's even possible to bring up the sync engine - if not | 786 // See if it's even possible to bring up the sync engine - if not |
| 785 // (unrecoverable error?), don't bother displaying a spinner that will be | 787 // (unrecoverable error?), don't bother displaying a spinner that will be |
| 786 // immediately closed because this leads to some ugly infinite UI loop (see | 788 // immediately closed because this leads to some ugly infinite UI loop (see |
| 787 // http://crbug.com/244769). | 789 // http://crbug.com/244769). |
| 788 if (SyncStartupTracker::GetSyncServiceState(profile_) != | 790 if (SyncStartupTracker::GetSyncServiceState(profile_) != |
| 789 SyncStartupTracker::SYNC_STARTUP_ERROR) { | 791 SyncStartupTracker::SYNC_STARTUP_ERROR) { |
| 790 DisplaySpinner(); | 792 DisplaySpinner(); |
| 791 } | 793 } |
| 792 | |
| 793 // Start SyncSetupTracker to wait for sync to initialize. | |
| 794 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); | |
| 795 return; | 794 return; |
| 796 } | 795 } |
| 797 | 796 |
| 798 configuring_sync_ = true; | 797 configuring_sync_ = true; |
| 799 DCHECK(service->IsEngineInitialized()) | 798 DCHECK(service->IsEngineInitialized()) |
| 800 << "Cannot configure sync until the sync engine is initialized"; | 799 << "Cannot configure sync until the sync engine is initialized"; |
| 801 | 800 |
| 802 // Setup args for the sync configure screen: | 801 // Setup args for the sync configure screen: |
| 803 // syncAllDataTypes: true if the user wants to sync everything | 802 // syncAllDataTypes: true if the user wants to sync everything |
| 804 // <data_type>Registered: true if the associated data type is supported | 803 // <data_type>Registered: true if the associated data type is supported |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 base::FilePath profile_file_path = profile_->GetPath(); | 911 base::FilePath profile_file_path = profile_->GetPath(); |
| 913 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 912 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 914 | 913 |
| 915 // We're done configuring, so notify ProfileSyncService that it is OK to | 914 // We're done configuring, so notify ProfileSyncService that it is OK to |
| 916 // start syncing. | 915 // start syncing. |
| 917 sync_blocker_.reset(); | 916 sync_blocker_.reset(); |
| 918 service->SetFirstSetupComplete(); | 917 service->SetFirstSetupComplete(); |
| 919 } | 918 } |
| 920 | 919 |
| 921 } // namespace settings | 920 } // namespace settings |
| OLD | NEW |