OLD | NEW |
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 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
| 15 #include "base/task_runner_util.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
17 | 18 |
18 #if defined(UNIT_TEST) | 19 #if defined(UNIT_TEST) |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #endif // UNIT_TEST | 21 #endif // UNIT_TEST |
21 | 22 |
22 class MessageLoop; | 23 class MessageLoop; |
23 | 24 |
24 namespace base { | 25 namespace base { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 const tracked_objects::Location& from_here, | 128 const tracked_objects::Location& from_here, |
128 const base::Closure& task, | 129 const base::Closure& task, |
129 base::TimeDelta delay); | 130 base::TimeDelta delay); |
130 | 131 |
131 static bool PostTaskAndReply( | 132 static bool PostTaskAndReply( |
132 ID identifier, | 133 ID identifier, |
133 const tracked_objects::Location& from_here, | 134 const tracked_objects::Location& from_here, |
134 const base::Closure& task, | 135 const base::Closure& task, |
135 const base::Closure& reply); | 136 const base::Closure& reply); |
136 | 137 |
| 138 template <typename ReturnType> |
| 139 static bool PostTaskAndReplyWithResult( |
| 140 ID identifier, |
| 141 const tracked_objects::Location& from_here, |
| 142 const base::Callback<ReturnType(void)>& task, |
| 143 const base::Callback<void(ReturnType)>& reply) { |
| 144 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = |
| 145 GetMessageLoopProxyForThread(identifier); |
| 146 return base::PostTaskAndReplyWithResult<ReturnType>( |
| 147 message_loop_proxy.get(), from_here, task, reply); |
| 148 } |
| 149 |
137 template <class T> | 150 template <class T> |
138 static bool DeleteSoon(ID identifier, | 151 static bool DeleteSoon(ID identifier, |
139 const tracked_objects::Location& from_here, | 152 const tracked_objects::Location& from_here, |
140 const T* object) { | 153 const T* object) { |
141 return GetMessageLoopProxyForThread(identifier)->DeleteSoon( | 154 return GetMessageLoopProxyForThread(identifier)->DeleteSoon( |
142 from_here, object); | 155 from_here, object); |
143 } | 156 } |
144 | 157 |
145 template <class T> | 158 template <class T> |
146 static bool ReleaseSoon(ID identifier, | 159 static bool ReleaseSoon(ID identifier, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 private: | 283 private: |
271 friend class BrowserThreadImpl; | 284 friend class BrowserThreadImpl; |
272 | 285 |
273 BrowserThread() {} | 286 BrowserThread() {} |
274 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 287 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
275 }; | 288 }; |
276 | 289 |
277 } // namespace content | 290 } // namespace content |
278 | 291 |
279 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 292 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
OLD | NEW |