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

Unified Diff: chrome/browser/browsing_data/conditional_cache_deletion_helper_browsertest.cc

Issue 2405803003: Replace RunLoop with WaitableEvent in ConditionalCacheDeletionHelperBrowserTest (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browsing_data/conditional_cache_deletion_helper_browsertest.cc
diff --git a/chrome/browser/browsing_data/conditional_cache_deletion_helper_browsertest.cc b/chrome/browser/browsing_data/conditional_cache_deletion_helper_browsertest.cc
index 4fec4646bc76d041cc33fe12926bfd2d881552a7..c037b1599bf31e474db41ada47027be8926d274d 100644
--- a/chrome/browser/browsing_data/conditional_cache_deletion_helper_browsertest.cc
+++ b/chrome/browser/browsing_data/conditional_cache_deletion_helper_browsertest.cc
@@ -8,8 +8,8 @@
#include <string>
#include <vector>
-#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -50,6 +50,11 @@ class ConditionalCacheDeletionHelperBrowserTest : public InProcessBrowserTest {
&ConditionalCacheDeletionHelperBrowserTest::DoneCallback,
base::Unretained(this));
+ // UI and IO thread synchronization.
+ waitable_event_ = base::MakeUnique<base::WaitableEvent>(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+
// Get the storage partition.
partition_ = content::BrowserContext::GetDefaultStoragePartition(
browser()->profile());
@@ -92,8 +97,7 @@ class ConditionalCacheDeletionHelperBrowserTest : public InProcessBrowserTest {
void WaitForTasksOnIOThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- io_thread_loop_.reset(new base::RunLoop());
- io_thread_loop_->Run();
+ waitable_event_->Wait();
}
void SetNumberOfWaitedTasks(int count) {
@@ -120,11 +124,7 @@ class ConditionalCacheDeletionHelperBrowserTest : public InProcessBrowserTest {
if (--remaining_tasks_ > 0)
return;
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&base::RunLoop::Quit,
- base::Unretained(io_thread_loop_.get())));
+ waitable_event_->Signal();
}
// Cache operation shorthands. -----------------------------------------------
@@ -195,7 +195,7 @@ class ConditionalCacheDeletionHelperBrowserTest : public InProcessBrowserTest {
base::Callback<void(int)> done_callback_;
- std::unique_ptr<base::RunLoop> io_thread_loop_;
+ std::unique_ptr<base::WaitableEvent> waitable_event_;
int remaining_tasks_;
std::vector<std::string> remaining_keys_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698