| 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" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 // Creates the thread. | 67 // Creates the thread. |
| 68 ChildThread(); | 68 ChildThread(); |
| 69 // Used for single-process mode and for in process gpu mode. | 69 // Used for single-process mode and for in process gpu mode. |
| 70 explicit ChildThread(const Options& options); | 70 explicit ChildThread(const Options& options); |
| 71 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 71 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
| 72 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 72 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
| 73 // must be terminated before Shutdown returns. In particular, if a subsystem | 73 // must be terminated before Shutdown returns. In particular, if a subsystem |
| 74 // has a thread that post tasks to ChildProcess::main_thread(), that thread | 74 // has a thread that post tasks to ChildProcess::main_thread(), that thread |
| 75 // should be joined in Shutdown(). | 75 // should be joined in Shutdown(). |
| 76 virtual ~ChildThread(); | 76 ~ChildThread() override; |
| 77 virtual void Shutdown(); | 77 virtual void Shutdown(); |
| 78 | 78 |
| 79 // IPC::Sender implementation: | 79 // IPC::Sender implementation: |
| 80 virtual bool Send(IPC::Message* msg) override; | 80 bool Send(IPC::Message* msg) override; |
| 81 | 81 |
| 82 IPC::SyncChannel* channel() { return channel_.get(); } | 82 IPC::SyncChannel* channel() { return channel_.get(); } |
| 83 | 83 |
| 84 MessageRouter* GetRouter(); | 84 MessageRouter* GetRouter(); |
| 85 | 85 |
| 86 // Allocates a block of shared memory of the given size and | 86 // Allocates a block of shared memory of the given size and |
| 87 // maps in into the address space. Returns NULL of failure. | 87 // maps in into the address space. Returns NULL of failure. |
| 88 // Note: On posix, this requires a sync IPC to the browser process, | 88 // Note: On posix, this requires a sync IPC to the browser process, |
| 89 // but on windows the child process directly allocates the block. | 89 // but on windows the child process directly allocates the block. |
| 90 base::SharedMemory* AllocateSharedMemory(size_t buf_size); | 90 base::SharedMemory* AllocateSharedMemory(size_t buf_size); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // Called when the process refcount is 0. | 166 // Called when the process refcount is 0. |
| 167 void OnProcessFinalRelease(); | 167 void OnProcessFinalRelease(); |
| 168 | 168 |
| 169 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 169 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 170 | 170 |
| 171 void set_on_channel_error_called(bool on_channel_error_called) { | 171 void set_on_channel_error_called(bool on_channel_error_called) { |
| 172 on_channel_error_called_ = on_channel_error_called; | 172 on_channel_error_called_ = on_channel_error_called; |
| 173 } | 173 } |
| 174 | 174 |
| 175 // IPC::Listener implementation: | 175 // IPC::Listener implementation: |
| 176 virtual bool OnMessageReceived(const IPC::Message& msg) override; | 176 bool OnMessageReceived(const IPC::Message& msg) override; |
| 177 virtual void OnChannelConnected(int32 peer_pid) override; | 177 void OnChannelConnected(int32 peer_pid) override; |
| 178 virtual void OnChannelError() override; | 178 void OnChannelError() override; |
| 179 | 179 |
| 180 private: | 180 private: |
| 181 class ChildThreadMessageRouter : public MessageRouter { | 181 class ChildThreadMessageRouter : public MessageRouter { |
| 182 public: | 182 public: |
| 183 // |sender| must outlive this object. | 183 // |sender| must outlive this object. |
| 184 explicit ChildThreadMessageRouter(IPC::Sender* sender); | 184 explicit ChildThreadMessageRouter(IPC::Sender* sender); |
| 185 virtual bool Send(IPC::Message* msg) override; | 185 bool Send(IPC::Message* msg) override; |
| 186 | 186 |
| 187 private: | 187 private: |
| 188 IPC::Sender* const sender_; | 188 IPC::Sender* const sender_; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 void Init(const Options& options); | 191 void Init(const Options& options); |
| 192 scoped_ptr<IPC::SyncChannel> CreateChannel(bool use_mojo_channel); | 192 scoped_ptr<IPC::SyncChannel> CreateChannel(bool use_mojo_channel); |
| 193 | 193 |
| 194 // IPC message handlers. | 194 // IPC message handlers. |
| 195 void OnShutdown(); | 195 void OnShutdown(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 bool in_browser_process_; | 260 bool in_browser_process_; |
| 261 | 261 |
| 262 base::WeakPtrFactory<ChildThread> channel_connected_factory_; | 262 base::WeakPtrFactory<ChildThread> channel_connected_factory_; |
| 263 | 263 |
| 264 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 264 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 } // namespace content | 267 } // namespace content |
| 268 | 268 |
| 269 #endif // CONTENT_CHILD_CHILD_THREAD_H_ | 269 #endif // CONTENT_CHILD_CHILD_THREAD_H_ |
| OLD | NEW |