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/message_loop_proxy.h

Issue 7210053: Implementation of PostTaskAndReply() in MessageLoopProxy and BrowserThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unittests Created 9 years, 4 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/message_loop_proxy.cc » ('j') | base/task_unittest.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_MESSAGE_LOOP_PROXY_H_ 5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_
6 #define BASE_MESSAGE_LOOP_PROXY_H_ 6 #define BASE_MESSAGE_LOOP_PROXY_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_export.h" 9 #include "base/base_export.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const base::Closure& task) = 0; 60 const base::Closure& task) = 0;
61 virtual bool PostNonNestableDelayedTask( 61 virtual bool PostNonNestableDelayedTask(
62 const tracked_objects::Location& from_here, 62 const tracked_objects::Location& from_here,
63 const base::Closure& task, 63 const base::Closure& task,
64 int64 delay_ms) = 0; 64 int64 delay_ms) = 0;
65 65
66 // A method which checks if the caller is currently running in the thread that 66 // A method which checks if the caller is currently running in the thread that
67 // this proxy represents. 67 // this proxy represents.
68 virtual bool BelongsToCurrentThread() = 0; 68 virtual bool BelongsToCurrentThread() = 0;
69 69
70 // Executes |task| on the given MessageLoopProxy. On completion, |reply|
71 // is passed back to the MessageLoopProxy for the thread that called
72 // PostTaskAndReply().
73 //
74 // Both |task| and |reply| are guaranteed to be deleted on the thread from
75 // which PostTaskAndReply() is invoked.
76 //
77 // This simplifies logic when an operation needs to be executed on another
78 // thread, but processing of the result needs to occur on the current thread.
79 //
80 // Note that because of the lifetime guarantees on the |reply| Closure, it is
81 // perfectly valid to use a WeakPtr<> in the bound parameters for |reply|.
82 // This is useful if |reply| needs to be canceled on the originating thread
83 // while |task| may still be executing.
84 bool PostTaskAndReply(const tracked_objects::Location& from_here,
85 const Closure& task,
86 const Closure& reply);
87
70 template <class T> 88 template <class T>
71 bool DeleteSoon(const tracked_objects::Location& from_here, 89 bool DeleteSoon(const tracked_objects::Location& from_here,
72 T* object) { 90 T* object) {
73 return PostNonNestableTask(from_here, new DeleteTask<T>(object)); 91 return PostNonNestableTask(from_here, new DeleteTask<T>(object));
74 } 92 }
75 template <class T> 93 template <class T>
76 bool ReleaseSoon(const tracked_objects::Location& from_here, 94 bool ReleaseSoon(const tracked_objects::Location& from_here,
77 T* object) { 95 T* object) {
78 return PostNonNestableTask(from_here, new ReleaseTask<T>(object)); 96 return PostNonNestableTask(from_here, new ReleaseTask<T>(object));
79 } 97 }
(...skipping 16 matching lines...) Expand all
96 114
97 struct MessageLoopProxyTraits { 115 struct MessageLoopProxyTraits {
98 static void Destruct(const MessageLoopProxy* proxy) { 116 static void Destruct(const MessageLoopProxy* proxy) {
99 proxy->OnDestruct(); 117 proxy->OnDestruct();
100 } 118 }
101 }; 119 };
102 120
103 } // namespace base 121 } // namespace base
104 122
105 #endif // BASE_MESSAGE_LOOP_PROXY_H_ 123 #endif // BASE_MESSAGE_LOOP_PROXY_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop_proxy.cc » ('j') | base/task_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698