Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 CONTENT_COMMON_CHILD_THREAD_H_ | 5 #ifndef CONTENT_COMMON_CHILD_THREAD_H_ |
| 6 #define CONTENT_COMMON_CHILD_THREAD_H_ | 6 #define CONTENT_COMMON_CHILD_THREAD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/common/message_router.h" | 13 #include "content/common/message_router.h" |
| 14 #include "webkit/glue/resource_loader_bridge.h" | 14 #include "webkit/glue/resource_loader_bridge.h" |
| 15 | 15 |
| 16 class FileSystemDispatcher; | 16 class FileSystemDispatcher; |
| 17 class MessageLoop; | 17 class MessageLoop; |
| 18 class QuotaDispatcher; | 18 class QuotaDispatcher; |
| 19 class ResourceDispatcher; | 19 class ResourceDispatcher; |
| 20 class SocketStreamDispatcher; | 20 class SocketStreamDispatcher; |
| 21 class WorkerTaskRunner; | |
| 21 | 22 |
| 22 namespace IPC { | 23 namespace IPC { |
| 23 class SyncChannel; | 24 class SyncChannel; |
| 24 class SyncMessageFilter; | 25 class SyncMessageFilter; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // The main thread of a child process derives from this class. | 28 // The main thread of a child process derives from this class. |
| 28 class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, | 29 class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, |
| 29 public IPC::Message::Sender { | 30 public IPC::Message::Sender { |
| 30 public: | 31 public: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 73 |
| 73 // Safe to call on any thread, as long as it's guaranteed that the thread's | 74 // Safe to call on any thread, as long as it's guaranteed that the thread's |
| 74 // lifetime is less than the main thread. | 75 // lifetime is less than the main thread. |
| 75 IPC::SyncMessageFilter* sync_message_filter(); | 76 IPC::SyncMessageFilter* sync_message_filter(); |
| 76 | 77 |
| 77 MessageLoop* message_loop(); | 78 MessageLoop* message_loop(); |
| 78 | 79 |
| 79 // Returns the one child thread. | 80 // Returns the one child thread. |
| 80 static ChildThread* current(); | 81 static ChildThread* current(); |
| 81 | 82 |
| 83 WorkerTaskRunner* worker_task_runner() const; | |
| 84 | |
| 82 protected: | 85 protected: |
| 83 friend class ChildProcess; | 86 friend class ChildProcess; |
| 84 | 87 |
| 85 // Called when the process refcount is 0. | 88 // Called when the process refcount is 0. |
| 86 void OnProcessFinalRelease(); | 89 void OnProcessFinalRelease(); |
| 87 | 90 |
| 88 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 91 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 89 virtual void OnAskBeforeShutdown(); | 92 virtual void OnAskBeforeShutdown(); |
| 90 virtual void OnShutdown(); | 93 virtual void OnShutdown(); |
| 91 | 94 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // The OnChannelError() callback was invoked - the channel is dead, don't | 136 // The OnChannelError() callback was invoked - the channel is dead, don't |
| 134 // attempt to communicate. | 137 // attempt to communicate. |
| 135 bool on_channel_error_called_; | 138 bool on_channel_error_called_; |
| 136 | 139 |
| 137 MessageLoop* message_loop_; | 140 MessageLoop* message_loop_; |
| 138 | 141 |
| 139 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; | 142 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; |
| 140 | 143 |
| 141 scoped_ptr<QuotaDispatcher> quota_dispatcher_; | 144 scoped_ptr<QuotaDispatcher> quota_dispatcher_; |
| 142 | 145 |
| 146 scoped_refptr<WorkerTaskRunner> worker_task_runner_; | |
|
michaeln
2011/12/05 22:02:09
Would a leaky lazy instance be a safer/better choi
dgrogan
2011/12/06 00:15:15
Not having to worry about the lifetime would be ni
| |
| 147 | |
| 143 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 148 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
| 144 }; | 149 }; |
| 145 | 150 |
| 146 #endif // CONTENT_COMMON_CHILD_THREAD_H_ | 151 #endif // CONTENT_COMMON_CHILD_THREAD_H_ |
| OLD | NEW |