| 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_CHILD_CHILD_THREAD_H_ | 5 #ifndef CONTENT_CHILD_CHILD_THREAD_H_ |
| 6 #define CONTENT_CHILD_CHILD_THREAD_H_ | 6 #define CONTENT_CHILD_CHILD_THREAD_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/power_monitor/power_monitor.h" | 14 #include "base/power_monitor/power_monitor.h" |
| 15 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/common/message_router.h" | 17 #include "content/common/message_router.h" |
| 18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
| 19 #include "webkit/child/resource_loader_bridge.h" | |
| 20 | 19 |
| 21 namespace base { | 20 namespace base { |
| 22 class MessageLoop; | 21 class MessageLoop; |
| 23 | 22 |
| 24 namespace debug { | 23 namespace debug { |
| 25 class TraceMemoryController; | 24 class TraceMemoryController; |
| 26 } // namespace debug | 25 } // namespace debug |
| 27 } // namespace base | 26 } // namespace base |
| 28 | 27 |
| 29 namespace IPC { | 28 namespace IPC { |
| 30 class SyncChannel; | 29 class SyncChannel; |
| 31 class SyncMessageFilter; | 30 class SyncMessageFilter; |
| 32 } // namespace IPC | 31 } // namespace IPC |
| 33 | 32 |
| 34 namespace blink { | 33 namespace blink { |
| 35 class WebFrame; | 34 class WebFrame; |
| 36 } // namespace blink | 35 } // namespace blink |
| 37 | 36 |
| 37 namespace webkit_glue { |
| 38 class ResourceLoaderBridge; |
| 39 } // namespace webkit_glue |
| 40 |
| 38 namespace content { | 41 namespace content { |
| 39 class ChildHistogramMessageFilter; | 42 class ChildHistogramMessageFilter; |
| 40 class ChildResourceMessageFilter; | 43 class ChildResourceMessageFilter; |
| 41 class ChildSharedBitmapManager; | 44 class ChildSharedBitmapManager; |
| 42 class FileSystemDispatcher; | 45 class FileSystemDispatcher; |
| 43 class ServiceWorkerDispatcher; | 46 class ServiceWorkerDispatcher; |
| 44 class ServiceWorkerMessageFilter; | 47 class ServiceWorkerMessageFilter; |
| 45 class QuotaDispatcher; | 48 class QuotaDispatcher; |
| 46 class QuotaMessageFilter; | 49 class QuotaMessageFilter; |
| 47 class ResourceDispatcher; | 50 class ResourceDispatcher; |
| 48 class SocketStreamDispatcher; | 51 class SocketStreamDispatcher; |
| 49 class ThreadSafeSender; | 52 class ThreadSafeSender; |
| 50 class WebSocketDispatcher; | 53 class WebSocketDispatcher; |
| 54 struct RequestInfo; |
| 51 | 55 |
| 52 // The main thread of a child process derives from this class. | 56 // The main thread of a child process derives from this class. |
| 53 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender { | 57 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender { |
| 54 public: | 58 public: |
| 55 // Creates the thread. | 59 // Creates the thread. |
| 56 ChildThread(); | 60 ChildThread(); |
| 57 // Used for single-process mode and for in process gpu mode. | 61 // Used for single-process mode and for in process gpu mode. |
| 58 explicit ChildThread(const std::string& channel_name); | 62 explicit ChildThread(const std::string& channel_name); |
| 59 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 63 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
| 60 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 64 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
| 61 // must be terminated before Shutdown returns. In particular, if a subsystem | 65 // must be terminated before Shutdown returns. In particular, if a subsystem |
| 62 // has a thread that post tasks to ChildProcess::main_thread(), that thread | 66 // has a thread that post tasks to ChildProcess::main_thread(), that thread |
| 63 // should be joined in Shutdown(). | 67 // should be joined in Shutdown(). |
| 64 virtual ~ChildThread(); | 68 virtual ~ChildThread(); |
| 65 virtual void Shutdown(); | 69 virtual void Shutdown(); |
| 66 | 70 |
| 67 // IPC::Sender implementation: | 71 // IPC::Sender implementation: |
| 68 virtual bool Send(IPC::Message* msg) OVERRIDE; | 72 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 69 | 73 |
| 70 IPC::SyncChannel* channel() { return channel_.get(); } | 74 IPC::SyncChannel* channel() { return channel_.get(); } |
| 71 | 75 |
| 72 MessageRouter* GetRouter(); | 76 MessageRouter* GetRouter(); |
| 73 | 77 |
| 74 // Creates a ResourceLoaderBridge. | 78 // Creates a ResourceLoaderBridge. |
| 75 // Tests can override this method if they want a custom loading behavior. | 79 // Tests can override this method if they want a custom loading behavior. |
| 76 virtual webkit_glue::ResourceLoaderBridge* CreateBridge( | 80 virtual webkit_glue::ResourceLoaderBridge* CreateBridge( |
| 77 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); | 81 const RequestInfo& request_info); |
| 78 | 82 |
| 79 // Allocates a block of shared memory of the given size and | 83 // Allocates a block of shared memory of the given size and |
| 80 // maps in into the address space. Returns NULL of failure. | 84 // maps in into the address space. Returns NULL of failure. |
| 81 // Note: On posix, this requires a sync IPC to the browser process, | 85 // Note: On posix, this requires a sync IPC to the browser process, |
| 82 // but on windows the child process directly allocates the block. | 86 // but on windows the child process directly allocates the block. |
| 83 base::SharedMemory* AllocateSharedMemory(size_t buf_size); | 87 base::SharedMemory* AllocateSharedMemory(size_t buf_size); |
| 84 | 88 |
| 85 // A static variant that can be called on background threads provided | 89 // A static variant that can be called on background threads provided |
| 86 // the |sender| passed in is safe to use on background threads. | 90 // the |sender| passed in is safe to use on background threads. |
| 87 static base::SharedMemory* AllocateSharedMemory(size_t buf_size, | 91 static base::SharedMemory* AllocateSharedMemory(size_t buf_size, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 scoped_ptr<base::PowerMonitor> power_monitor_; | 247 scoped_ptr<base::PowerMonitor> power_monitor_; |
| 244 | 248 |
| 245 bool in_browser_process_; | 249 bool in_browser_process_; |
| 246 | 250 |
| 247 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 251 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
| 248 }; | 252 }; |
| 249 | 253 |
| 250 } // namespace content | 254 } // namespace content |
| 251 | 255 |
| 252 #endif // CONTENT_CHILD_CHILD_THREAD_H_ | 256 #endif // CONTENT_CHILD_CHILD_THREAD_H_ |
| OLD | NEW |