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

Side by Side Diff: base/task.h

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
« no previous file with comments | « no previous file | base/task.cc » ('j') | base/task.cc » ('J')
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 #ifndef BASE_TASK_H_ 5 #ifndef BASE_TASK_H_
6 #define BASE_TASK_H_ 6 #define BASE_TASK_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_api.h" 9 #include "base/base_api.h"
10 #include "base/callback.h"
10 #include "base/debug/alias.h" 11 #include "base/debug/alias.h"
11 #include "base/memory/raw_scoped_refptr_mismatch_checker.h" 12 #include "base/memory/raw_scoped_refptr_mismatch_checker.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/tracked.h" 14 #include "base/tracked.h"
14 #include "base/tuple.h" 15 #include "base/tuple.h"
15 16
16 namespace base { 17 namespace base {
17 const size_t kDeadTask = 0xDEAD7A53; 18 const size_t kDeadTask = 0xDEAD7A53;
18 } 19 }
19 20
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 ~ScopedTaskRunner(); 558 ~ScopedTaskRunner();
558 559
559 Task* Release(); 560 Task* Release();
560 561
561 private: 562 private:
562 Task* task_; 563 Task* task_;
563 564
564 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner); 565 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner);
565 }; 566 };
566 567
568 namespace internal {
569
570 class PostTaskAndReplyRelay {
571 public:
572 PostTaskAndReplyRelay(const Closure& task, const Closure& reply);
573
574 ~PostTaskAndReplyRelay();
575
576 void Run();
577
578 private:
579 void RunReplyAndSelfDestruct();
580
581 base::Closure task_;
582 base::Closure reply_;
583 };
584 } // 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.
585
586 template <typename MessageLoopType, typename ResponseType>
darin (slow to review) 2011/07/01 04:15:32 I guess ResponseType is just a placeholder.
awong 2011/07/02 00:36:57 No...just a mistake due to rushing this CL out. Re
587 void PostTaskAndReply(MessageLoopType loop, const Closure& task,
willchan no longer on Chromium 2011/07/01 15:13:54 Why is MessageLoopType templated? Is this to make
awong 2011/07/02 00:36:57 Actually, I was trying bridge between MessageLoopP
588 const Closure& reply) {
589 PostTaskAndReplyRelay* relay = new PostTaskAndReplyRelay(task, reply);
590 loop.PostTask(&PostTaskAndReplyRelay::Run, base::Unretained(relay));
willchan no longer on Chromium 2011/07/01 15:13:54 Does this code actually work? Is there no need for
awong 2011/07/02 00:36:57 Nope...doesn't work yet. Will soon.
591 }
592
593 template <typename MessageLoopType, typename ResponseType>
594 void PostTaskAndReply<MessageLoopType, ResponseType>(
595 MessageLoopType* loop, const Closure& task, const Closure& reply) {
596 PostTaskAndReplyRelay* relay = new PostTaskAndReplyRelay(task, reply);
597 loop->PostTask(&PostTaskAndReplyRelay::Run, base::Unretained(relay));
598 }
599
567 } // namespace base 600 } // namespace base
568 601
569 #endif // BASE_TASK_H_ 602 #endif // BASE_TASK_H_
OLDNEW
« no previous file with comments | « no previous file | base/task.cc » ('j') | base/task.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698