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

Side by Side Diff: content/child/child_thread_impl.h

Issue 977573002: content: Add an overridable task runner to ChildThreadImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test build fix. Created 5 years, 9 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 | « no previous file | content/child/child_thread_impl.cc » ('j') | content/child/child_thread_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CHILD_CHILD_THREAD_IMPL_H_ 5 #ifndef CONTENT_CHILD_CHILD_THREAD_IMPL_H_
6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // must be terminated before Shutdown returns. In particular, if a subsystem 74 // must be terminated before Shutdown returns. In particular, if a subsystem
75 // has a thread that post tasks to ChildProcess::main_thread(), that thread 75 // has a thread that post tasks to ChildProcess::main_thread(), that thread
76 // should be joined in Shutdown(). 76 // should be joined in Shutdown().
77 ~ChildThreadImpl() override; 77 ~ChildThreadImpl() override;
78 virtual void Shutdown(); 78 virtual void Shutdown();
79 79
80 // IPC::Sender implementation: 80 // IPC::Sender implementation:
81 bool Send(IPC::Message* msg) override; 81 bool Send(IPC::Message* msg) override;
82 82
83 // ChildThread implementation: 83 // ChildThread implementation:
84 // Returns the task runner which should be used to post tasks to run on this
85 // child thread. Note that this may be different from the underlying message
86 // loop returned by message_loop(). For this reason, only use message_loop()
87 // if you need to directly manipulate the underlying message loop, e.g., by
88 // adding a task listener instead of just posting tasks for execution.
89 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override;
84 #if defined(OS_WIN) 90 #if defined(OS_WIN)
85 void PreCacheFont(const LOGFONT& log_font) override; 91 void PreCacheFont(const LOGFONT& log_font) override;
86 void ReleaseCachedFonts() override; 92 void ReleaseCachedFonts() override;
87 #endif 93 #endif
88 94
89 IPC::SyncChannel* channel() { return channel_.get(); } 95 IPC::SyncChannel* channel() { return channel_.get(); }
90 96
91 MessageRouter* GetRouter(); 97 MessageRouter* GetRouter();
92 98
93 // Allocates a block of shared memory of the given size. Returns NULL on 99 // Allocates a block of shared memory of the given size. Returns NULL on
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 165 }
160 166
161 QuotaMessageFilter* quota_message_filter() const { 167 QuotaMessageFilter* quota_message_filter() const {
162 return quota_message_filter_.get(); 168 return quota_message_filter_.get();
163 } 169 }
164 170
165 ChildResourceMessageFilter* child_resource_message_filter() const { 171 ChildResourceMessageFilter* child_resource_message_filter() const {
166 return resource_message_filter_.get(); 172 return resource_message_filter_.get();
167 } 173 }
168 174
175 // See note in GetTaskRunner().
169 base::MessageLoop* message_loop() const { return message_loop_; } 176 base::MessageLoop* message_loop() const { return message_loop_; }
170 177
171 // Returns the one child thread. Can only be called on the main thread. 178 // Returns the one child thread. Can only be called on the main thread.
172 static ChildThreadImpl* current(); 179 static ChildThreadImpl* current();
173 180
174 #if defined(OS_ANDROID) 181 #if defined(OS_ANDROID)
175 // Called on Android's service thread to shutdown the main thread of this 182 // Called on Android's service thread to shutdown the main thread of this
176 // process. 183 // process.
177 static void ShutdownThread(); 184 static void ShutdownThread();
178 #endif 185 #endif
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Handles resource loads for this process. 263 // Handles resource loads for this process.
257 scoped_ptr<ResourceDispatcher> resource_dispatcher_; 264 scoped_ptr<ResourceDispatcher> resource_dispatcher_;
258 265
259 scoped_ptr<WebSocketDispatcher> websocket_dispatcher_; 266 scoped_ptr<WebSocketDispatcher> websocket_dispatcher_;
260 267
261 // The OnChannelError() callback was invoked - the channel is dead, don't 268 // The OnChannelError() callback was invoked - the channel is dead, don't
262 // attempt to communicate. 269 // attempt to communicate.
263 bool on_channel_error_called_; 270 bool on_channel_error_called_;
264 271
265 base::MessageLoop* message_loop_; 272 base::MessageLoop* message_loop_;
273 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
266 274
267 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; 275 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_;
268 276
269 scoped_ptr<QuotaDispatcher> quota_dispatcher_; 277 scoped_ptr<QuotaDispatcher> quota_dispatcher_;
270 278
271 scoped_refptr<ChildHistogramMessageFilter> histogram_message_filter_; 279 scoped_refptr<ChildHistogramMessageFilter> histogram_message_filter_;
272 280
273 scoped_refptr<ChildResourceMessageFilter> resource_message_filter_; 281 scoped_refptr<ChildResourceMessageFilter> resource_message_filter_;
274 282
275 scoped_refptr<ServiceWorkerMessageFilter> service_worker_message_filter_; 283 scoped_refptr<ServiceWorkerMessageFilter> service_worker_message_filter_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 315
308 struct ChildThreadImpl::Options { 316 struct ChildThreadImpl::Options {
309 ~Options(); 317 ~Options();
310 318
311 class Builder; 319 class Builder;
312 320
313 std::string channel_name; 321 std::string channel_name;
314 bool use_mojo_channel; 322 bool use_mojo_channel;
315 bool in_browser_process; 323 bool in_browser_process;
316 std::vector<IPC::MessageFilter*> startup_filters; 324 std::vector<IPC::MessageFilter*> startup_filters;
325 scoped_refptr<base::SingleThreadTaskRunner> task_runner;
317 326
318 private: 327 private:
319 Options(); 328 Options();
320 }; 329 };
321 330
322 class ChildThreadImpl::Options::Builder { 331 class ChildThreadImpl::Options::Builder {
323 public: 332 public:
324 Builder(); 333 Builder();
325 334
326 Builder& InBrowserProcess(bool in_browser_process); 335 Builder& InBrowserProcess(bool in_browser_process);
327 Builder& UseMojoChannel(bool use_mojo_channel); 336 Builder& UseMojoChannel(bool use_mojo_channel);
328 Builder& WithChannelName(const std::string& channel_name); 337 Builder& WithChannelName(const std::string& channel_name);
329 Builder& AddStartupFilter(IPC::MessageFilter* filter); 338 Builder& AddStartupFilter(IPC::MessageFilter* filter);
339 Builder& WithTaskRunner(
340 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
330 341
331 Options Build(); 342 Options Build();
332 343
333 private: 344 private:
334 struct Options options_; 345 struct Options options_;
335 346
336 DISALLOW_COPY_AND_ASSIGN(Builder); 347 DISALLOW_COPY_AND_ASSIGN(Builder);
337 }; 348 };
338 349
339 } // namespace content 350 } // namespace content
340 351
341 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 352 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/child_thread_impl.cc » ('j') | content/child/child_thread_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698