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

Unified Diff: base/message_loop/message_loop_proxy_impl.cc

Issue 19661004: Made MessagePump a non-thread safe class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding a missing header. Created 7 years, 5 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/message_loop/message_loop_proxy_impl.h ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop_proxy_impl.cc
diff --git a/base/message_loop/message_loop_proxy_impl.cc b/base/message_loop/message_loop_proxy_impl.cc
index 7dc8caa9f4c047f93cf7366c2e373ad1eebdd0fb..b7abca377e668270d2f1db89f54c3731de577602 100644
--- a/base/message_loop/message_loop_proxy_impl.cc
+++ b/base/message_loop/message_loop_proxy_impl.cc
@@ -5,81 +5,43 @@
#include "base/message_loop/message_loop_proxy_impl.h"
#include "base/location.h"
-#include "base/threading/thread_restrictions.h"
+#include "base/logging.h"
+#include "base/message_loop/incoming_task_queue.h"
+#include "base/message_loop/message_loop.h"
namespace base {
+namespace internal {
-MessageLoopProxyImpl::~MessageLoopProxyImpl() {
+MessageLoopProxyImpl::MessageLoopProxyImpl(
+ scoped_refptr<IncomingTaskQueue> incoming_queue)
+ : incoming_queue_(incoming_queue),
+ valid_thread_id_(PlatformThread::CurrentId()) {
}
bool MessageLoopProxyImpl::PostDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
- return PostTaskHelper(from_here, task, delay, true);
+ DCHECK(!task.is_null()) << from_here.ToString();
+ return incoming_queue_->AddToIncomingQueue(from_here, task, delay, true);
}
bool MessageLoopProxyImpl::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
- return PostTaskHelper(from_here, task, delay, false);
+ DCHECK(!task.is_null()) << from_here.ToString();
+ return incoming_queue_->AddToIncomingQueue(from_here, task, delay, false);
}
bool MessageLoopProxyImpl::RunsTasksOnCurrentThread() const {
- // We shouldn't use MessageLoop::current() since it uses LazyInstance which
- // may be deleted by ~AtExitManager when a WorkerPool thread calls this
- // function.
- // http://crbug.com/63678
- base::ThreadRestrictions::ScopedAllowSingleton allow_singleton;
- AutoLock lock(message_loop_lock_);
- return (target_message_loop_ &&
- (MessageLoop::current() == target_message_loop_));
-}
-
-// MessageLoop::DestructionObserver implementation
-void MessageLoopProxyImpl::WillDestroyCurrentMessageLoop() {
- AutoLock lock(message_loop_lock_);
- target_message_loop_ = NULL;
+ return valid_thread_id_ == PlatformThread::CurrentId();
}
-void MessageLoopProxyImpl::OnDestruct() const {
- // We shouldn't use MessageLoop::current() since it uses LazyInstance which
- // may be deleted by ~AtExitManager when a WorkerPool thread calls this
- // function.
- // http://crbug.com/63678
- base::ThreadRestrictions::ScopedAllowSingleton allow_singleton;
- bool delete_later = false;
- {
- AutoLock lock(message_loop_lock_);
- if (target_message_loop_ &&
- (MessageLoop::current() != target_message_loop_)) {
- target_message_loop_->DeleteSoon(FROM_HERE, this);
- delete_later = true;
- }
- }
- if (!delete_later)
- delete this;
-}
-
-MessageLoopProxyImpl::MessageLoopProxyImpl()
- : target_message_loop_(MessageLoop::current()) {
+MessageLoopProxyImpl::~MessageLoopProxyImpl() {
}
-bool MessageLoopProxyImpl::PostTaskHelper(
- const tracked_objects::Location& from_here, const base::Closure& task,
- base::TimeDelta delay, bool nestable) {
- AutoLock lock(message_loop_lock_);
- if (target_message_loop_) {
- if (nestable) {
- target_message_loop_->PostDelayedTask(from_here, task, delay);
- } else {
- target_message_loop_->PostNonNestableDelayedTask(from_here, task, delay);
- }
- return true;
- }
- return false;
-}
+} // namespace internal
scoped_refptr<MessageLoopProxy>
MessageLoopProxy::current() {
« no previous file with comments | « base/message_loop/message_loop_proxy_impl.h ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698