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

Side by Side Diff: base/message_loop_proxy_impl.cc

Issue 9169037: Make new TaskRunner, SequencedTaskRunner, and SingleThreadTaskRunner interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop_proxy_impl.h ('k') | base/sequenced_task_runner.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/message_loop_proxy_impl.h" 5 #include "base/message_loop_proxy_impl.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 9
10 namespace base { 10 namespace base {
11 11
12 MessageLoopProxyImpl::~MessageLoopProxyImpl() { 12 MessageLoopProxyImpl::~MessageLoopProxyImpl() {
13 } 13 }
14 14
15 bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here,
16 const base::Closure& task) {
17 return PostTaskHelper(from_here, task, 0, true);
18 }
19
20 bool MessageLoopProxyImpl::PostDelayedTask( 15 bool MessageLoopProxyImpl::PostDelayedTask(
21 const tracked_objects::Location& from_here, 16 const tracked_objects::Location& from_here,
22 const base::Closure& task, 17 const base::Closure& task,
23 int64 delay_ms) { 18 int64 delay_ms) {
24 return PostTaskHelper(from_here, task, delay_ms, true); 19 return PostTaskHelper(from_here, task, delay_ms, true);
25 } 20 }
26 21
27 bool MessageLoopProxyImpl::PostNonNestableTask(
28 const tracked_objects::Location& from_here, const base::Closure& task) {
29 return PostTaskHelper(from_here, task, 0, false);
30 }
31
32 bool MessageLoopProxyImpl::PostNonNestableDelayedTask( 22 bool MessageLoopProxyImpl::PostNonNestableDelayedTask(
33 const tracked_objects::Location& from_here, 23 const tracked_objects::Location& from_here,
34 const base::Closure& task, 24 const base::Closure& task,
35 int64 delay_ms) { 25 int64 delay_ms) {
36 return PostTaskHelper(from_here, task, delay_ms, false); 26 return PostTaskHelper(from_here, task, delay_ms, false);
37 } 27 }
38 28
39 bool MessageLoopProxyImpl::BelongsToCurrentThread() { 29 bool MessageLoopProxyImpl::RunsTasksOnCurrentThread() const {
40 // We shouldn't use MessageLoop::current() since it uses LazyInstance which 30 // We shouldn't use MessageLoop::current() since it uses LazyInstance which
41 // may be deleted by ~AtExitManager when a WorkerPool thread calls this 31 // may be deleted by ~AtExitManager when a WorkerPool thread calls this
42 // function. 32 // function.
43 // http://crbug.com/63678 33 // http://crbug.com/63678
44 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; 34 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton;
45 AutoLock lock(message_loop_lock_); 35 AutoLock lock(message_loop_lock_);
46 return (target_message_loop_ && 36 return (target_message_loop_ &&
47 (MessageLoop::current() == target_message_loop_)); 37 (MessageLoop::current() == target_message_loop_));
48 } 38 }
49 39
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 84
95 scoped_refptr<MessageLoopProxy> 85 scoped_refptr<MessageLoopProxy>
96 MessageLoopProxy::current() { 86 MessageLoopProxy::current() {
97 MessageLoop* cur_loop = MessageLoop::current(); 87 MessageLoop* cur_loop = MessageLoop::current();
98 if (!cur_loop) 88 if (!cur_loop)
99 return NULL; 89 return NULL;
100 return cur_loop->message_loop_proxy(); 90 return cur_loop->message_loop_proxy();
101 } 91 }
102 92
103 } // namespace base 93 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop_proxy_impl.h ('k') | base/sequenced_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698