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

Side by Side Diff: base/task.cc

Issue 7210053: Implementation of PostTaskAndReply() in MessageLoopProxy and BrowserThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« base/task.h ('K') | « base/task.h ('k') | no next file » | 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/task.h" 5 #include "base/task.h"
6 6
7 #include "base/bind.h"
8
7 Task::Task() { 9 Task::Task() {
8 } 10 }
9 11
10 Task::~Task() { 12 Task::~Task() {
11 } 13 }
12 14
13 CancelableTask::CancelableTask() { 15 CancelableTask::CancelableTask() {
14 } 16 }
15 17
16 CancelableTask::~CancelableTask() { 18 CancelableTask::~CancelableTask() {
(...skipping 10 matching lines...) Expand all
27 delete task_; 29 delete task_;
28 } 30 }
29 } 31 }
30 32
31 Task* ScopedTaskRunner::Release() { 33 Task* ScopedTaskRunner::Release() {
32 Task* tmp = task_; 34 Task* tmp = task_;
33 task_ = NULL; 35 task_ = NULL;
34 return tmp; 36 return tmp;
35 } 37 }
36 38
39 namespace internal {
40
41 PostTaskAndReplyRelay::PostTaskAndReplyRelay(const Closure& task,
42 const Closure& reply)
43 : task_(task),
44 reply_(reply),
45 origin_loop_(MessageLoop::Current()) {
46 }
47
48 PostTaskAndReplyRelay::~PostTaskAndReplyRelay() {
49 DCHECK(origin_loop_ == MessageLoop::Current());
50 }
51
52 void PostTaskAndReplyRelay::Run() {
53 task_.Run();
54 origin_loop_->PostTask(
darin (slow to review) 2011/07/01 04:15:32 what if the origin thread is already gone? i susp
willchan no longer on Chromium 2011/07/01 15:13:54 Yes, MessageLoopProxy FTW.
awong 2011/07/02 00:36:57 Done.
55 base::Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
willchan no longer on Chromium 2011/07/01 15:13:54 We're already in base::, so the prefix probably is
awong 2011/07/02 00:36:57 Done.
56 base::Unretained(this)));
57 }
58
59 void PostTaskAndReplyRelay::RunReplyAndSelfDestruct() {
60 reply_.Run();
61 delete this;
62 }
63 } // namespace internal
darin (slow to review) 2011/07/01 04:15:32 nit: add a new line above the close of the namespa
awong 2011/07/02 00:36:57 Done.
64
65
37 } // namespace base 66 } // namespace base
OLDNEW
« base/task.h ('K') | « base/task.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698