Commit 7b99fd08 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Revert "Reland "Migrate away from deprecated RunLoop API""

This reverts commit d8d9405e.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Reland "Migrate away from deprecated RunLoop API"
> 
> In this second attempt, we stick to QuitWhenIdle() for passwords, with
> no apparent legit reason. TODO added for further investigation.
> 
> This is a reland of 07edac9e
> Original change's description:
> > Migrate away from deprecated RunLoop API
> >
> > Instead, we keep around an instance of base::RunLoop and pass it
> > explicitly for Quit(), which makes sure the code quits the intended loop
> > and not a nested one.
> >
> > Bug: 783774
> > Change-Id: I3ea5092699bbae127f581e5c955cb27904d98f0a
> > Reviewed-on: https://chromium-review.googlesource.com/784790
> > Reviewed-by: Pavel Yatsuk <pavely@chromium.org>
> > Commit-Queue: Mikel Astiz <mastiz@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#519664}
> 
> TBR=pavely@chromium.org
> 
> Bug: 783774
> Change-Id: Ia93b738ad34e78289d938809f61e6c6d06c4bc80
> Reviewed-on: https://chromium-review.googlesource.com/793910
> Reviewed-by: Mikel Astiz <mastiz@chromium.org>
> Commit-Queue: Mikel Astiz <mastiz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#520539}

TBR=pavely@chromium.org,mastiz@chromium.org

Change-Id: I82972cfe1b3b7b33dd962a8fabb001bda9791c89
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 783774
Reviewed-on: https://chromium-review.googlesource.com/801111Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520570}
parent 152136f1
......@@ -87,15 +87,13 @@ class FaviconChangeObserver : public bookmarks::BookmarkModelObserver {
}
~FaviconChangeObserver() override { model_->RemoveObserver(this); }
void WaitForGetFavicon() {
DCHECK(!run_loop_.running());
wait_for_load_ = true;
content::RunThisRunLoop(&run_loop_);
content::RunMessageLoop();
ASSERT_TRUE(node_->is_favicon_loaded());
}
void WaitForSetFavicon() {
DCHECK(!run_loop_.running());
wait_for_load_ = false;
content::RunThisRunLoop(&run_loop_);
content::RunMessageLoop();
}
// bookmarks::BookmarkModelObserver:
......@@ -127,9 +125,9 @@ class FaviconChangeObserver : public bookmarks::BookmarkModelObserver {
const BookmarkNode* node) override {}
void BookmarkNodeFaviconChanged(BookmarkModel* model,
const BookmarkNode* node) override {
if (model == model_ && node == node_ && run_loop_.running()) {
if (model == model_ && node == node_) {
if (!wait_for_load_ || (wait_for_load_ && node->is_favicon_loaded()))
run_loop_.Quit();
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
}
......@@ -137,7 +135,6 @@ class FaviconChangeObserver : public bookmarks::BookmarkModelObserver {
BookmarkModel* model_;
const BookmarkNode* node_;
bool wait_for_load_;
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(FaviconChangeObserver);
};
......
......@@ -49,19 +49,15 @@ class PasswordStoreConsumerHelper
void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<PasswordForm>> results) override {
result_.swap(results);
// TODO(crbug.com/789950): Replace with Quit(), which as of today
// apparently causes a flaky DCHECK failure.
run_loop_.QuitWhenIdle();
// Quit the message loop to wake up passwords_helper::GetLogins.
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
std::vector<std::unique_ptr<PasswordForm>> WaitForResult() {
DCHECK(!run_loop_.running());
content::RunThisRunLoop(&run_loop_);
std::vector<std::unique_ptr<PasswordForm>> result() {
return std::move(result_);
}
private:
base::RunLoop run_loop_;
std::vector<std::unique_ptr<PasswordForm>> result_;
DISALLOW_COPY_AND_ASSIGN(PasswordStoreConsumerHelper);
......@@ -105,7 +101,8 @@ std::vector<std::unique_ptr<PasswordForm>> GetLogins(PasswordStore* store) {
PasswordForm::SCHEME_HTML, kFakeSignonRealm, GURL()};
PasswordStoreConsumerHelper consumer;
store->GetLogins(matcher_form, &consumer);
return consumer.WaitForResult();
content::RunMessageLoop();
return consumer.result();
}
void RemoveLogin(PasswordStore* store, const PasswordForm& form) {
......
......@@ -8,9 +8,7 @@
#include "base/run_loop.h"
#include "base/timer/timer.h"
StatusChangeChecker::StatusChangeChecker()
: run_loop_(base::RunLoop::Type::kNestableTasksAllowed),
timed_out_(false) {}
StatusChangeChecker::StatusChangeChecker() : timed_out_(false) {}
StatusChangeChecker::~StatusChangeChecker() {}
......@@ -32,9 +30,18 @@ base::TimeDelta StatusChangeChecker::GetTimeoutDuration() {
return base::TimeDelta::FromSeconds(45);
}
void StatusChangeChecker::StartBlockingWait() {
base::OneShotTimer timer;
timer.Start(FROM_HERE,
GetTimeoutDuration(),
base::Bind(&StatusChangeChecker::OnTimeout,
base::Unretained(this)));
base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).Run();
}
void StatusChangeChecker::StopWaiting() {
if (run_loop_.running())
run_loop_.Quit();
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
void StatusChangeChecker::CheckExitCondition() {
......@@ -45,17 +52,6 @@ void StatusChangeChecker::CheckExitCondition() {
}
}
void StatusChangeChecker::StartBlockingWait() {
DCHECK(!run_loop_.running());
base::OneShotTimer timer;
timer.Start(
FROM_HERE, GetTimeoutDuration(),
base::Bind(&StatusChangeChecker::OnTimeout, base::Unretained(this)));
run_loop_.Run();
}
void StatusChangeChecker::OnTimeout() {
DVLOG(1) << "Await -> Timed out: " << GetDebugMessage();
timed_out_ = true;
......
......@@ -7,7 +7,6 @@
#include <string>
#include "base/run_loop.h"
#include "base/time/time.h"
// Interface for a helper class that can pump the message loop while waiting
......@@ -46,15 +45,7 @@ class StatusChangeChecker {
// Timeout length when blocking.
virtual base::TimeDelta GetTimeoutDuration();
// Stop the nested running of the message loop started in StartBlockingWait().
void StopWaiting();
// Checks IsExitConditionSatisfied() and calls StopWaiting() if it returns
// true.
void CheckExitCondition();
private:
// Helper function to start running the nested run loop (run_loop_).
// Helper function to start running the nested run loop.
//
// Will exit if IsExitConditionSatisfied() returns true when called from
// CheckExitCondition(), if a timeout occurs, or if StopWaiting() is called.
......@@ -62,10 +53,16 @@ class StatusChangeChecker {
// The timeout length is specified with GetTimeoutDuration().
void StartBlockingWait();
// Stop the nested running of the message loop started in StartBlockingWait().
void StopWaiting();
// Checks IsExitConditionSatisfied() and calls StopWaiting() if it returns
// true.
void CheckExitCondition();
// Called when the blocking wait timeout is exceeded.
void OnTimeout();
base::RunLoop run_loop_;
bool timed_out_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment