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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "ipc/mojo/ipc_channel_mojo.h" | 61 #include "ipc/mojo/ipc_channel_mojo.h" |
62 | 62 |
63 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) | 63 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
64 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 64 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
65 #endif | 65 #endif |
66 | 66 |
67 #if defined(OS_MACOSX) | 67 #if defined(OS_MACOSX) |
68 #include "content/child/child_io_surface_manager_mac.h" | 68 #include "content/child/child_io_surface_manager_mac.h" |
69 #endif | 69 #endif |
70 | 70 |
| 71 #if defined(USE_OZONE) |
| 72 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 73 #endif |
| 74 |
71 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
72 #include "ipc/attachment_broker_unprivileged_win.h" | 76 #include "ipc/attachment_broker_unprivileged_win.h" |
73 #endif | 77 #endif |
74 | 78 |
75 using tracked_objects::ThreadData; | 79 using tracked_objects::ThreadData; |
76 | 80 |
77 namespace content { | 81 namespace content { |
78 namespace { | 82 namespace { |
79 | 83 |
80 // How long to wait for a connection to the browser process before giving up. | 84 // How long to wait for a connection to the browser process before giving up. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 189 |
186 protected: | 190 protected: |
187 ~IOSurfaceManagerFilter() override {} | 191 ~IOSurfaceManagerFilter() override {} |
188 | 192 |
189 void OnSetIOSurfaceManagerToken(const IOSurfaceManagerToken& token) { | 193 void OnSetIOSurfaceManagerToken(const IOSurfaceManagerToken& token) { |
190 ChildIOSurfaceManager::GetInstance()->set_token(token); | 194 ChildIOSurfaceManager::GetInstance()->set_token(token); |
191 } | 195 } |
192 }; | 196 }; |
193 #endif | 197 #endif |
194 | 198 |
| 199 #if defined(USE_OZONE) |
| 200 class ClientNativePixmapFactoryFilter : public IPC::MessageFilter { |
| 201 public: |
| 202 // Overridden from IPC::MessageFilter: |
| 203 bool OnMessageReceived(const IPC::Message& message) override { |
| 204 bool handled = true; |
| 205 IPC_BEGIN_MESSAGE_MAP(ClientNativePixmapFactoryFilter, message) |
| 206 IPC_MESSAGE_HANDLER(ChildProcessMsg_InitializeClientNativePixmapFactory, |
| 207 OnInitializeClientNativePixmapFactory) |
| 208 IPC_MESSAGE_UNHANDLED(handled = false) |
| 209 IPC_END_MESSAGE_MAP() |
| 210 return handled; |
| 211 } |
| 212 |
| 213 protected: |
| 214 ~ClientNativePixmapFactoryFilter() override {} |
| 215 |
| 216 void OnInitializeClientNativePixmapFactory( |
| 217 const base::FileDescriptor& device_fd) { |
| 218 ui::ClientNativePixmapFactory::GetInstance()->Initialize( |
| 219 base::ScopedFD(device_fd.fd)); |
| 220 } |
| 221 }; |
| 222 #endif |
| 223 |
195 #if defined(OS_ANDROID) | 224 #if defined(OS_ANDROID) |
196 // A class that allows for triggering a clean shutdown from another | 225 // A class that allows for triggering a clean shutdown from another |
197 // thread through draining the main thread's msg loop. | 226 // thread through draining the main thread's msg loop. |
198 class QuitClosure { | 227 class QuitClosure { |
199 public: | 228 public: |
200 QuitClosure(); | 229 QuitClosure(); |
201 ~QuitClosure(); | 230 ~QuitClosure(); |
202 | 231 |
203 void BindToMainThread(); | 232 void BindToMainThread(); |
204 void PostQuitFromNonMainThread(); | 233 void PostQuitFromNonMainThread(); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Check that --process-type is specified so we don't do this in unit tests | 450 // Check that --process-type is specified so we don't do this in unit tests |
422 // and single-process mode. | 451 // and single-process mode. |
423 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 452 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
424 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 453 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
425 #endif | 454 #endif |
426 | 455 |
427 #if defined(OS_MACOSX) | 456 #if defined(OS_MACOSX) |
428 channel_->AddFilter(new IOSurfaceManagerFilter()); | 457 channel_->AddFilter(new IOSurfaceManagerFilter()); |
429 #endif | 458 #endif |
430 | 459 |
| 460 #if defined(USE_OZONE) |
| 461 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); |
| 462 #endif |
| 463 |
431 // Add filters passed here via options. | 464 // Add filters passed here via options. |
432 for (auto startup_filter : options.startup_filters) { | 465 for (auto startup_filter : options.startup_filters) { |
433 channel_->AddFilter(startup_filter); | 466 channel_->AddFilter(startup_filter); |
434 } | 467 } |
435 | 468 |
436 ConnectChannel(options.use_mojo_channel); | 469 ConnectChannel(options.use_mojo_channel); |
437 if (attachment_broker_) | 470 if (attachment_broker_) |
438 attachment_broker_->DesignateBrokerCommunicationChannel(channel_.get()); | 471 attachment_broker_->DesignateBrokerCommunicationChannel(channel_.get()); |
439 | 472 |
440 int connection_timeout = kConnectionTimeoutS; | 473 int connection_timeout = kConnectionTimeoutS; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 | 740 |
708 void ChildThreadImpl::OnProcessBackgrounded(bool background) { | 741 void ChildThreadImpl::OnProcessBackgrounded(bool background) { |
709 // Set timer slack to maximum on main thread when in background. | 742 // Set timer slack to maximum on main thread when in background. |
710 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 743 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
711 if (background) | 744 if (background) |
712 timer_slack = base::TIMER_SLACK_MAXIMUM; | 745 timer_slack = base::TIMER_SLACK_MAXIMUM; |
713 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 746 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
714 } | 747 } |
715 | 748 |
716 } // namespace content | 749 } // namespace content |
OLD | NEW |