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 #include "content/common/child_thread.h" | 5 #include "content/common/child_thread.h" |
6 | 6 |
7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ipc/ipc_logging.h" | 23 #include "ipc/ipc_logging.h" |
24 #include "ipc/ipc_switches.h" | 24 #include "ipc/ipc_switches.h" |
25 #include "ipc/ipc_sync_channel.h" | 25 #include "ipc/ipc_sync_channel.h" |
26 #include "ipc/ipc_sync_message_filter.h" | 26 #include "ipc/ipc_sync_message_filter.h" |
27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
28 | 28 |
29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
30 #include "content/common/handle_enumerator_win.h" | 30 #include "content/common/handle_enumerator_win.h" |
31 #endif | 31 #endif |
32 | 32 |
33 using content::ResourceDispatcher; | |
34 using tracked_objects::ThreadData; | 33 using tracked_objects::ThreadData; |
35 | 34 |
| 35 namespace content { |
36 namespace { | 36 namespace { |
37 | 37 |
38 // How long to wait for a connection to the browser process before giving up. | 38 // How long to wait for a connection to the browser process before giving up. |
39 const int kConnectionTimeoutS = 15; | 39 const int kConnectionTimeoutS = 15; |
40 | 40 |
41 // This isn't needed on Windows because there the sandbox's job object | 41 // This isn't needed on Windows because there the sandbox's job object |
42 // terminates child processes automatically. For unsandboxed processes (i.e. | 42 // terminates child processes automatically. For unsandboxed processes (i.e. |
43 // plugins), PluginThread has EnsureTerminateMessageFilter. | 43 // plugins), PluginThread has EnsureTerminateMessageFilter. |
44 #if defined(OS_POSIX) | 44 #if defined(OS_POSIX) |
45 | 45 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 IPC::Logging::GetInstance()->SetIPCSender(this); | 104 IPC::Logging::GetInstance()->SetIPCSender(this); |
105 #endif | 105 #endif |
106 | 106 |
107 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 107 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
108 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 108 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
109 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 109 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
110 quota_dispatcher_.reset(new QuotaDispatcher()); | 110 quota_dispatcher_.reset(new QuotaDispatcher()); |
111 | 111 |
112 sync_message_filter_ = | 112 sync_message_filter_ = |
113 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); | 113 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); |
114 histogram_message_filter_ = new content::ChildHistogramMessageFilter(); | 114 histogram_message_filter_ = new ChildHistogramMessageFilter(); |
115 | 115 |
116 channel_->AddFilter(histogram_message_filter_.get()); | 116 channel_->AddFilter(histogram_message_filter_.get()); |
117 channel_->AddFilter(sync_message_filter_.get()); | 117 channel_->AddFilter(sync_message_filter_.get()); |
118 channel_->AddFilter(new ChildTraceMessageFilter()); | 118 channel_->AddFilter(new ChildTraceMessageFilter()); |
119 | 119 |
120 #if defined(OS_POSIX) | 120 #if defined(OS_POSIX) |
121 // Check that --process-type is specified so we don't do this in unit tests | 121 // Check that --process-type is specified so we don't do this in unit tests |
122 // and single-process mode. | 122 // and single-process mode. |
123 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 123 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
124 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 124 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 void ChildThread::OnGetChildProfilerData(int sequence_number) { | 299 void ChildThread::OnGetChildProfilerData(int sequence_number) { |
300 tracked_objects::ProcessDataSnapshot process_data; | 300 tracked_objects::ProcessDataSnapshot process_data; |
301 ThreadData::Snapshot(false, &process_data); | 301 ThreadData::Snapshot(false, &process_data); |
302 | 302 |
303 Send(new ChildProcessHostMsg_ChildProfilerData(sequence_number, | 303 Send(new ChildProcessHostMsg_ChildProfilerData(sequence_number, |
304 process_data)); | 304 process_data)); |
305 } | 305 } |
306 | 306 |
307 void ChildThread::OnDumpHandles() { | 307 void ChildThread::OnDumpHandles() { |
308 #if defined(OS_WIN) | 308 #if defined(OS_WIN) |
309 scoped_refptr<content::HandleEnumerator> handle_enum( | 309 scoped_refptr<HandleEnumerator> handle_enum( |
310 new content::HandleEnumerator( | 310 new HandleEnumerator( |
311 CommandLine::ForCurrentProcess()->HasSwitch( | 311 CommandLine::ForCurrentProcess()->HasSwitch( |
312 switches::kAuditAllHandles))); | 312 switches::kAuditAllHandles))); |
313 handle_enum->EnumerateHandles(); | 313 handle_enum->EnumerateHandles(); |
314 Send(new ChildProcessHostMsg_DumpHandlesDone); | 314 Send(new ChildProcessHostMsg_DumpHandlesDone); |
315 return; | 315 return; |
316 #endif | 316 #endif |
317 | 317 |
318 NOTIMPLEMENTED(); | 318 NOTIMPLEMENTED(); |
319 } | 319 } |
320 | 320 |
(...skipping 28 matching lines...) Expand all Loading... |
349 // The browser then sends back a response if it's ok to shutdown. This avoids | 349 // The browser then sends back a response if it's ok to shutdown. This avoids |
350 // race conditions if the process refcount is 0 but there's an IPC message | 350 // race conditions if the process refcount is 0 but there's an IPC message |
351 // inflight that would addref it. | 351 // inflight that would addref it. |
352 Send(new ChildProcessHostMsg_ShutdownRequest); | 352 Send(new ChildProcessHostMsg_ShutdownRequest); |
353 } | 353 } |
354 | 354 |
355 void ChildThread::EnsureConnected() { | 355 void ChildThread::EnsureConnected() { |
356 LOG(INFO) << "ChildThread::EnsureConnected()"; | 356 LOG(INFO) << "ChildThread::EnsureConnected()"; |
357 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 357 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
358 } | 358 } |
| 359 |
| 360 } // namespace content |
OLD | NEW |