| 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 void NotifyTimezoneChangeOnThisThread() { | 320 void NotifyTimezoneChangeOnThisThread() { |
| 321 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 321 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 322 if (!isolate) | 322 if (!isolate) |
| 323 return; | 323 return; |
| 324 v8::Date::DateTimeConfigurationChangeNotification(isolate); | 324 v8::Date::DateTimeConfigurationChangeNotification(isolate); |
| 325 } | 325 } |
| 326 | 326 |
| 327 class FrameFactoryImpl : public mojom::FrameFactory { | 327 class FrameFactoryImpl : public mojom::FrameFactory { |
| 328 public: | 328 public: |
| 329 explicit FrameFactoryImpl(mojom::FrameFactoryRequest request) | 329 FrameFactoryImpl() : routing_id_highmark_(-1) {} |
| 330 : routing_id_highmark_(-1), binding_(this, std::move(request)) {} | |
| 331 | 330 |
| 332 private: | 331 private: |
| 333 // mojom::FrameFactory: | 332 // mojom::FrameFactory: |
| 334 void CreateFrame(int32_t frame_routing_id, | 333 void CreateFrame(int32_t frame_routing_id, |
| 335 mojom::FrameRequest frame_request, | 334 mojom::FrameRequest frame_request, |
| 336 mojom::FrameHostPtr frame_host) override { | 335 mojom::FrameHostPtr frame_host) override { |
| 337 // TODO(morrita): This is for investigating http://crbug.com/415059 and | 336 // TODO(morrita): This is for investigating http://crbug.com/415059 and |
| 338 // should be removed once it is fixed. | 337 // should be removed once it is fixed. |
| 339 CHECK_LT(routing_id_highmark_, frame_routing_id); | 338 CHECK_LT(routing_id_highmark_, frame_routing_id); |
| 340 routing_id_highmark_ = frame_routing_id; | 339 routing_id_highmark_ = frame_routing_id; |
| 341 | 340 |
| 342 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); | 341 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); |
| 343 // We can receive a GetServiceProviderForFrame message for a frame not yet | 342 // We can receive a GetServiceProviderForFrame message for a frame not yet |
| 344 // created due to a race between the message and a ViewMsg_New IPC that | 343 // created due to a race between the message and a ViewMsg_New IPC that |
| 345 // triggers creation of the RenderFrame we want. | 344 // triggers creation of the RenderFrame we want. |
| 346 if (!frame) { | 345 if (!frame) { |
| 347 RenderThreadImpl::current()->RegisterPendingFrameCreate( | 346 RenderThreadImpl::current()->RegisterPendingFrameCreate( |
| 348 frame_routing_id, std::move(frame_request), std::move(frame_host)); | 347 frame_routing_id, std::move(frame_request), std::move(frame_host)); |
| 349 return; | 348 return; |
| 350 } | 349 } |
| 351 | 350 |
| 352 frame->Bind(std::move(frame_request), std::move(frame_host)); | 351 frame->Bind(std::move(frame_request), std::move(frame_host)); |
| 353 } | 352 } |
| 354 | 353 |
| 355 private: | 354 private: |
| 356 int32_t routing_id_highmark_; | 355 int32_t routing_id_highmark_; |
| 357 mojo::StrongBinding<mojom::FrameFactory> binding_; | |
| 358 }; | 356 }; |
| 359 | 357 |
| 360 void CreateFrameFactory(mojom::FrameFactoryRequest request) { | 358 void CreateFrameFactory(mojom::FrameFactoryRequest request) { |
| 361 new FrameFactoryImpl(std::move(request)); | 359 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(), |
| 360 std::move(request)); |
| 362 } | 361 } |
| 363 | 362 |
| 364 void SetupEmbeddedWorkerOnWorkerThread( | 363 void SetupEmbeddedWorkerOnWorkerThread( |
| 365 shell::mojom::InterfaceProviderRequest request, | 364 shell::mojom::InterfaceProviderRequest request, |
| 366 shell::mojom::InterfaceProviderPtrInfo remote_interfaces) { | 365 shell::mojom::InterfaceProviderPtrInfo remote_interfaces) { |
| 367 ServiceWorkerContextClient* client = | 366 ServiceWorkerContextClient* client = |
| 368 ServiceWorkerContextClient::ThreadSpecificInstance(); | 367 ServiceWorkerContextClient::ThreadSpecificInstance(); |
| 369 // It is possible for client to be null if for some reason the worker died | 368 // It is possible for client to be null if for some reason the worker died |
| 370 // before this call made it to the worker thread. In that case just do | 369 // before this call made it to the worker thread. In that case just do |
| 371 // nothing and let mojo close the connection. | 370 // nothing and let mojo close the connection. |
| 372 if (!client) | 371 if (!client) |
| 373 return; | 372 return; |
| 374 client->BindInterfaceProviders(std::move(request), | 373 client->BindInterfaceProviders(std::move(request), |
| 375 mojo::MakeProxy(std::move(remote_interfaces))); | 374 mojo::MakeProxy(std::move(remote_interfaces))); |
| 376 } | 375 } |
| 377 | 376 |
| 378 class EmbeddedWorkerSetupImpl : public mojom::EmbeddedWorkerSetup { | 377 class EmbeddedWorkerSetupImpl : public mojom::EmbeddedWorkerSetup { |
| 379 public: | 378 public: |
| 380 explicit EmbeddedWorkerSetupImpl( | 379 EmbeddedWorkerSetupImpl() = default; |
| 381 mojo::InterfaceRequest<mojom::EmbeddedWorkerSetup> request) | |
| 382 : binding_(this, std::move(request)) {} | |
| 383 | 380 |
| 384 void ExchangeInterfaceProviders( | 381 void ExchangeInterfaceProviders( |
| 385 int32_t thread_id, | 382 int32_t thread_id, |
| 386 shell::mojom::InterfaceProviderRequest request, | 383 shell::mojom::InterfaceProviderRequest request, |
| 387 shell::mojom::InterfaceProviderPtr remote_interfaces) override { | 384 shell::mojom::InterfaceProviderPtr remote_interfaces) override { |
| 388 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask( | 385 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask( |
| 389 FROM_HERE, | 386 FROM_HERE, |
| 390 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&request), | 387 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&request), |
| 391 base::Passed(remote_interfaces.PassInterface()))); | 388 base::Passed(remote_interfaces.PassInterface()))); |
| 392 } | 389 } |
| 393 | |
| 394 private: | |
| 395 mojo::StrongBinding<mojom::EmbeddedWorkerSetup> binding_; | |
| 396 }; | 390 }; |
| 397 | 391 |
| 398 void CreateEmbeddedWorkerSetup( | 392 void CreateEmbeddedWorkerSetup(mojom::EmbeddedWorkerSetupRequest request) { |
| 399 mojo::InterfaceRequest<mojom::EmbeddedWorkerSetup> request) { | 393 mojo::MakeStrongBinding(base::MakeUnique<EmbeddedWorkerSetupImpl>(), |
| 400 new EmbeddedWorkerSetupImpl(std::move(request)); | 394 std::move(request)); |
| 401 } | 395 } |
| 402 | 396 |
| 403 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( | 397 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( |
| 404 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 398 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 405 const gpu::SharedMemoryLimits& limits, | 399 const gpu::SharedMemoryLimits& limits, |
| 406 bool support_locking, | 400 bool support_locking, |
| 407 command_buffer_metrics::ContextType type, | 401 command_buffer_metrics::ContextType type, |
| 408 int32_t stream_id, | 402 int32_t stream_id, |
| 409 gpu::GpuStreamPriority stream_priority) { | 403 gpu::GpuStreamPriority stream_priority) { |
| 410 DCHECK(gpu_channel_host); | 404 DCHECK(gpu_channel_host); |
| (...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 if (blink::mainThreadIsolate()) { | 2239 if (blink::mainThreadIsolate()) { |
| 2246 blink::mainThreadIsolate()->MemoryPressureNotification( | 2240 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2247 v8::MemoryPressureLevel::kCritical); | 2241 v8::MemoryPressureLevel::kCritical); |
| 2248 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2242 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2249 v8::MemoryPressureLevel::kCritical); | 2243 v8::MemoryPressureLevel::kCritical); |
| 2250 } | 2244 } |
| 2251 } | 2245 } |
| 2252 | 2246 |
| 2253 | 2247 |
| 2254 } // namespace content | 2248 } // namespace content |
| OLD | NEW |