| 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/utility/utility_thread_impl.h" | 5 #include "content/utility/utility_thread_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "content/child/blink_platform_impl.h" | 11 #include "content/child/blink_platform_impl.h" |
| 12 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
| 13 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
| 14 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
| 15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/utility/content_utility_client.h" | 16 #include "content/public/utility/content_utility_client.h" |
| 17 #include "content/utility/utility_blink_platform_impl.h" | 17 #include "content/utility/utility_blink_platform_impl.h" |
| 18 #include "content/utility/utility_process_control_impl.h" |
| 18 #include "ipc/ipc_sync_channel.h" | 19 #include "ipc/ipc_sync_channel.h" |
| 19 #include "third_party/WebKit/public/web/WebKit.h" | 20 #include "third_party/WebKit/public/web/WebKit.h" |
| 20 | 21 |
| 21 #if defined(OS_POSIX) && defined(ENABLE_PLUGINS) | 22 #if defined(OS_POSIX) && defined(ENABLE_PLUGINS) |
| 22 #include "base/files/file_path.h" | 23 #include "base/files/file_path.h" |
| 23 #include "content/common/plugin_list.h" | 24 #include "content/common/plugin_list.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 ChildProcess::current()->AddRefProcess(); | 79 ChildProcess::current()->AddRefProcess(); |
| 79 if (!IsInBrowserProcess()) { | 80 if (!IsInBrowserProcess()) { |
| 80 // We can only initialize WebKit on one thread, and in single process mode | 81 // We can only initialize WebKit on one thread, and in single process mode |
| 81 // we run the utility thread on separate thread. This means that if any code | 82 // we run the utility thread on separate thread. This means that if any code |
| 82 // needs WebKit initialized in the utility process, they need to have | 83 // needs WebKit initialized in the utility process, they need to have |
| 83 // another path to support single process mode. | 84 // another path to support single process mode. |
| 84 blink_platform_impl_.reset(new UtilityBlinkPlatformImpl); | 85 blink_platform_impl_.reset(new UtilityBlinkPlatformImpl); |
| 85 blink::initialize(blink_platform_impl_.get()); | 86 blink::initialize(blink_platform_impl_.get()); |
| 86 } | 87 } |
| 87 GetContentClient()->utility()->UtilityThreadStarted(); | 88 GetContentClient()->utility()->UtilityThreadStarted(); |
| 89 |
| 90 process_control_.reset(new UtilityProcessControlImpl); |
| 91 service_registry()->AddService(base::Bind( |
| 92 &UtilityThreadImpl::BindProcessControlRequest, base::Unretained(this))); |
| 93 |
| 94 GetContentClient()->utility()->RegisterMojoApplications( |
| 95 process_control_.get()); |
| 88 GetContentClient()->utility()->RegisterMojoServices(service_registry()); | 96 GetContentClient()->utility()->RegisterMojoServices(service_registry()); |
| 89 } | 97 } |
| 90 | 98 |
| 91 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 99 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 92 if (GetContentClient()->utility()->OnMessageReceived(msg)) | 100 if (GetContentClient()->utility()->OnMessageReceived(msg)) |
| 93 return true; | 101 return true; |
| 94 | 102 |
| 95 bool handled = true; | 103 bool handled = true; |
| 96 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) | 104 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) |
| 97 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 105 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 plugin_paths[i], &plugins, &plugin)) | 136 plugin_paths[i], &plugins, &plugin)) |
| 129 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); | 137 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); |
| 130 else | 138 else |
| 131 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); | 139 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); |
| 132 } | 140 } |
| 133 | 141 |
| 134 ReleaseProcessIfNeeded(); | 142 ReleaseProcessIfNeeded(); |
| 135 } | 143 } |
| 136 #endif | 144 #endif |
| 137 | 145 |
| 146 void UtilityThreadImpl::BindProcessControlRequest( |
| 147 mojo::InterfaceRequest<ProcessControl> request) { |
| 148 DCHECK(process_control_); |
| 149 process_control_bindings_.AddBinding(process_control_.get(), request.Pass()); |
| 150 } |
| 151 |
| 138 } // namespace content | 152 } // namespace content |
| OLD | NEW |