| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_COMMON_CHILD_THREAD_H_ | 5 #ifndef CHROME_COMMON_CHILD_THREAD_H_ |
| 6 #define CHROME_COMMON_CHILD_THREAD_H_ | 6 #define CHROME_COMMON_CHILD_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/thread.h" | 8 #include "base/thread.h" |
| 9 #include "chrome/common/ipc_sync_channel.h" | 9 #include "chrome/common/ipc_sync_channel.h" |
| 10 #include "chrome/common/message_router.h" | 10 #include "chrome/common/message_router.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 void SetChannelName(const std::wstring& name) { channel_name_ = name; } | 37 void SetChannelName(const std::wstring& name) { channel_name_ = name; } |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 virtual void OnControlMessageReceived(const IPC::Message& msg) { } | 40 virtual void OnControlMessageReceived(const IPC::Message& msg) { } |
| 41 | 41 |
| 42 // Returns the one child thread. | 42 // Returns the one child thread. |
| 43 static ChildThread* current(); | 43 static ChildThread* current(); |
| 44 | 44 |
| 45 IPC::SyncChannel* channel() { return channel_.get(); } | 45 IPC::SyncChannel* channel() { return channel_.get(); } |
| 46 | 46 |
| 47 // Indicates if ChildThread::Send() is on the call stack. | |
| 48 virtual bool InSend() const { return in_send_ != 0; } | |
| 49 | |
| 50 // Thread implementation. | 47 // Thread implementation. |
| 51 virtual void Init(); | 48 virtual void Init(); |
| 52 virtual void CleanUp(); | 49 virtual void CleanUp(); |
| 53 | 50 |
| 54 private: | 51 private: |
| 55 // IPC::Channel::Listener implementation: | 52 // IPC::Channel::Listener implementation: |
| 56 virtual void OnMessageReceived(const IPC::Message& msg); | 53 virtual void OnMessageReceived(const IPC::Message& msg); |
| 57 virtual void OnChannelError(); | 54 virtual void OnChannelError(); |
| 58 | 55 |
| 59 // The message loop used to run tasks on the thread that started this thread. | 56 // The message loop used to run tasks on the thread that started this thread. |
| 60 MessageLoop* owner_loop_; | 57 MessageLoop* owner_loop_; |
| 61 | 58 |
| 62 std::wstring channel_name_; | 59 std::wstring channel_name_; |
| 63 scoped_ptr<IPC::SyncChannel> channel_; | 60 scoped_ptr<IPC::SyncChannel> channel_; |
| 64 | 61 |
| 65 // Used only on the background render thread to implement message routing | 62 // Used only on the background render thread to implement message routing |
| 66 // functionality to the consumers of the ChildThread. | 63 // functionality to the consumers of the ChildThread. |
| 67 MessageRouter router_; | 64 MessageRouter router_; |
| 68 | 65 |
| 69 int in_send_; | |
| 70 | |
| 71 Thread::Options options_; | 66 Thread::Options options_; |
| 72 | 67 |
| 73 DISALLOW_EVIL_CONSTRUCTORS(ChildThread); | 68 DISALLOW_EVIL_CONSTRUCTORS(ChildThread); |
| 74 }; | 69 }; |
| 75 | 70 |
| 76 #endif // CHROME_COMMON_CHILD_THREAD_H_ | 71 #endif // CHROME_COMMON_CHILD_THREAD_H_ |
| OLD | NEW |