| 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 <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/allocator/allocator_extension.h" | 11 #include "base/allocator/allocator_extension.h" |
| 12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/debug/leak_annotations.h" | 15 #include "base/debug/leak_annotations.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/message_loop/timer_slack.h" | 19 #include "base/message_loop/timer_slack.h" |
| 20 #include "base/process/kill.h" | 20 #include "base/process/kill.h" |
| 21 #include "base/process/process_handle.h" | 21 #include "base/process/process_handle.h" |
| 22 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/synchronization/condition_variable.h" | 24 #include "base/synchronization/condition_variable.h" |
| 24 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
| 25 #include "base/threading/thread_local.h" | 26 #include "base/threading/thread_local.h" |
| 26 #include "base/tracked_objects.h" | 27 #include "base/tracked_objects.h" |
| 27 #include "components/tracing/child_trace_message_filter.h" | 28 #include "components/tracing/child_trace_message_filter.h" |
| 28 #include "content/child/child_histogram_message_filter.h" | 29 #include "content/child/child_histogram_message_filter.h" |
| 29 #include "content/child/child_process.h" | 30 #include "content/child/child_process.h" |
| 30 #include "content/child/child_resource_message_filter.h" | 31 #include "content/child/child_resource_message_filter.h" |
| 31 #include "content/child/child_shared_bitmap_manager.h" | 32 #include "content/child/child_shared_bitmap_manager.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 power_monitor_source.PassAs<base::PowerMonitorSource>())); | 283 power_monitor_source.PassAs<base::PowerMonitorSource>())); |
| 283 } | 284 } |
| 284 | 285 |
| 285 #if defined(OS_POSIX) | 286 #if defined(OS_POSIX) |
| 286 // Check that --process-type is specified so we don't do this in unit tests | 287 // Check that --process-type is specified so we don't do this in unit tests |
| 287 // and single-process mode. | 288 // and single-process mode. |
| 288 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 289 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
| 289 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 290 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
| 290 #endif | 291 #endif |
| 291 | 292 |
| 293 int connection_timeout = kConnectionTimeoutS; |
| 294 std::string connection_override = |
| 295 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 296 switches::kIPCConnectionTimeout); |
| 297 if (!connection_override.empty()) { |
| 298 int temp; |
| 299 if (base::StringToInt(connection_override, &temp)) |
| 300 connection_timeout = temp; |
| 301 } |
| 302 |
| 292 base::MessageLoop::current()->PostDelayedTask( | 303 base::MessageLoop::current()->PostDelayedTask( |
| 293 FROM_HERE, | 304 FROM_HERE, |
| 294 base::Bind(&ChildThread::EnsureConnected, | 305 base::Bind(&ChildThread::EnsureConnected, |
| 295 channel_connected_factory_.GetWeakPtr()), | 306 channel_connected_factory_.GetWeakPtr()), |
| 296 base::TimeDelta::FromSeconds(kConnectionTimeoutS)); | 307 base::TimeDelta::FromSeconds(connection_timeout)); |
| 297 | 308 |
| 298 #if defined(OS_ANDROID) | 309 #if defined(OS_ANDROID) |
| 299 { | 310 { |
| 300 base::AutoLock lock(g_lazy_child_thread_lock.Get()); | 311 base::AutoLock lock(g_lazy_child_thread_lock.Get()); |
| 301 g_child_thread = this; | 312 g_child_thread = this; |
| 302 } | 313 } |
| 303 // Signalling without locking is fine here because only | 314 // Signalling without locking is fine here because only |
| 304 // one thread can wait on the condition variable. | 315 // one thread can wait on the condition variable. |
| 305 g_lazy_child_thread_cv.Get().Signal(); | 316 g_lazy_child_thread_cv.Get().Signal(); |
| 306 #endif | 317 #endif |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 572 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 562 | 573 |
| 563 #ifdef OS_WIN | 574 #ifdef OS_WIN |
| 564 // Windows Vista+ has a fancy process backgrounding mode that can only be set | 575 // Windows Vista+ has a fancy process backgrounding mode that can only be set |
| 565 // from within the process. | 576 // from within the process. |
| 566 base::Process::Current().SetProcessBackgrounded(background); | 577 base::Process::Current().SetProcessBackgrounded(background); |
| 567 #endif // OS_WIN | 578 #endif // OS_WIN |
| 568 } | 579 } |
| 569 | 580 |
| 570 } // namespace content | 581 } // namespace content |
| OLD | NEW |