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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "ipc/ipc_logging.h" | 62 #include "ipc/ipc_logging.h" |
63 #include "ipc/ipc_platform_file.h" | 63 #include "ipc/ipc_platform_file.h" |
64 #include "ipc/ipc_switches.h" | 64 #include "ipc/ipc_switches.h" |
65 #include "ipc/ipc_sync_channel.h" | 65 #include "ipc/ipc_sync_channel.h" |
66 #include "ipc/ipc_sync_message_filter.h" | 66 #include "ipc/ipc_sync_message_filter.h" |
67 #include "ipc/mojo/ipc_channel_mojo.h" | 67 #include "ipc/mojo/ipc_channel_mojo.h" |
68 #include "ipc/mojo/scoped_ipc_support.h" | 68 #include "ipc/mojo/scoped_ipc_support.h" |
69 #include "mojo/edk/embedder/embedder.h" | 69 #include "mojo/edk/embedder/embedder.h" |
70 #include "mojo/edk/embedder/platform_channel_pair.h" | 70 #include "mojo/edk/embedder/platform_channel_pair.h" |
71 | 71 |
72 #if defined(USE_OZONE) | |
73 #include "ui/ozone/public/client_native_pixmap_factory.h" | |
74 #endif | |
75 | |
76 #if defined(OS_POSIX) | 72 #if defined(OS_POSIX) |
77 #include "base/posix/global_descriptors.h" | 73 #include "base/posix/global_descriptors.h" |
78 #include "content/public/common/content_descriptors.h" | 74 #include "content/public/common/content_descriptors.h" |
79 #endif | 75 #endif |
80 | 76 |
81 using tracked_objects::ThreadData; | 77 using tracked_objects::ThreadData; |
82 | 78 |
83 namespace content { | 79 namespace content { |
84 namespace { | 80 namespace { |
85 | 81 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 _exit(0); | 164 _exit(0); |
169 #endif | 165 #endif |
170 } | 166 } |
171 | 167 |
172 protected: | 168 protected: |
173 ~SuicideOnChannelErrorFilter() override {} | 169 ~SuicideOnChannelErrorFilter() override {} |
174 }; | 170 }; |
175 | 171 |
176 #endif // OS(POSIX) | 172 #endif // OS(POSIX) |
177 | 173 |
178 #if defined(USE_OZONE) | |
179 class ClientNativePixmapFactoryFilter : public IPC::MessageFilter { | |
180 public: | |
181 // Overridden from IPC::MessageFilter: | |
182 bool OnMessageReceived(const IPC::Message& message) override { | |
183 bool handled = true; | |
184 IPC_BEGIN_MESSAGE_MAP(ClientNativePixmapFactoryFilter, message) | |
185 IPC_MESSAGE_HANDLER(ChildProcessMsg_InitializeClientNativePixmapFactory, | |
186 OnInitializeClientNativePixmapFactory) | |
187 IPC_MESSAGE_UNHANDLED(handled = false) | |
188 IPC_END_MESSAGE_MAP() | |
189 return handled; | |
190 } | |
191 | |
192 protected: | |
193 ~ClientNativePixmapFactoryFilter() override {} | |
194 | |
195 void OnInitializeClientNativePixmapFactory( | |
196 const base::FileDescriptor& device_fd) { | |
197 ui::ClientNativePixmapFactory::GetInstance()->Initialize( | |
198 base::ScopedFD(device_fd.fd)); | |
199 } | |
200 }; | |
201 #endif | |
202 | |
203 #if defined(OS_ANDROID) | 174 #if defined(OS_ANDROID) |
204 // A class that allows for triggering a clean shutdown from another | 175 // A class that allows for triggering a clean shutdown from another |
205 // thread through draining the main thread's msg loop. | 176 // thread through draining the main thread's msg loop. |
206 class QuitClosure { | 177 class QuitClosure { |
207 public: | 178 public: |
208 QuitClosure(); | 179 QuitClosure(); |
209 ~QuitClosure(); | 180 ~QuitClosure(); |
210 | 181 |
211 void BindToMainThread(); | 182 void BindToMainThread(); |
212 void PostQuitFromNonMainThread(); | 183 void PostQuitFromNonMainThread(); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 new base::PowerMonitor(std::move(power_monitor_source))); | 442 new base::PowerMonitor(std::move(power_monitor_source))); |
472 } | 443 } |
473 | 444 |
474 #if defined(OS_POSIX) | 445 #if defined(OS_POSIX) |
475 // Check that --process-type is specified so we don't do this in unit tests | 446 // Check that --process-type is specified so we don't do this in unit tests |
476 // and single-process mode. | 447 // and single-process mode. |
477 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 448 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
478 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 449 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
479 #endif | 450 #endif |
480 | 451 |
481 #if defined(USE_OZONE) | |
482 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); | |
483 #endif | |
484 | |
485 // Add filters passed here via options. | 452 // Add filters passed here via options. |
486 for (auto startup_filter : options.startup_filters) { | 453 for (auto startup_filter : options.startup_filters) { |
487 channel_->AddFilter(startup_filter); | 454 channel_->AddFilter(startup_filter); |
488 } | 455 } |
489 | 456 |
490 ConnectChannel( | 457 ConnectChannel( |
491 options.use_mojo_channel, | 458 options.use_mojo_channel, |
492 mojo::MakeScopedHandle(options.in_process_message_pipe_handle)); | 459 mojo::MakeScopedHandle(options.in_process_message_pipe_handle)); |
493 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); | 460 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); |
494 if (broker && !broker->IsPrivilegedBroker()) | 461 if (broker && !broker->IsPrivilegedBroker()) |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 void ChildThreadImpl::EnsureConnected() { | 708 void ChildThreadImpl::EnsureConnected() { |
742 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 709 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
743 base::Process::Current().Terminate(0, false); | 710 base::Process::Current().Terminate(0, false); |
744 } | 711 } |
745 | 712 |
746 bool ChildThreadImpl::IsInBrowserProcess() const { | 713 bool ChildThreadImpl::IsInBrowserProcess() const { |
747 return browser_process_io_runner_; | 714 return browser_process_io_runner_; |
748 } | 715 } |
749 | 716 |
750 } // namespace content | 717 } // namespace content |
OLD | NEW |