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

Side by Side Diff: chrome/browser/profile_resetter/automatic_profile_resetter.cc

Issue 1107863002: [chrome/browser/profile_resetter] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/profile_resetter/automatic_profile_resetter_delegate.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/profile_resetter/automatic_profile_resetter.h" 5 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 void IncludeMementoValues() { 211 void IncludeMementoValues() {
212 data_->SetString(kMementoValueInPrefsKey, memento_in_prefs_.ReadValue()); 212 data_->SetString(kMementoValueInPrefsKey, memento_in_prefs_.ReadValue());
213 data_->SetString(kMementoValueInLocalStateKey, 213 data_->SetString(kMementoValueInLocalStateKey,
214 memento_in_local_state_.ReadValue()); 214 memento_in_local_state_.ReadValue());
215 memento_in_file_.ReadValue(base::Bind( 215 memento_in_file_.ReadValue(base::Bind(
216 &InputBuilder::IncludeFileBasedMementoCallback, AsWeakPtr())); 216 &InputBuilder::IncludeFileBasedMementoCallback, AsWeakPtr()));
217 } 217 }
218 218
219 // Called back by |memento_in_file_| once the |memento_value| has been read. 219 // Called back by |memento_in_file_| once the |memento_value| has been read.
220 void IncludeFileBasedMementoCallback(const std::string& memento_value) { 220 void IncludeFileBasedMementoCallback(const std::string& memento_value) {
221 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 221 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
222 data_->SetString(kMementoValueInFileKey, memento_value); 222 data_->SetString(kMementoValueInFileKey, memento_value);
223 // As an asynchronous task, we need to take care of posting the next task. 223 // As an asynchronous task, we need to take care of posting the next task.
224 PostNextTask(); 224 PostNextTask();
225 } 225 }
226 226
227 // Task that includes all user (i.e. profile-specific) preferences, along with 227 // Task that includes all user (i.e. profile-specific) preferences, along with
228 // information about whether the value is coming from the 'user' PrefStore. 228 // information about whether the value is coming from the 'user' PrefStore.
229 // This is the most expensive operation, so it is itself split into two parts. 229 // This is the most expensive operation, so it is itself split into two parts.
230 void IncludeUserPreferences() { 230 void IncludeUserPreferences() {
231 PrefService* prefs = profile_->GetPrefs(); 231 PrefService* prefs = profile_->GetPrefs();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 template_url_service_ready_(false), 375 template_url_service_ready_(false),
376 has_already_dismissed_prompt_(false), 376 has_already_dismissed_prompt_(false),
377 should_show_reset_banner_(false), 377 should_show_reset_banner_(false),
378 weak_ptr_factory_(this) { 378 weak_ptr_factory_(this) {
379 DCHECK(profile_); 379 DCHECK(profile_);
380 } 380 }
381 381
382 AutomaticProfileResetter::~AutomaticProfileResetter() {} 382 AutomaticProfileResetter::~AutomaticProfileResetter() {}
383 383
384 void AutomaticProfileResetter::Initialize() { 384 void AutomaticProfileResetter::Initialize() {
385 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 385 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
386 DCHECK_EQ(state_, STATE_UNINITIALIZED); 386 DCHECK_EQ(state_, STATE_UNINITIALIZED);
387 387
388 if (!ShouldPerformDryRun() && !ShouldPerformLiveRun()) { 388 if (!ShouldPerformDryRun() && !ShouldPerformLiveRun()) {
389 state_ = STATE_DISABLED; 389 state_ = STATE_DISABLED;
390 return; 390 return;
391 } 391 }
392 392
393 if (!GetProgramAndHashSeedOverridesFromExperiment(&program_, &hash_seed_)) { 393 if (!GetProgramAndHashSeedOverridesFromExperiment(&program_, &hash_seed_)) {
394 ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance()); 394 ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance());
395 if (ShouldPerformLiveRun()) { 395 if (ShouldPerformLiveRun()) {
(...skipping 12 matching lines...) Expand all
408 delegate_.reset(new AutomaticProfileResetterDelegateImpl( 408 delegate_.reset(new AutomaticProfileResetterDelegateImpl(
409 profile_, ProfileResetter::ALL)); 409 profile_, ProfileResetter::ALL));
410 task_runner_for_waiting_ = 410 task_runner_for_waiting_ =
411 content::BrowserThread::GetMessageLoopProxyForThread( 411 content::BrowserThread::GetMessageLoopProxyForThread(
412 content::BrowserThread::UI); 412 content::BrowserThread::UI);
413 413
414 state_ = STATE_INITIALIZED; 414 state_ = STATE_INITIALIZED;
415 } 415 }
416 416
417 void AutomaticProfileResetter::Activate() { 417 void AutomaticProfileResetter::Activate() {
418 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 418 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
419 DCHECK(state_ == STATE_INITIALIZED || state_ == STATE_DISABLED); 419 DCHECK(state_ == STATE_INITIALIZED || state_ == STATE_DISABLED);
420 420
421 if (state_ == STATE_INITIALIZED) { 421 if (state_ == STATE_INITIALIZED) {
422 if (!program_.empty()) { 422 if (!program_.empty()) {
423 // Some steps in the flow (e.g. loaded modules, file-based memento) are 423 // Some steps in the flow (e.g. loaded modules, file-based memento) are
424 // IO-intensive, so defer execution until some time later. 424 // IO-intensive, so defer execution until some time later.
425 task_runner_for_waiting_->PostDelayedTask( 425 task_runner_for_waiting_->PostDelayedTask(
426 FROM_HERE, 426 FROM_HERE,
427 base::Bind(&AutomaticProfileResetter::PrepareEvaluationFlow, 427 base::Bind(&AutomaticProfileResetter::PrepareEvaluationFlow,
428 weak_ptr_factory_.GetWeakPtr()), 428 weak_ptr_factory_.GetWeakPtr()),
429 base::TimeDelta::FromSeconds(kEvaluationFlowDelayInSeconds)); 429 base::TimeDelta::FromSeconds(kEvaluationFlowDelayInSeconds));
430 } else { 430 } else {
431 // Terminate early if there is no program included (nor set by tests). 431 // Terminate early if there is no program included (nor set by tests).
432 state_ = STATE_DISABLED; 432 state_ = STATE_DISABLED;
433 } 433 }
434 } 434 }
435 } 435 }
436 436
437 void AutomaticProfileResetter::TriggerProfileReset(bool send_feedback) { 437 void AutomaticProfileResetter::TriggerProfileReset(bool send_feedback) {
438 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 438 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
439 DCHECK_EQ(state_, STATE_HAS_SHOWN_BUBBLE); 439 DCHECK_EQ(state_, STATE_HAS_SHOWN_BUBBLE);
440 440
441 state_ = STATE_PERFORMING_RESET; 441 state_ = STATE_PERFORMING_RESET;
442 should_show_reset_banner_ = false; 442 should_show_reset_banner_ = false;
443 443
444 ReportPromptResult(PROMPT_ACTION_RESET); 444 ReportPromptResult(PROMPT_ACTION_RESET);
445 delegate_->TriggerProfileSettingsReset( 445 delegate_->TriggerProfileSettingsReset(
446 send_feedback, 446 send_feedback,
447 base::Bind(&AutomaticProfileResetter::OnProfileSettingsResetCompleted, 447 base::Bind(&AutomaticProfileResetter::OnProfileSettingsResetCompleted,
448 weak_ptr_factory_.GetWeakPtr())); 448 weak_ptr_factory_.GetWeakPtr()));
449 } 449 }
450 450
451 void AutomaticProfileResetter::SkipProfileReset() { 451 void AutomaticProfileResetter::SkipProfileReset() {
452 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 452 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
453 DCHECK_EQ(state_, STATE_HAS_SHOWN_BUBBLE); 453 DCHECK_EQ(state_, STATE_HAS_SHOWN_BUBBLE);
454 454
455 should_show_reset_banner_ = false; 455 should_show_reset_banner_ = false;
456 456
457 ReportPromptResult(PROMPT_ACTION_NO_RESET); 457 ReportPromptResult(PROMPT_ACTION_NO_RESET);
458 delegate_->DismissPrompt(); 458 delegate_->DismissPrompt();
459 FinishResetPromptFlow(); 459 FinishResetPromptFlow();
460 } 460 }
461 461
462 bool AutomaticProfileResetter::IsResetPromptFlowActive() const { 462 bool AutomaticProfileResetter::IsResetPromptFlowActive() const {
463 return state_ == STATE_HAS_TRIGGERED_PROMPT || 463 return state_ == STATE_HAS_TRIGGERED_PROMPT ||
464 state_ == STATE_HAS_SHOWN_BUBBLE; 464 state_ == STATE_HAS_SHOWN_BUBBLE;
465 } 465 }
466 466
467 bool AutomaticProfileResetter::ShouldShowResetBanner() const { 467 bool AutomaticProfileResetter::ShouldShowResetBanner() const {
468 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 468 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
469 return should_show_reset_banner_ && ShouldPerformLiveRun(); 469 return should_show_reset_banner_ && ShouldPerformLiveRun();
470 } 470 }
471 471
472 void AutomaticProfileResetter::NotifyDidShowResetBubble() { 472 void AutomaticProfileResetter::NotifyDidShowResetBubble() {
473 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 473 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
474 DCHECK_EQ(state_, STATE_HAS_TRIGGERED_PROMPT); 474 DCHECK_EQ(state_, STATE_HAS_TRIGGERED_PROMPT);
475 475
476 state_ = STATE_HAS_SHOWN_BUBBLE; 476 state_ = STATE_HAS_SHOWN_BUBBLE;
477 477
478 PersistMementos(); 478 PersistMementos();
479 ReportPromptResult(PROMPT_SHOWN_BUBBLE); 479 ReportPromptResult(PROMPT_SHOWN_BUBBLE);
480 } 480 }
481 481
482 void AutomaticProfileResetter::NotifyDidOpenWebUIResetDialog() { 482 void AutomaticProfileResetter::NotifyDidOpenWebUIResetDialog() {
483 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 483 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
484 484
485 // This notification is invoked unconditionally by the WebUI, only care about 485 // This notification is invoked unconditionally by the WebUI, only care about
486 // it when the prompt flow is currently active (and not yet resetting). 486 // it when the prompt flow is currently active (and not yet resetting).
487 if (state_ == STATE_HAS_TRIGGERED_PROMPT || 487 if (state_ == STATE_HAS_TRIGGERED_PROMPT ||
488 state_ == STATE_HAS_SHOWN_BUBBLE) { 488 state_ == STATE_HAS_SHOWN_BUBBLE) {
489 has_already_dismissed_prompt_ = true; 489 has_already_dismissed_prompt_ = true;
490 delegate_->DismissPrompt(); 490 delegate_->DismissPrompt();
491 } 491 }
492 } 492 }
493 493
494 void AutomaticProfileResetter::NotifyDidCloseWebUIResetDialog( 494 void AutomaticProfileResetter::NotifyDidCloseWebUIResetDialog(
495 bool performed_reset) { 495 bool performed_reset) {
496 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 496 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
497 497
498 // This notification is invoked unconditionally by the WebUI, only care about 498 // This notification is invoked unconditionally by the WebUI, only care about
499 // it when the prompt flow is currently active (and not yet resetting). 499 // it when the prompt flow is currently active (and not yet resetting).
500 if (state_ == STATE_HAS_TRIGGERED_PROMPT || 500 if (state_ == STATE_HAS_TRIGGERED_PROMPT ||
501 state_ == STATE_HAS_SHOWN_BUBBLE) { 501 state_ == STATE_HAS_SHOWN_BUBBLE) {
502 if (!has_already_dismissed_prompt_) 502 if (!has_already_dismissed_prompt_)
503 delegate_->DismissPrompt(); 503 delegate_->DismissPrompt();
504 if (state_ == STATE_HAS_TRIGGERED_PROMPT) { 504 if (state_ == STATE_HAS_TRIGGERED_PROMPT) {
505 PersistMementos(); 505 PersistMementos();
506 ReportPromptResult(performed_reset ? 506 ReportPromptResult(performed_reset ?
507 PROMPT_NOT_SHOWN_BUBBLE_BUT_HAD_WEBUI_RESET : 507 PROMPT_NOT_SHOWN_BUBBLE_BUT_HAD_WEBUI_RESET :
508 PROMPT_NOT_SHOWN_BUBBLE_BUT_HAD_WEBUI_NO_RESET); 508 PROMPT_NOT_SHOWN_BUBBLE_BUT_HAD_WEBUI_NO_RESET);
509 } else { // if (state_ == STATE_HAS_SHOWN_PROMPT) 509 } else { // if (state_ == STATE_HAS_SHOWN_PROMPT)
510 ReportPromptResult(performed_reset ? 510 ReportPromptResult(performed_reset ?
511 PROMPT_FOLLOWED_BY_WEBUI_RESET : 511 PROMPT_FOLLOWED_BY_WEBUI_RESET :
512 PROMPT_FOLLOWED_BY_WEBUI_NO_RESET); 512 PROMPT_FOLLOWED_BY_WEBUI_NO_RESET);
513 } 513 }
514 FinishResetPromptFlow(); 514 FinishResetPromptFlow();
515 } 515 }
516 } 516 }
517 517
518 void AutomaticProfileResetter::NotifyDidCloseWebUIResetBanner() { 518 void AutomaticProfileResetter::NotifyDidCloseWebUIResetBanner() {
519 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 519 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
520 should_show_reset_banner_ = false; 520 should_show_reset_banner_ = false;
521 } 521 }
522 522
523 void AutomaticProfileResetter::SetProgramForTesting( 523 void AutomaticProfileResetter::SetProgramForTesting(
524 const std::string& program) { 524 const std::string& program) {
525 program_ = program; 525 program_ = program;
526 } 526 }
527 527
528 void AutomaticProfileResetter::SetHashSeedForTesting( 528 void AutomaticProfileResetter::SetHashSeedForTesting(
529 const std::string& hash_key) { 529 const std::string& hash_key) {
530 hash_seed_ = hash_key; 530 hash_seed_ = hash_key;
531 } 531 }
532 532
533 void AutomaticProfileResetter::SetDelegateForTesting( 533 void AutomaticProfileResetter::SetDelegateForTesting(
534 scoped_ptr<AutomaticProfileResetterDelegate> delegate) { 534 scoped_ptr<AutomaticProfileResetterDelegate> delegate) {
535 delegate_ = delegate.Pass(); 535 delegate_ = delegate.Pass();
536 } 536 }
537 537
538 void AutomaticProfileResetter::SetTaskRunnerForWaitingForTesting( 538 void AutomaticProfileResetter::SetTaskRunnerForWaitingForTesting(
539 const scoped_refptr<base::TaskRunner>& task_runner) { 539 const scoped_refptr<base::TaskRunner>& task_runner) {
540 task_runner_for_waiting_ = task_runner; 540 task_runner_for_waiting_ = task_runner;
541 } 541 }
542 542
543 void AutomaticProfileResetter::Shutdown() { 543 void AutomaticProfileResetter::Shutdown() {
544 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 544 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
545 545
546 // We better not do anything substantial at this point. The metrics service 546 // We better not do anything substantial at this point. The metrics service
547 // has already been shut down; and local state has already been commited to 547 // has already been shut down; and local state has already been commited to
548 // file (in the regular fashion) for the last time. 548 // file (in the regular fashion) for the last time.
549 549
550 state_ = STATE_DISABLED; 550 state_ = STATE_DISABLED;
551 551
552 weak_ptr_factory_.InvalidateWeakPtrs(); 552 weak_ptr_factory_.InvalidateWeakPtrs();
553 delegate_.reset(); 553 delegate_.reset();
554 } 554 }
555 555
556 void AutomaticProfileResetter::PrepareEvaluationFlow() { 556 void AutomaticProfileResetter::PrepareEvaluationFlow() {
557 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 557 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
558 DCHECK_EQ(state_, STATE_INITIALIZED); 558 DCHECK_EQ(state_, STATE_INITIALIZED);
559 559
560 state_ = STATE_WAITING_ON_DEPENDENCIES; 560 state_ = STATE_WAITING_ON_DEPENDENCIES;
561 561
562 delegate_->RequestCallbackWhenTemplateURLServiceIsLoaded( 562 delegate_->RequestCallbackWhenTemplateURLServiceIsLoaded(
563 base::Bind(&AutomaticProfileResetter::OnTemplateURLServiceIsLoaded, 563 base::Bind(&AutomaticProfileResetter::OnTemplateURLServiceIsLoaded,
564 weak_ptr_factory_.GetWeakPtr())); 564 weak_ptr_factory_.GetWeakPtr()));
565 delegate_->RequestCallbackWhenLoadedModulesAreEnumerated( 565 delegate_->RequestCallbackWhenLoadedModulesAreEnumerated(
566 base::Bind(&AutomaticProfileResetter::OnLoadedModulesAreEnumerated, 566 base::Bind(&AutomaticProfileResetter::OnLoadedModulesAreEnumerated,
567 weak_ptr_factory_.GetWeakPtr())); 567 weak_ptr_factory_.GetWeakPtr()));
568 delegate_->LoadTemplateURLServiceIfNeeded(); 568 delegate_->LoadTemplateURLServiceIfNeeded();
569 delegate_->EnumerateLoadedModulesIfNeeded(); 569 delegate_->EnumerateLoadedModulesIfNeeded();
570 } 570 }
571 571
572 void AutomaticProfileResetter::OnTemplateURLServiceIsLoaded() { 572 void AutomaticProfileResetter::OnTemplateURLServiceIsLoaded() {
573 template_url_service_ready_ = true; 573 template_url_service_ready_ = true;
574 OnDependencyIsReady(); 574 OnDependencyIsReady();
575 } 575 }
576 576
577 void AutomaticProfileResetter::OnLoadedModulesAreEnumerated() { 577 void AutomaticProfileResetter::OnLoadedModulesAreEnumerated() {
578 enumeration_of_loaded_modules_ready_ = true; 578 enumeration_of_loaded_modules_ready_ = true;
579 OnDependencyIsReady(); 579 OnDependencyIsReady();
580 } 580 }
581 581
582 void AutomaticProfileResetter::OnDependencyIsReady() { 582 void AutomaticProfileResetter::OnDependencyIsReady() {
583 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 583 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
584 DCHECK_EQ(state_, STATE_WAITING_ON_DEPENDENCIES); 584 DCHECK_EQ(state_, STATE_WAITING_ON_DEPENDENCIES);
585 585
586 if (template_url_service_ready_ && enumeration_of_loaded_modules_ready_) { 586 if (template_url_service_ready_ && enumeration_of_loaded_modules_ready_) {
587 state_ = STATE_READY; 587 state_ = STATE_READY;
588 content::BrowserThread::PostTask( 588 content::BrowserThread::PostTask(
589 content::BrowserThread::UI, 589 content::BrowserThread::UI,
590 FROM_HERE, 590 FROM_HERE,
591 base::Bind(&AutomaticProfileResetter::BeginEvaluationFlow, 591 base::Bind(&AutomaticProfileResetter::BeginEvaluationFlow,
592 weak_ptr_factory_.GetWeakPtr())); 592 weak_ptr_factory_.GetWeakPtr()));
593 } 593 }
594 } 594 }
595 595
596 void AutomaticProfileResetter::BeginEvaluationFlow() { 596 void AutomaticProfileResetter::BeginEvaluationFlow() {
597 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 597 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
598 DCHECK_EQ(state_, STATE_READY); 598 DCHECK_EQ(state_, STATE_READY);
599 DCHECK(!program_.empty()); 599 DCHECK(!program_.empty());
600 DCHECK(!input_builder_); 600 DCHECK(!input_builder_);
601 601
602 state_ = STATE_EVALUATING_CONDITIONS; 602 state_ = STATE_EVALUATING_CONDITIONS;
603 603
604 input_builder_.reset(new InputBuilder(profile_, delegate_.get())); 604 input_builder_.reset(new InputBuilder(profile_, delegate_.get()));
605 input_builder_->BuildEvaluatorProgramInput( 605 input_builder_->BuildEvaluatorProgramInput(
606 base::Bind(&AutomaticProfileResetter::ContinueWithEvaluationFlow, 606 base::Bind(&AutomaticProfileResetter::ContinueWithEvaluationFlow,
607 weak_ptr_factory_.GetWeakPtr())); 607 weak_ptr_factory_.GetWeakPtr()));
608 } 608 }
609 609
610 void AutomaticProfileResetter::ContinueWithEvaluationFlow( 610 void AutomaticProfileResetter::ContinueWithEvaluationFlow(
611 scoped_ptr<base::DictionaryValue> program_input) { 611 scoped_ptr<base::DictionaryValue> program_input) {
612 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 612 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
613 DCHECK_EQ(state_, STATE_EVALUATING_CONDITIONS); 613 DCHECK_EQ(state_, STATE_EVALUATING_CONDITIONS);
614 614
615 input_builder_.reset(); 615 input_builder_.reset();
616 616
617 base::SequencedWorkerPool* blocking_pool = 617 base::SequencedWorkerPool* blocking_pool =
618 content::BrowserThread::GetBlockingPool(); 618 content::BrowserThread::GetBlockingPool();
619 scoped_refptr<base::TaskRunner> task_runner = 619 scoped_refptr<base::TaskRunner> task_runner =
620 blocking_pool->GetTaskRunnerWithShutdownBehavior( 620 blocking_pool->GetTaskRunnerWithShutdownBehavior(
621 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 621 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
622 622
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 UMA_HISTOGRAM_ENUMERATION("AutomaticProfileReset.SatisfiedCriteriaMask", 679 UMA_HISTOGRAM_ENUMERATION("AutomaticProfileReset.SatisfiedCriteriaMask",
680 satisfied_criteria_mask, 680 satisfied_criteria_mask,
681 kSatisfiedCriteriaMaskMaximumValue); 681 kSatisfiedCriteriaMaskMaximumValue);
682 UMA_HISTOGRAM_ENUMERATION("AutomaticProfileReset.CombinedStatusMask", 682 UMA_HISTOGRAM_ENUMERATION("AutomaticProfileReset.CombinedStatusMask",
683 combined_status_mask, 683 combined_status_mask,
684 kCombinedStatusMaskMaximumValue); 684 kCombinedStatusMaskMaximumValue);
685 } 685 }
686 686
687 void AutomaticProfileResetter::FinishEvaluationFlow( 687 void AutomaticProfileResetter::FinishEvaluationFlow(
688 scoped_ptr<EvaluationResults> results) { 688 scoped_ptr<EvaluationResults> results) {
689 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 689 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
690 DCHECK_EQ(state_, STATE_EVALUATING_CONDITIONS); 690 DCHECK_EQ(state_, STATE_EVALUATING_CONDITIONS);
691 691
692 ReportStatistics(results->satisfied_criteria_mask, 692 ReportStatistics(results->satisfied_criteria_mask,
693 results->combined_status_mask); 693 results->combined_status_mask);
694 694
695 if (results->should_prompt) 695 if (results->should_prompt)
696 should_show_reset_banner_ = true; 696 should_show_reset_banner_ = true;
697 697
698 if (results->should_prompt && !results->had_prompted_already) { 698 if (results->should_prompt && !results->had_prompted_already) {
699 evaluation_results_ = results.Pass(); 699 evaluation_results_ = results.Pass();
700 BeginResetPromptFlow(); 700 BeginResetPromptFlow();
701 } else { 701 } else {
702 state_ = STATE_DONE; 702 state_ = STATE_DONE;
703 } 703 }
704 } 704 }
705 705
706 void AutomaticProfileResetter::BeginResetPromptFlow() { 706 void AutomaticProfileResetter::BeginResetPromptFlow() {
707 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 707 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
708 DCHECK_EQ(state_, STATE_EVALUATING_CONDITIONS); 708 DCHECK_EQ(state_, STATE_EVALUATING_CONDITIONS);
709 709
710 state_ = STATE_HAS_TRIGGERED_PROMPT; 710 state_ = STATE_HAS_TRIGGERED_PROMPT;
711 711
712 if (ShouldPerformLiveRun() && delegate_->TriggerPrompt()) { 712 if (ShouldPerformLiveRun() && delegate_->TriggerPrompt()) {
713 // Start fetching the brandcoded default settings speculatively in the 713 // Start fetching the brandcoded default settings speculatively in the
714 // background, so as to reduce waiting time if the user chooses to go 714 // background, so as to reduce waiting time if the user chooses to go
715 // through with the reset. 715 // through with the reset.
716 delegate_->FetchBrandcodedDefaultSettingsIfNeeded(); 716 delegate_->FetchBrandcodedDefaultSettingsIfNeeded();
717 } else { 717 } else {
718 PersistMementos(); 718 PersistMementos();
719 ReportPromptResult(PROMPT_NOT_TRIGGERED); 719 ReportPromptResult(PROMPT_NOT_TRIGGERED);
720 FinishResetPromptFlow(); 720 FinishResetPromptFlow();
721 } 721 }
722 } 722 }
723 723
724 void AutomaticProfileResetter::OnProfileSettingsResetCompleted() { 724 void AutomaticProfileResetter::OnProfileSettingsResetCompleted() {
725 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 725 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
726 DCHECK_EQ(state_, STATE_PERFORMING_RESET); 726 DCHECK_EQ(state_, STATE_PERFORMING_RESET);
727 727
728 delegate_->DismissPrompt(); 728 delegate_->DismissPrompt();
729 FinishResetPromptFlow(); 729 FinishResetPromptFlow();
730 } 730 }
731 731
732 void AutomaticProfileResetter::ReportPromptResult(PromptResult result) { 732 void AutomaticProfileResetter::ReportPromptResult(PromptResult result) {
733 UMA_HISTOGRAM_ENUMERATION( 733 UMA_HISTOGRAM_ENUMERATION(
734 "AutomaticProfileReset.PromptResult", result, PROMPT_RESULT_MAX); 734 "AutomaticProfileReset.PromptResult", result, PROMPT_RESULT_MAX);
735 } 735 }
736 736
737 void AutomaticProfileResetter::PersistMementos() { 737 void AutomaticProfileResetter::PersistMementos() {
738 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 738 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
739 DCHECK(state_ == STATE_HAS_TRIGGERED_PROMPT || 739 DCHECK(state_ == STATE_HAS_TRIGGERED_PROMPT ||
740 state_ == STATE_HAS_SHOWN_BUBBLE); 740 state_ == STATE_HAS_SHOWN_BUBBLE);
741 DCHECK(evaluation_results_); 741 DCHECK(evaluation_results_);
742 742
743 PreferenceHostedPromptMemento memento_in_prefs(profile_); 743 PreferenceHostedPromptMemento memento_in_prefs(profile_);
744 LocalStateHostedPromptMemento memento_in_local_state(profile_); 744 LocalStateHostedPromptMemento memento_in_local_state(profile_);
745 FileHostedPromptMemento memento_in_file(profile_); 745 FileHostedPromptMemento memento_in_file(profile_);
746 746
747 memento_in_prefs.StoreValue(evaluation_results_->memento_value_in_prefs); 747 memento_in_prefs.StoreValue(evaluation_results_->memento_value_in_prefs);
748 memento_in_local_state.StoreValue( 748 memento_in_local_state.StoreValue(
749 evaluation_results_->memento_value_in_local_state); 749 evaluation_results_->memento_value_in_local_state);
750 memento_in_file.StoreValue(evaluation_results_->memento_value_in_file); 750 memento_in_file.StoreValue(evaluation_results_->memento_value_in_file);
751 751
752 evaluation_results_.reset(); 752 evaluation_results_.reset();
753 } 753 }
754 754
755 void AutomaticProfileResetter::FinishResetPromptFlow() { 755 void AutomaticProfileResetter::FinishResetPromptFlow() {
756 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 756 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
757 DCHECK(state_ == STATE_HAS_TRIGGERED_PROMPT || 757 DCHECK(state_ == STATE_HAS_TRIGGERED_PROMPT ||
758 state_ == STATE_HAS_SHOWN_BUBBLE || 758 state_ == STATE_HAS_SHOWN_BUBBLE ||
759 state_ == STATE_PERFORMING_RESET); 759 state_ == STATE_PERFORMING_RESET);
760 DCHECK(!evaluation_results_); 760 DCHECK(!evaluation_results_);
761 761
762 state_ = STATE_DONE; 762 state_ = STATE_DONE;
763 } 763 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profile_resetter/automatic_profile_resetter_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698