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_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 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
10 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
11 #include "base/tracked_objects.h" | 12 #include "base/tracked_objects.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 "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 15 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
15 #include "webkit/glue/resource_loader_bridge.h" | 16 #include "webkit/glue/resource_loader_bridge.h" |
16 | 17 |
17 class FileSystemDispatcher; | 18 class FileSystemDispatcher; |
18 class MessageLoop; | 19 class MessageLoop; |
19 class QuotaDispatcher; | 20 class QuotaDispatcher; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 94 |
94 virtual bool IsWebFrameValid(WebKit::WebFrame* frame); | 95 virtual bool IsWebFrameValid(WebKit::WebFrame* frame); |
95 | 96 |
96 protected: | 97 protected: |
97 friend class ChildProcess; | 98 friend class ChildProcess; |
98 | 99 |
99 // Called when the process refcount is 0. | 100 // Called when the process refcount is 0. |
100 void OnProcessFinalRelease(); | 101 void OnProcessFinalRelease(); |
101 | 102 |
102 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 103 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
103 virtual void OnShutdown(); | |
104 | |
105 #ifdef IPC_MESSAGE_LOG_ENABLED | |
106 virtual void OnSetIPCLoggingEnabled(bool enable); | |
107 #endif | |
108 | |
109 virtual void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); | |
110 virtual void OnGetChildProfilerData(int sequence_number); | |
111 | |
112 virtual void OnDumpHandles(); | |
113 | 104 |
114 void set_on_channel_error_called(bool on_channel_error_called) { | 105 void set_on_channel_error_called(bool on_channel_error_called) { |
115 on_channel_error_called_ = on_channel_error_called; | 106 on_channel_error_called_ = on_channel_error_called; |
116 } | 107 } |
117 | 108 |
118 // IPC::Listener implementation: | 109 // IPC::Listener implementation: |
119 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 110 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
120 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 111 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
121 virtual void OnChannelError() OVERRIDE; | 112 virtual void OnChannelError() OVERRIDE; |
122 | 113 |
123 private: | 114 private: |
124 void Init(); | 115 void Init(); |
125 | 116 |
| 117 // IPC message handlers. |
| 118 void OnShutdown(); |
| 119 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); |
| 120 void OnGetChildProfilerData(int sequence_number); |
| 121 void OnDumpHandles(); |
| 122 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 123 void OnSetIPCLoggingEnabled(bool enable); |
| 124 #endif |
126 #if defined(USE_TCMALLOC) | 125 #if defined(USE_TCMALLOC) |
127 void OnGetTcmallocStats(); | 126 void OnGetTcmallocStats(); |
128 #endif | 127 #endif |
129 | 128 |
| 129 void EnsureConnected(); |
| 130 |
130 std::string channel_name_; | 131 std::string channel_name_; |
131 scoped_ptr<IPC::SyncChannel> channel_; | 132 scoped_ptr<IPC::SyncChannel> channel_; |
132 | 133 |
133 // Allows threads other than the main thread to send sync messages. | 134 // Allows threads other than the main thread to send sync messages. |
134 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; | 135 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; |
135 | 136 |
136 // Implements message routing functionality to the consumers of ChildThread. | 137 // Implements message routing functionality to the consumers of ChildThread. |
137 MessageRouter router_; | 138 MessageRouter router_; |
138 | 139 |
139 // Handles resource loads for this process. | 140 // Handles resource loads for this process. |
140 scoped_ptr<content::ResourceDispatcher> resource_dispatcher_; | 141 scoped_ptr<content::ResourceDispatcher> resource_dispatcher_; |
141 | 142 |
142 // Handles SocketStream for this process. | 143 // Handles SocketStream for this process. |
143 scoped_ptr<SocketStreamDispatcher> socket_stream_dispatcher_; | 144 scoped_ptr<SocketStreamDispatcher> socket_stream_dispatcher_; |
144 | 145 |
145 // The OnChannelError() callback was invoked - the channel is dead, don't | 146 // The OnChannelError() callback was invoked - the channel is dead, don't |
146 // attempt to communicate. | 147 // attempt to communicate. |
147 bool on_channel_error_called_; | 148 bool on_channel_error_called_; |
148 | 149 |
149 MessageLoop* message_loop_; | 150 MessageLoop* message_loop_; |
150 | 151 |
151 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; | 152 scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; |
152 | 153 |
153 scoped_ptr<QuotaDispatcher> quota_dispatcher_; | 154 scoped_ptr<QuotaDispatcher> quota_dispatcher_; |
154 | 155 |
155 scoped_refptr<content::ChildHistogramMessageFilter> histogram_message_filter_; | 156 scoped_refptr<content::ChildHistogramMessageFilter> histogram_message_filter_; |
156 | 157 |
| 158 base::WeakPtrFactory<ChildThread> channel_connected_factory_; |
| 159 |
157 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 160 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
158 }; | 161 }; |
159 | 162 |
160 #endif // CONTENT_COMMON_CHILD_THREAD_H_ | 163 #endif // CONTENT_COMMON_CHILD_THREAD_H_ |
OLD | NEW |