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/lazy_instance.h" | |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "content/common/message_router.h" | 14 #include "content/common/message_router.h" |
| 14 #include "webkit/glue/resource_loader_bridge.h" | 15 #include "webkit/glue/resource_loader_bridge.h" |
| 15 | 16 |
| 16 class FileSystemDispatcher; | 17 class FileSystemDispatcher; |
| 17 class MessageLoop; | 18 class MessageLoop; |
| 18 class QuotaDispatcher; | 19 class QuotaDispatcher; |
| 19 class ResourceDispatcher; | 20 class ResourceDispatcher; |
| 20 class SocketStreamDispatcher; | 21 class SocketStreamDispatcher; |
| 22 class WorkerTaskRunner; | |
| 21 | 23 |
| 22 namespace IPC { | 24 namespace IPC { |
| 23 class SyncChannel; | 25 class SyncChannel; |
| 24 class SyncMessageFilter; | 26 class SyncMessageFilter; |
| 25 } | 27 } |
| 26 | 28 |
| 27 // The main thread of a child process derives from this class. | 29 // The main thread of a child process derives from this class. |
| 28 class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, | 30 class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, |
| 29 public IPC::Message::Sender { | 31 public IPC::Message::Sender { |
| 30 public: | 32 public: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 74 |
| 73 // Safe to call on any thread, as long as it's guaranteed that the thread's | 75 // Safe to call on any thread, as long as it's guaranteed that the thread's |
| 74 // lifetime is less than the main thread. | 76 // lifetime is less than the main thread. |
| 75 IPC::SyncMessageFilter* sync_message_filter(); | 77 IPC::SyncMessageFilter* sync_message_filter(); |
| 76 | 78 |
| 77 MessageLoop* message_loop(); | 79 MessageLoop* message_loop(); |
| 78 | 80 |
| 79 // Returns the one child thread. | 81 // Returns the one child thread. |
| 80 static ChildThread* current(); | 82 static ChildThread* current(); |
| 81 | 83 |
| 84 WorkerTaskRunner* worker_task_runner() const; | |
| 85 | |
| 82 protected: | 86 protected: |
| 83 friend class ChildProcess; | 87 friend class ChildProcess; |
| 84 | 88 |
| 85 // Called when the process refcount is 0. | 89 // Called when the process refcount is 0. |
| 86 void OnProcessFinalRelease(); | 90 void OnProcessFinalRelease(); |
| 87 | 91 |
| 88 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 92 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 89 virtual void OnAskBeforeShutdown(); | 93 virtual void OnAskBeforeShutdown(); |
| 90 virtual void OnShutdown(); | 94 virtual void OnShutdown(); |
| 91 | 95 |
| (...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 | 137 // The OnChannelError() callback was invoked - the channel is dead, don't |
| 134 // attempt to communicate. | 138 // attempt to communicate. |
| 135 bool on_channel_error_called_; | 139 bool on_channel_error_called_; |
| 136 | 140 |
| 137 MessageLoop* message_loop_; | 141 MessageLoop* message_loop_; |
| 138 | 142 |
| 139 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; | 143 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; |
| 140 | 144 |
| 141 scoped_ptr<QuotaDispatcher> quota_dispatcher_; | 145 scoped_ptr<QuotaDispatcher> quota_dispatcher_; |
| 142 | 146 |
| 147 static base::LazyInstance<WorkerTaskRunner, | |
|
dgrogan
2011/12/07 22:47:39
I don't think this needs to be static, but LazyIns
michaeln
2011/12/07 23:57:38
LazyInstances are pretty much always static. They'
| |
| 148 base::LeakyLazyInstanceTraits<WorkerTaskRunner> > | |
| 149 worker_task_runner_; | |
| 150 | |
| 143 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 151 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
| 144 }; | 152 }; |
| 145 | 153 |
| 146 #endif // CONTENT_COMMON_CHILD_THREAD_H_ | 154 #endif // CONTENT_COMMON_CHILD_THREAD_H_ |
| OLD | NEW |