| 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_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "ipc/mojo/ipc_channel_mojo.h" | 62 #include "ipc/mojo/ipc_channel_mojo.h" |
| 63 | 63 |
| 64 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
| 65 #include "base/thread_task_runner_handle.h" | 65 #include "base/thread_task_runner_handle.h" |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) | 68 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
| 69 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 69 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 73 #include "content/child/child_io_surface_manager_mac.h" |
| 74 #endif |
| 75 |
| 72 using tracked_objects::ThreadData; | 76 using tracked_objects::ThreadData; |
| 73 | 77 |
| 74 namespace content { | 78 namespace content { |
| 75 namespace { | 79 namespace { |
| 76 | 80 |
| 77 // How long to wait for a connection to the browser process before giving up. | 81 // How long to wait for a connection to the browser process before giving up. |
| 78 const int kConnectionTimeoutS = 15; | 82 const int kConnectionTimeoutS = 15; |
| 79 | 83 |
| 80 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = | 84 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = |
| 81 LAZY_INSTANCE_INITIALIZER; | 85 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 OnSetProfilerStatus) | 575 OnSetProfilerStatus) |
| 572 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, | 576 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, |
| 573 OnGetChildProfilerData) | 577 OnGetChildProfilerData) |
| 574 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, | 578 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, |
| 575 OnProfilingPhaseCompleted) | 579 OnProfilingPhaseCompleted) |
| 576 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, | 580 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, |
| 577 OnProcessBackgrounded) | 581 OnProcessBackgrounded) |
| 578 #if defined(USE_TCMALLOC) | 582 #if defined(USE_TCMALLOC) |
| 579 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) | 583 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) |
| 580 #endif | 584 #endif |
| 585 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 586 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIOSurfaceManagerToken, |
| 587 OnSetIOSurfaceManagerToken) |
| 588 #endif |
| 581 IPC_MESSAGE_UNHANDLED(handled = false) | 589 IPC_MESSAGE_UNHANDLED(handled = false) |
| 582 IPC_END_MESSAGE_MAP() | 590 IPC_END_MESSAGE_MAP() |
| 583 | 591 |
| 584 if (handled) | 592 if (handled) |
| 585 return true; | 593 return true; |
| 586 | 594 |
| 587 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 595 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
| 588 return OnControlMessageReceived(msg); | 596 return OnControlMessageReceived(msg); |
| 589 | 597 |
| 590 return router_.OnMessageReceived(msg); | 598 return router_.OnMessageReceived(msg); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 #if defined(USE_TCMALLOC) | 635 #if defined(USE_TCMALLOC) |
| 628 void ChildThreadImpl::OnGetTcmallocStats() { | 636 void ChildThreadImpl::OnGetTcmallocStats() { |
| 629 std::string result; | 637 std::string result; |
| 630 char buffer[1024 * 32]; | 638 char buffer[1024 * 32]; |
| 631 base::allocator::GetStats(buffer, sizeof(buffer)); | 639 base::allocator::GetStats(buffer, sizeof(buffer)); |
| 632 result.append(buffer); | 640 result.append(buffer); |
| 633 Send(new ChildProcessHostMsg_TcmallocStats(result)); | 641 Send(new ChildProcessHostMsg_TcmallocStats(result)); |
| 634 } | 642 } |
| 635 #endif | 643 #endif |
| 636 | 644 |
| 645 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 646 void ChildThreadImpl::OnSetIOSurfaceManagerToken( |
| 647 const IOSurfaceManagerToken& token) { |
| 648 ChildIOSurfaceManager::GetInstance()->set_token(token); |
| 649 } |
| 650 #endif |
| 651 |
| 637 ChildThreadImpl* ChildThreadImpl::current() { | 652 ChildThreadImpl* ChildThreadImpl::current() { |
| 638 return g_lazy_tls.Pointer()->Get(); | 653 return g_lazy_tls.Pointer()->Get(); |
| 639 } | 654 } |
| 640 | 655 |
| 641 #if defined(OS_ANDROID) | 656 #if defined(OS_ANDROID) |
| 642 // The method must NOT be called on the child thread itself. | 657 // The method must NOT be called on the child thread itself. |
| 643 // It may block the child thread if so. | 658 // It may block the child thread if so. |
| 644 void ChildThreadImpl::ShutdownThread() { | 659 void ChildThreadImpl::ShutdownThread() { |
| 645 DCHECK(!ChildThreadImpl::current()) << | 660 DCHECK(!ChildThreadImpl::current()) << |
| 646 "this method should NOT be called from child thread itself"; | 661 "this method should NOT be called from child thread itself"; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 674 | 689 |
| 675 void ChildThreadImpl::OnProcessBackgrounded(bool background) { | 690 void ChildThreadImpl::OnProcessBackgrounded(bool background) { |
| 676 // Set timer slack to maximum on main thread when in background. | 691 // Set timer slack to maximum on main thread when in background. |
| 677 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 692 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
| 678 if (background) | 693 if (background) |
| 679 timer_slack = base::TIMER_SLACK_MAXIMUM; | 694 timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 680 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 695 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 681 } | 696 } |
| 682 | 697 |
| 683 } // namespace content | 698 } // namespace content |
| OLD | NEW |