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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 270081: Facelifts to sync UI (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/new_new_tab.js ('k') | chrome/browser/sync/resources/gaia_login.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifdef CHROME_PERSONALIZATION 5 #ifdef CHROME_PERSONALIZATION
6 #include "chrome/browser/sync/profile_sync_service.h" 6 #include "chrome/browser/sync/profile_sync_service.h"
7 7
8 #include <stack> 8 #include <stack>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 profile_->GetPrefs()->SetInt64(prefs::kSyncLastSyncedTime, 205 profile_->GetPrefs()->SetInt64(prefs::kSyncLastSyncedTime,
206 last_synced_time_.ToInternalValue()); 206 last_synced_time_.ToInternalValue());
207 profile_->GetPrefs()->ScheduleSavePersistentPrefs(); 207 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
208 } 208 }
209 209
210 // An invariant has been violated. Transition to an error state where we try 210 // An invariant has been violated. Transition to an error state where we try
211 // to do as little work as possible, to avoid further corruption or crashes. 211 // to do as little work as possible, to avoid further corruption or crashes.
212 void ProfileSyncService::OnUnrecoverableError() { 212 void ProfileSyncService::OnUnrecoverableError() {
213 unrecoverable_error_detected_ = true; 213 unrecoverable_error_detected_ = true;
214 change_processor_->Stop(); 214 change_processor_->Stop();
215 215
216 if (SetupInProgress()) 216 // Tell the wizard so it can inform the user only if it is already open.
217 wizard_.Step(SyncSetupWizard::FATAL_ERROR); 217 wizard_.Step(SyncSetupWizard::FATAL_ERROR);
218 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); 218 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
219 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable."; 219 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable.";
220 } 220 }
221 221
222 void ProfileSyncService::OnBackendInitialized() { 222 void ProfileSyncService::OnBackendInitialized() {
223 backend_initialized_ = true; 223 backend_initialized_ = true;
224 StartProcessingChangesIfReady(); 224 StartProcessingChangesIfReady();
225 225
226 // The very first time the backend initializes is effectively the first time 226 // The very first time the backend initializes is effectively the first time
227 // we can say we successfully "synced". last_synced_time_ will only be null 227 // we can say we successfully "synced". last_synced_time_ will only be null
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 last_attempted_user_email_ = username; 331 last_attempted_user_email_ = username;
332 is_auth_in_progress_ = true; 332 is_auth_in_progress_ = true;
333 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); 333 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
334 334
335 auth_start_time_ = base::TimeTicks::Now(); 335 auth_start_time_ = base::TimeTicks::Now();
336 backend_->Authenticate(username, password); 336 backend_->Authenticate(username, password);
337 } 337 }
338 338
339 void ProfileSyncService::OnUserAcceptedMergeAndSync() { 339 void ProfileSyncService::OnUserAcceptedMergeAndSync() {
340 base::TimeTicks start_time = base::TimeTicks::Now(); 340 base::TimeTicks start_time = base::TimeTicks::Now();
341 bool not_first_run = model_associator_->SyncModelHasUserCreatedNodes();
341 bool merge_success = model_associator_->AssociateModels(); 342 bool merge_success = model_associator_->AssociateModels();
342 UMA_HISTOGRAM_MEDIUM_TIMES("Sync.UserPerceivedBookmarkAssociation", 343 UMA_HISTOGRAM_MEDIUM_TIMES("Sync.UserPerceivedBookmarkAssociation",
343 base::TimeTicks::Now() - start_time); 344 base::TimeTicks::Now() - start_time);
344
345 wizard_.Step(SyncSetupWizard::DONE); // TODO(timsteele): error state?
346 if (!merge_success) { 345 if (!merge_success) {
347 LOG(ERROR) << "Model assocation failed."; 346 LOG(ERROR) << "Model assocation failed.";
348 OnUnrecoverableError(); 347 OnUnrecoverableError();
349 return; 348 return;
350 } 349 }
351 350
351 wizard_.Step(not_first_run ? SyncSetupWizard::DONE :
352 SyncSetupWizard::DONE_FIRST_TIME);
353
352 change_processor_->Start(profile_->GetBookmarkModel(), 354 change_processor_->Start(profile_->GetBookmarkModel(),
353 backend_->GetUserShareHandle()); 355 backend_->GetUserShareHandle());
354 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); 356 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
355 } 357 }
356 358
357 void ProfileSyncService::OnUserCancelledDialog() { 359 void ProfileSyncService::OnUserCancelledDialog() {
358 if (!profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted)) { 360 if (!profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted)) {
359 // A sync dialog was aborted before authentication or merge acceptance. 361 // A sync dialog was aborted before authentication or merge acceptance.
360 // Rollback. 362 // Rollback.
361 DisableForUser(); 363 DisableForUser();
(...skipping 16 matching lines...) Expand all
378 380
379 // Show the sync merge warning dialog if needed. 381 // Show the sync merge warning dialog if needed.
380 if (MergeAndSyncAcceptanceNeeded()) { 382 if (MergeAndSyncAcceptanceNeeded()) {
381 ProfileSyncService::SyncEvent(MERGE_AND_SYNC_NEEDED); 383 ProfileSyncService::SyncEvent(MERGE_AND_SYNC_NEEDED);
382 wizard_.Step(SyncSetupWizard::MERGE_AND_SYNC); 384 wizard_.Step(SyncSetupWizard::MERGE_AND_SYNC);
383 return; 385 return;
384 } 386 }
385 387
386 // We're ready to merge the models. 388 // We're ready to merge the models.
387 base::TimeTicks start_time = base::TimeTicks::Now(); 389 base::TimeTicks start_time = base::TimeTicks::Now();
390 bool not_first_run = model_associator_->SyncModelHasUserCreatedNodes();
388 bool merge_success = model_associator_->AssociateModels(); 391 bool merge_success = model_associator_->AssociateModels();
389 UMA_HISTOGRAM_TIMES("Sync.BookmarkAssociationTime", 392 UMA_HISTOGRAM_TIMES("Sync.BookmarkAssociationTime",
390 base::TimeTicks::Now() - start_time); 393 base::TimeTicks::Now() - start_time);
394 if (!merge_success) {
395 LOG(ERROR) << "Model assocation failed.";
396 OnUnrecoverableError();
397 return;
398 }
391 399
392 wizard_.Step(SyncSetupWizard::DONE); // TODO(timsteele): error state? 400 wizard_.Step(not_first_run ? SyncSetupWizard::DONE :
393 if (!merge_success) { 401 SyncSetupWizard::DONE_FIRST_TIME);
394 LOG(ERROR) << "Model assocation failed.";
395 OnUnrecoverableError();
396 return;
397 }
398 402
399 change_processor_->Start(profile_->GetBookmarkModel(), 403 change_processor_->Start(profile_->GetBookmarkModel(),
400 backend_->GetUserShareHandle()); 404 backend_->GetUserShareHandle());
401 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); 405 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
402 } 406 }
403 407
404 void ProfileSyncService::AddObserver(Observer* observer) { 408 void ProfileSyncService::AddObserver(Observer* observer) {
405 observers_.AddObserver(observer); 409 observers_.AddObserver(observer);
406 } 410 }
407 411
(...skipping 10 matching lines...) Expand all
418 } 422 }
419 423
420 bool ProfileSyncService::ShouldPushChanges() { 424 bool ProfileSyncService::ShouldPushChanges() {
421 // True only after all bootstrapping has succeeded: the bookmark model is 425 // True only after all bootstrapping has succeeded: the bookmark model is
422 // loaded, the sync backend is initialized, the two domains are 426 // loaded, the sync backend is initialized, the two domains are
423 // consistent with one another, and no unrecoverable error has transpired. 427 // consistent with one another, and no unrecoverable error has transpired.
424 return change_processor_->IsRunning(); 428 return change_processor_->IsRunning();
425 } 429 }
426 430
427 #endif // CHROME_PERSONALIZATION 431 #endif // CHROME_PERSONALIZATION
OLDNEW
« no previous file with comments | « chrome/browser/resources/new_new_tab.js ('k') | chrome/browser/sync/resources/gaia_login.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698