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

Unified Diff: base/prefs/pref_member.cc

Issue 1113953002: Revert of base: Remove use of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « base/prefs/pref_member.h ('k') | base/prefs/pref_member_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/pref_member.cc
diff --git a/base/prefs/pref_member.cc b/base/prefs/pref_member.cc
index 3097596dadb485495039dd68cbf4f698de203302..8d80dd0049b3dc3f47c19c44fdff8ee18895623c 100644
--- a/base/prefs/pref_member.cc
+++ b/base/prefs/pref_member.cc
@@ -7,10 +7,11 @@
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/location.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/prefs/pref_service.h"
-#include "base/thread_task_runner_handle.h"
#include "base/value_conversions.h"
+using base::MessageLoopProxy;
using base::SingleThreadTaskRunner;
namespace subtle {
@@ -51,7 +52,7 @@
}
void PrefMemberBase::MoveToThread(
- scoped_refptr<SingleThreadTaskRunner> task_runner) {
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner) {
VerifyValuePrefName();
// Load the value from preferences if it hasn't been loaded so far.
if (!internal())
@@ -90,14 +91,15 @@
}
PrefMemberBase::Internal::Internal()
- : thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ : thread_loop_(MessageLoopProxy::current()),
is_managed_(false),
is_user_modifiable_(false) {
}
PrefMemberBase::Internal::~Internal() { }
bool PrefMemberBase::Internal::IsOnCorrectThread() const {
- return thread_task_runner_->BelongsToCurrentThread();
+ // In unit tests, there may not be a message loop.
+ return thread_loop_.get() == NULL || thread_loop_->BelongsToCurrentThread();
}
void PrefMemberBase::Internal::UpdateValue(
@@ -113,18 +115,19 @@
is_managed_ = is_managed;
is_user_modifiable_ = is_user_modifiable;
} else {
- bool may_run = thread_task_runner_->PostTask(
- FROM_HERE, base::Bind(&PrefMemberBase::Internal::UpdateValue, this,
- value.release(), is_managed, is_user_modifiable,
- closure_runner.Release()));
+ bool may_run = thread_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&PrefMemberBase::Internal::UpdateValue, this,
+ value.release(), is_managed, is_user_modifiable,
+ closure_runner.Release()));
DCHECK(may_run);
}
}
void PrefMemberBase::Internal::MoveToThread(
- scoped_refptr<SingleThreadTaskRunner> task_runner) {
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner) {
CheckOnCorrectThread();
- thread_task_runner_ = task_runner.Pass();
+ thread_loop_ = task_runner;
}
bool PrefMemberVectorStringUpdate(const base::Value& value,
« no previous file with comments | « base/prefs/pref_member.h ('k') | base/prefs/pref_member_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698