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 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "ipc/ipc_switches.h" | 63 #include "ipc/ipc_switches.h" |
64 #include "ipc/ipc_sync_channel.h" | 64 #include "ipc/ipc_sync_channel.h" |
65 #include "ipc/ipc_sync_message_filter.h" | 65 #include "ipc/ipc_sync_message_filter.h" |
66 #include "ipc/mojo/ipc_channel_mojo.h" | 66 #include "ipc/mojo/ipc_channel_mojo.h" |
67 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 67 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
68 | 68 |
69 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) | 69 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
70 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 70 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
71 #endif | 71 #endif |
72 | 72 |
73 #if defined(OS_MACOSX) | |
74 #include "content/child/child_io_surface_manager_mac.h" | |
75 #endif | |
76 | |
77 #if defined(USE_OZONE) | 73 #if defined(USE_OZONE) |
78 #include "ui/ozone/public/client_native_pixmap_factory.h" | 74 #include "ui/ozone/public/client_native_pixmap_factory.h" |
79 #endif | 75 #endif |
80 | 76 |
81 #if defined(MOJO_SHELL_CLIENT) | 77 #if defined(MOJO_SHELL_CLIENT) |
82 #include "content/common/mojo/mojo_shell_connection_impl.h" | 78 #include "content/common/mojo/mojo_shell_connection_impl.h" |
83 #endif | 79 #endif |
84 | 80 |
85 using tracked_objects::ThreadData; | 81 using tracked_objects::ThreadData; |
86 | 82 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 _exit(0); | 168 _exit(0); |
173 #endif | 169 #endif |
174 } | 170 } |
175 | 171 |
176 protected: | 172 protected: |
177 ~SuicideOnChannelErrorFilter() override {} | 173 ~SuicideOnChannelErrorFilter() override {} |
178 }; | 174 }; |
179 | 175 |
180 #endif // OS(POSIX) | 176 #endif // OS(POSIX) |
181 | 177 |
182 #if defined(OS_MACOSX) | |
183 class IOSurfaceManagerFilter : public IPC::MessageFilter { | |
184 public: | |
185 // Overridden from IPC::MessageFilter: | |
186 bool OnMessageReceived(const IPC::Message& message) override { | |
187 bool handled = true; | |
188 IPC_BEGIN_MESSAGE_MAP(IOSurfaceManagerFilter, message) | |
189 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIOSurfaceManagerToken, | |
190 OnSetIOSurfaceManagerToken) | |
191 IPC_MESSAGE_UNHANDLED(handled = false) | |
192 IPC_END_MESSAGE_MAP() | |
193 return handled; | |
194 } | |
195 | |
196 protected: | |
197 ~IOSurfaceManagerFilter() override {} | |
198 | |
199 void OnSetIOSurfaceManagerToken(const IOSurfaceManagerToken& token) { | |
200 ChildIOSurfaceManager::GetInstance()->set_token(token); | |
201 } | |
202 }; | |
203 #endif | |
204 | |
205 #if defined(USE_OZONE) | 178 #if defined(USE_OZONE) |
206 class ClientNativePixmapFactoryFilter : public IPC::MessageFilter { | 179 class ClientNativePixmapFactoryFilter : public IPC::MessageFilter { |
207 public: | 180 public: |
208 // Overridden from IPC::MessageFilter: | 181 // Overridden from IPC::MessageFilter: |
209 bool OnMessageReceived(const IPC::Message& message) override { | 182 bool OnMessageReceived(const IPC::Message& message) override { |
210 bool handled = true; | 183 bool handled = true; |
211 IPC_BEGIN_MESSAGE_MAP(ClientNativePixmapFactoryFilter, message) | 184 IPC_BEGIN_MESSAGE_MAP(ClientNativePixmapFactoryFilter, message) |
212 IPC_MESSAGE_HANDLER(ChildProcessMsg_InitializeClientNativePixmapFactory, | 185 IPC_MESSAGE_HANDLER(ChildProcessMsg_InitializeClientNativePixmapFactory, |
213 OnInitializeClientNativePixmapFactory) | 186 OnInitializeClientNativePixmapFactory) |
214 IPC_MESSAGE_UNHANDLED(handled = false) | 187 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 new base::PowerMonitor(std::move(power_monitor_source))); | 447 new base::PowerMonitor(std::move(power_monitor_source))); |
475 } | 448 } |
476 | 449 |
477 #if defined(OS_POSIX) | 450 #if defined(OS_POSIX) |
478 // Check that --process-type is specified so we don't do this in unit tests | 451 // Check that --process-type is specified so we don't do this in unit tests |
479 // and single-process mode. | 452 // and single-process mode. |
480 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 453 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
481 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 454 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
482 #endif | 455 #endif |
483 | 456 |
484 #if defined(OS_MACOSX) | |
485 channel_->AddFilter(new IOSurfaceManagerFilter()); | |
486 #endif | |
487 | |
488 #if defined(USE_OZONE) | 457 #if defined(USE_OZONE) |
489 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); | 458 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); |
490 #endif | 459 #endif |
491 | 460 |
492 // Add filters passed here via options. | 461 // Add filters passed here via options. |
493 for (auto startup_filter : options.startup_filters) { | 462 for (auto startup_filter : options.startup_filters) { |
494 channel_->AddFilter(startup_filter); | 463 channel_->AddFilter(startup_filter); |
495 } | 464 } |
496 | 465 |
497 ConnectChannel(options.use_mojo_channel); | 466 ConnectChannel(options.use_mojo_channel); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 void ChildThreadImpl::EnsureConnected() { | 736 void ChildThreadImpl::EnsureConnected() { |
768 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 737 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
769 base::Process::Current().Terminate(0, false); | 738 base::Process::Current().Terminate(0, false); |
770 } | 739 } |
771 | 740 |
772 bool ChildThreadImpl::IsInBrowserProcess() const { | 741 bool ChildThreadImpl::IsInBrowserProcess() const { |
773 return browser_process_io_runner_; | 742 return browser_process_io_runner_; |
774 } | 743 } |
775 | 744 |
776 } // namespace content | 745 } // namespace content |
OLD | NEW |