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/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
6 | 6 |
7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
| 8 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/process.h" | 12 #include "base/process.h" |
12 #include "base/process_util.h" | 13 #include "base/process_util.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
15 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
16 #include "components/tracing/child_trace_message_filter.h" | 17 #include "components/tracing/child_trace_message_filter.h" |
17 #include "content/child/child_histogram_message_filter.h" | 18 #include "content/child/child_histogram_message_filter.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ChildProcess::current()->io_message_loop_proxy())); | 144 ChildProcess::current()->io_message_loop_proxy())); |
144 channel_->AddFilter(resource_message_filter_.get()); | 145 channel_->AddFilter(resource_message_filter_.get()); |
145 | 146 |
146 #if defined(OS_POSIX) | 147 #if defined(OS_POSIX) |
147 // Check that --process-type is specified so we don't do this in unit tests | 148 // Check that --process-type is specified so we don't do this in unit tests |
148 // and single-process mode. | 149 // and single-process mode. |
149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 150 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
150 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 151 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
151 #endif | 152 #endif |
152 | 153 |
| 154 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTraceToConsole)) { |
| 155 std::string category_string = |
| 156 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 157 switches::kTraceToConsole); |
| 158 |
| 159 if (!category_string.size()) |
| 160 category_string = "*"; |
| 161 |
| 162 base::debug::TraceLog::GetInstance()->SetEnabled( |
| 163 base::debug::CategoryFilter(category_string), |
| 164 base::debug::TraceLog::ECHO_TO_CONSOLE); |
| 165 } |
| 166 |
153 base::MessageLoop::current()->PostDelayedTask( | 167 base::MessageLoop::current()->PostDelayedTask( |
154 FROM_HERE, | 168 FROM_HERE, |
155 base::Bind(&ChildThread::EnsureConnected, | 169 base::Bind(&ChildThread::EnsureConnected, |
156 channel_connected_factory_.GetWeakPtr()), | 170 channel_connected_factory_.GetWeakPtr()), |
157 base::TimeDelta::FromSeconds(kConnectionTimeoutS)); | 171 base::TimeDelta::FromSeconds(kConnectionTimeoutS)); |
158 | 172 |
159 #if defined(OS_ANDROID) | 173 #if defined(OS_ANDROID) |
160 g_child_thread = this; | 174 g_child_thread = this; |
161 #endif | 175 #endif |
162 } | 176 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // inflight that would addref it. | 388 // inflight that would addref it. |
375 Send(new ChildProcessHostMsg_ShutdownRequest); | 389 Send(new ChildProcessHostMsg_ShutdownRequest); |
376 } | 390 } |
377 | 391 |
378 void ChildThread::EnsureConnected() { | 392 void ChildThread::EnsureConnected() { |
379 LOG(INFO) << "ChildThread::EnsureConnected()"; | 393 LOG(INFO) << "ChildThread::EnsureConnected()"; |
380 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 394 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
381 } | 395 } |
382 | 396 |
383 } // namespace content | 397 } // namespace content |
OLD | NEW |