| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 #include "ipc/ipc_channel.h" | 175 #include "ipc/ipc_channel.h" |
| 176 #include "ipc/ipc_channel_mojo.h" | 176 #include "ipc/ipc_channel_mojo.h" |
| 177 #include "ipc/ipc_logging.h" | 177 #include "ipc/ipc_logging.h" |
| 178 #include "media/base/media_switches.h" | 178 #include "media/base/media_switches.h" |
| 179 #include "media/media_features.h" | 179 #include "media/media_features.h" |
| 180 #include "mojo/edk/embedder/embedder.h" | 180 #include "mojo/edk/embedder/embedder.h" |
| 181 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 181 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 182 #include "net/url_request/url_request_context_getter.h" | 182 #include "net/url_request/url_request_context_getter.h" |
| 183 #include "ppapi/features/features.h" | 183 #include "ppapi/features/features.h" |
| 184 #include "services/service_manager/public/cpp/connection.h" | 184 #include "services/service_manager/public/cpp/connection.h" |
| 185 #include "services/service_manager/public/cpp/connector.h" |
| 185 #include "services/service_manager/public/cpp/interface_provider.h" | 186 #include "services/service_manager/public/cpp/interface_provider.h" |
| 186 #include "services/service_manager/public/cpp/interface_registry.h" | 187 #include "services/service_manager/public/cpp/interface_registry.h" |
| 187 #include "services/service_manager/runner/common/client_util.h" | 188 #include "services/service_manager/runner/common/client_util.h" |
| 188 #include "services/service_manager/runner/common/switches.h" | 189 #include "services/service_manager/runner/common/switches.h" |
| 189 #include "services/shape_detection/public/interfaces/barcodedetection.mojom.h" | 190 #include "services/shape_detection/public/interfaces/barcodedetection.mojom.h" |
| 191 #include "services/shape_detection/public/interfaces/constants.mojom.h" |
| 190 #include "services/shape_detection/public/interfaces/facedetection_provider.mojo
m.h" | 192 #include "services/shape_detection/public/interfaces/facedetection_provider.mojo
m.h" |
| 191 #include "services/shape_detection/public/interfaces/textdetection.mojom.h" | 193 #include "services/shape_detection/public/interfaces/textdetection.mojom.h" |
| 192 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 194 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
| 193 #include "third_party/WebKit/public/public_features.h" | 195 #include "third_party/WebKit/public/public_features.h" |
| 194 #include "third_party/skia/include/core/SkBitmap.h" | 196 #include "third_party/skia/include/core/SkBitmap.h" |
| 195 #include "ui/base/ui_base_switches.h" | 197 #include "ui/base/ui_base_switches.h" |
| 196 #include "ui/display/display_switches.h" | 198 #include "ui/display/display_switches.h" |
| 197 #include "ui/gfx/switches.h" | 199 #include "ui/gfx/switches.h" |
| 198 #include "ui/gl/gl_switches.h" | 200 #include "ui/gl/gl_switches.h" |
| 199 #include "ui/gl/gpu_switching_manager.h" | 201 #include "ui/gl/gpu_switching_manager.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 212 #include "content/browser/renderer_host/dwrite_font_proxy_message_filter_win.h" | 214 #include "content/browser/renderer_host/dwrite_font_proxy_message_filter_win.h" |
| 213 #include "content/common/font_cache_dispatcher_win.h" | 215 #include "content/common/font_cache_dispatcher_win.h" |
| 214 #include "content/common/sandbox_win.h" | 216 #include "content/common/sandbox_win.h" |
| 215 #include "sandbox/win/src/sandbox_policy.h" | 217 #include "sandbox/win/src/sandbox_policy.h" |
| 216 #include "ui/display/win/dpi.h" | 218 #include "ui/display/win/dpi.h" |
| 217 #endif | 219 #endif |
| 218 | 220 |
| 219 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
| 220 #include "content/browser/bootstrap_sandbox_manager_mac.h" | 222 #include "content/browser/bootstrap_sandbox_manager_mac.h" |
| 221 #include "content/browser/mach_broker_mac.h" | 223 #include "content/browser/mach_broker_mac.h" |
| 222 #include "content/browser/shapedetection/face_detection_service_dispatcher.h" | |
| 223 #endif | 224 #endif |
| 224 | 225 |
| 225 #if defined(OS_POSIX) | 226 #if defined(OS_POSIX) |
| 226 #include "content/browser/zygote_host/zygote_communication_linux.h" | 227 #include "content/browser/zygote_host/zygote_communication_linux.h" |
| 227 #include "content/browser/zygote_host/zygote_host_impl_linux.h" | 228 #include "content/browser/zygote_host/zygote_host_impl_linux.h" |
| 228 #include "content/public/browser/zygote_handle_linux.h" | 229 #include "content/public/browser/zygote_handle_linux.h" |
| 229 #endif // defined(OS_POSIX) | 230 #endif // defined(OS_POSIX) |
| 230 | 231 |
| 231 #if defined(USE_OZONE) | 232 #if defined(USE_OZONE) |
| 232 #include "ui/ozone/public/ozone_switches.h" | 233 #include "ui/ozone/public/ozone_switches.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder); | 450 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder); |
| 450 }; | 451 }; |
| 451 | 452 |
| 452 void CreateMemoryCoordinatorHandle( | 453 void CreateMemoryCoordinatorHandle( |
| 453 int render_process_id, | 454 int render_process_id, |
| 454 mojom::MemoryCoordinatorHandleRequest request) { | 455 mojom::MemoryCoordinatorHandleRequest request) { |
| 455 MemoryCoordinatorImpl::GetInstance()->CreateHandle(render_process_id, | 456 MemoryCoordinatorImpl::GetInstance()->CreateHandle(render_process_id, |
| 456 std::move(request)); | 457 std::move(request)); |
| 457 } | 458 } |
| 458 | 459 |
| 460 // Forwards service requests to Service Manager since the renderer cannot launch |
| 461 // out-of-process services on is own. |
| 462 template <typename R> |
| 463 void ForwardShapeDetectionRequest(R request) { |
| 464 service_manager::Connector* connector = |
| 465 ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 466 connector->BindInterface(shape_detection::mojom::kServiceName, |
| 467 std::move(request)); |
| 468 } |
| 469 |
| 459 } // namespace | 470 } // namespace |
| 460 | 471 |
| 461 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 472 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
| 462 | 473 |
| 463 base::MessageLoop* g_in_process_thread; | 474 base::MessageLoop* g_in_process_thread; |
| 464 | 475 |
| 465 // Stores the maximum number of renderer processes the content module can | 476 // Stores the maximum number of renderer processes the content module can |
| 466 // create. | 477 // create. |
| 467 static size_t g_max_renderer_count_override = 0; | 478 static size_t g_max_renderer_count_override = 0; |
| 468 | 479 |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 #endif | 1201 #endif |
| 1191 } | 1202 } |
| 1192 | 1203 |
| 1193 void RenderProcessHostImpl::RegisterMojoInterfaces() { | 1204 void RenderProcessHostImpl::RegisterMojoInterfaces() { |
| 1194 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>( | 1205 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>( |
| 1195 service_manager::mojom::kServiceManager_ConnectorSpec); | 1206 service_manager::mojom::kServiceManager_ConnectorSpec); |
| 1196 | 1207 |
| 1197 channel_->AddAssociatedInterfaceForIOThread( | 1208 channel_->AddAssociatedInterfaceForIOThread( |
| 1198 base::Bind(&IndexedDBDispatcherHost::AddBinding, indexed_db_factory_)); | 1209 base::Bind(&IndexedDBDispatcherHost::AddBinding, indexed_db_factory_)); |
| 1199 | 1210 |
| 1200 #if defined(OS_MACOSX) | |
| 1201 AddUIThreadInterface( | |
| 1202 registry.get(), | |
| 1203 base::Bind(&FaceDetectionServiceDispatcher::CreateMojoService)); | |
| 1204 #endif | |
| 1205 | |
| 1206 #if defined(OS_ANDROID) | 1211 #if defined(OS_ANDROID) |
| 1207 AddUIThreadInterface(registry.get(), | 1212 AddUIThreadInterface(registry.get(), |
| 1208 GetGlobalJavaInterfaces() | 1213 GetGlobalJavaInterfaces() |
| 1209 ->CreateInterfaceFactory<device::BatteryMonitor>()); | 1214 ->CreateInterfaceFactory<device::BatteryMonitor>()); |
| 1210 AddUIThreadInterface( | 1215 AddUIThreadInterface( |
| 1211 registry.get(), GetGlobalJavaInterfaces() | 1216 registry.get(), GetGlobalJavaInterfaces() |
| 1212 ->CreateInterfaceFactory< | 1217 ->CreateInterfaceFactory< |
| 1213 shape_detection::mojom::FaceDetectionProvider>()); | 1218 shape_detection::mojom::FaceDetectionProvider>()); |
| 1214 AddUIThreadInterface( | 1219 AddUIThreadInterface( |
| 1215 registry.get(), | 1220 registry.get(), |
| 1216 GetGlobalJavaInterfaces() | 1221 GetGlobalJavaInterfaces() |
| 1217 ->CreateInterfaceFactory<shape_detection::mojom::BarcodeDetection>()); | 1222 ->CreateInterfaceFactory<shape_detection::mojom::BarcodeDetection>()); |
| 1218 AddUIThreadInterface( | 1223 AddUIThreadInterface( |
| 1219 registry.get(), | 1224 registry.get(), |
| 1220 GetGlobalJavaInterfaces() | 1225 GetGlobalJavaInterfaces() |
| 1221 ->CreateInterfaceFactory<shape_detection::mojom::TextDetection>()); | 1226 ->CreateInterfaceFactory<shape_detection::mojom::TextDetection>()); |
| 1222 #else | 1227 #else |
| 1223 AddUIThreadInterface( | 1228 AddUIThreadInterface( |
| 1224 registry.get(), base::Bind(&device::BatteryMonitorImpl::Create)); | 1229 registry.get(), base::Bind(&device::BatteryMonitorImpl::Create)); |
| 1230 AddUIThreadInterface( |
| 1231 registry.get(), |
| 1232 base::Bind(&ForwardShapeDetectionRequest< |
| 1233 shape_detection::mojom::BarcodeDetectionRequest>)); |
| 1234 AddUIThreadInterface( |
| 1235 registry.get(), |
| 1236 base::Bind(&ForwardShapeDetectionRequest< |
| 1237 shape_detection::mojom::FaceDetectionProviderRequest>)); |
| 1225 #endif | 1238 #endif |
| 1226 AddUIThreadInterface( | 1239 AddUIThreadInterface( |
| 1227 registry.get(), | 1240 registry.get(), |
| 1228 base::Bind(&PermissionServiceContext::CreateService, | 1241 base::Bind(&PermissionServiceContext::CreateService, |
| 1229 base::Unretained(permission_service_context_.get()))); | 1242 base::Unretained(permission_service_context_.get()))); |
| 1230 // TODO(mcasas): finalize arguments. | 1243 // TODO(mcasas): finalize arguments. |
| 1231 AddUIThreadInterface(registry.get(), base::Bind(&ImageCaptureImpl::Create)); | 1244 AddUIThreadInterface(registry.get(), base::Bind(&ImageCaptureImpl::Create)); |
| 1232 | 1245 |
| 1233 AddUIThreadInterface( | 1246 AddUIThreadInterface( |
| 1234 registry.get(), | 1247 registry.get(), |
| (...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3069 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3057 | 3070 |
| 3058 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3071 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3059 // Capture the error message in a crash key value. | 3072 // Capture the error message in a crash key value. |
| 3060 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3073 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3061 bad_message::ReceivedBadMessage(render_process_id, | 3074 bad_message::ReceivedBadMessage(render_process_id, |
| 3062 bad_message::RPH_MOJO_PROCESS_ERROR); | 3075 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3063 } | 3076 } |
| 3064 | 3077 |
| 3065 } // namespace content | 3078 } // namespace content |
| OLD | NEW |