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

Side by Side Diff: base/threading/post_task_and_reply_impl.cc

Issue 1048373003: CancelableTaskTracker::PostDelayedTask() support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary base:: 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 unified diff | Download patch
« no previous file with comments | « base/threading/post_task_and_reply_impl.h ('k') | base/threading/worker_pool.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/post_task_and_reply_impl.h" 5 #include "base/threading/post_task_and_reply_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
11 12
12 namespace base { 13 namespace base {
13 14
14 namespace { 15 namespace {
15 16
16 // This relay class remembers the MessageLoop that it was created on, and 17 // This relay class remembers the MessageLoop that it was created on, and
17 // ensures that both the |task| and |reply| Closures are deleted on this same 18 // ensures that both the |task| and |reply| Closures are deleted on this same
18 // thread. Also, |task| is guaranteed to be deleted before |reply| is run or 19 // thread. Also, |task| is guaranteed to be deleted before |reply| is run or
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 new PostTaskAndReplyRelay(from_here, task, reply); 80 new PostTaskAndReplyRelay(from_here, task, reply);
80 if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::Run, 81 if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::Run,
81 Unretained(relay)))) { 82 Unretained(relay)))) {
82 delete relay; 83 delete relay;
83 return false; 84 return false;
84 } 85 }
85 86
86 return true; 87 return true;
87 } 88 }
88 89
90 bool PostTaskAndReplyImpl::PostDelayedTaskAndReply(
91 const tracked_objects::Location& from_here,
92 const Closure& task,
93 const Closure& reply,
94 const TimeDelta& delay) {
95 PostTaskAndReplyRelay* relay =
96 new PostTaskAndReplyRelay(from_here, task, reply);
97 if (!PostDelayedTask(from_here, Bind(&PostTaskAndReplyRelay::Run,
98 Unretained(relay)), delay)) {
99 delete relay;
100 return false;
101 }
102
103 return true;
104 }
105
89 } // namespace internal 106 } // namespace internal
90 107
91 } // namespace base 108 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/post_task_and_reply_impl.h ('k') | base/threading/worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698