Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2821473002: Service CreateNewWindow on the UI thread with a new mojo interface (Closed)
Patch Set: MakeShared goodness Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 base::Histogram* histogram = static_cast<base::Histogram*>(hist); 314 base::Histogram* histogram = static_cast<base::Histogram*>(hist);
315 histogram->Add(sample); 315 histogram->Add(sample);
316 } 316 }
317 317
318 class FrameFactoryImpl : public mojom::FrameFactory { 318 class FrameFactoryImpl : public mojom::FrameFactory {
319 public: 319 public:
320 FrameFactoryImpl() : routing_id_highmark_(-1) {} 320 FrameFactoryImpl() : routing_id_highmark_(-1) {}
321 321
322 private: 322 private:
323 // mojom::FrameFactory: 323 // mojom::FrameFactory:
324 void CreateFrame(int32_t frame_routing_id, 324 void CreateFrame(
325 mojom::FrameRequest frame_request, 325 int32_t frame_routing_id,
326 mojom::FrameHostPtr frame_host) override { 326 mojom::FrameRequest frame_request,
327 mojom::FrameHostInterfaceBrokerPtr frame_host_interface_broker) override {
327 // TODO(morrita): This is for investigating http://crbug.com/415059 and 328 // TODO(morrita): This is for investigating http://crbug.com/415059 and
328 // should be removed once it is fixed. 329 // should be removed once it is fixed.
329 CHECK_LT(routing_id_highmark_, frame_routing_id); 330 CHECK_LT(routing_id_highmark_, frame_routing_id);
330 routing_id_highmark_ = frame_routing_id; 331 routing_id_highmark_ = frame_routing_id;
331 332
332 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); 333 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id);
333 // We can receive a GetServiceProviderForFrame message for a frame not yet 334 // We can receive a GetServiceProviderForFrame message for a frame not yet
334 // created due to a race between the message and a 335 // created due to a race between the message and a
335 // mojom::Renderer::CreateView IPC that triggers creation of the RenderFrame 336 // mojom::Renderer::CreateView IPC that triggers creation of the RenderFrame
336 // we want. 337 // we want.
337 if (!frame) { 338 if (!frame) {
338 RenderThreadImpl::current()->RegisterPendingFrameCreate( 339 RenderThreadImpl::current()->RegisterPendingFrameCreate(
339 frame_routing_id, std::move(frame_request), std::move(frame_host)); 340 frame_routing_id, std::move(frame_request),
341 std::move(frame_host_interface_broker));
340 return; 342 return;
341 } 343 }
342 344
343 frame->BindFrame(std::move(frame_request), std::move(frame_host)); 345 frame->BindFrame(std::move(frame_request),
346 std::move(frame_host_interface_broker));
344 } 347 }
345 348
346 private: 349 private:
347 int32_t routing_id_highmark_; 350 int32_t routing_id_highmark_;
348 }; 351 };
349 352
350 void CreateFrameFactory(mojom::FrameFactoryRequest request) { 353 void CreateFrameFactory(mojom::FrameFactoryRequest request) {
351 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(), 354 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(),
352 std::move(request)); 355 std::move(request));
353 } 356 }
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 ChildThreadImpl::GetRouter()->AddRoute(routing_id, listener); 992 ChildThreadImpl::GetRouter()->AddRoute(routing_id, listener);
990 auto it = pending_frame_creates_.find(routing_id); 993 auto it = pending_frame_creates_.find(routing_id);
991 if (it == pending_frame_creates_.end()) 994 if (it == pending_frame_creates_.end())
992 return; 995 return;
993 996
994 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); 997 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id);
995 if (!frame) 998 if (!frame)
996 return; 999 return;
997 1000
998 scoped_refptr<PendingFrameCreate> create(it->second); 1001 scoped_refptr<PendingFrameCreate> create(it->second);
999 frame->BindFrame(it->second->TakeFrameRequest(), it->second->TakeFrameHost()); 1002 frame->BindFrame(it->second->TakeFrameRequest(),
1003 it->second->TakeInterfaceBroker());
1000 pending_frame_creates_.erase(it); 1004 pending_frame_creates_.erase(it);
1001 } 1005 }
1002 1006
1003 void RenderThreadImpl::RemoveRoute(int32_t routing_id) { 1007 void RenderThreadImpl::RemoveRoute(int32_t routing_id) {
1004 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id); 1008 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id);
1005 } 1009 }
1006 1010
1007 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32_t routing_id, 1011 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32_t routing_id,
1008 IPC::Listener* listener) { 1012 IPC::Listener* listener) {
1009 AddRoute(routing_id, listener); 1013 AddRoute(routing_id, listener);
1010 if (devtools_agent_message_filter_.get()) { 1014 if (devtools_agent_message_filter_.get()) {
1011 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( 1015 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread(
1012 routing_id); 1016 routing_id);
1013 } 1017 }
1014 } 1018 }
1015 1019
1016 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32_t routing_id) { 1020 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32_t routing_id) {
1017 RemoveRoute(routing_id); 1021 RemoveRoute(routing_id);
1018 if (devtools_agent_message_filter_.get()) { 1022 if (devtools_agent_message_filter_.get()) {
1019 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( 1023 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread(
1020 routing_id); 1024 routing_id);
1021 } 1025 }
1022 } 1026 }
1023 1027
1024 void RenderThreadImpl::RegisterPendingFrameCreate( 1028 void RenderThreadImpl::RegisterPendingFrameCreate(
1025 int routing_id, 1029 int routing_id,
1026 mojom::FrameRequest frame_request, 1030 mojom::FrameRequest frame_request,
1027 mojom::FrameHostPtr frame_host) { 1031 mojom::FrameHostInterfaceBrokerPtr frame_host_interface_broker) {
1028 std::pair<PendingFrameCreateMap::iterator, bool> result = 1032 std::pair<PendingFrameCreateMap::iterator, bool> result =
1029 pending_frame_creates_.insert(std::make_pair( 1033 pending_frame_creates_.insert(std::make_pair(
1030 routing_id, 1034 routing_id, make_scoped_refptr(new PendingFrameCreate(
1031 make_scoped_refptr(new PendingFrameCreate( 1035 routing_id, std::move(frame_request),
1032 routing_id, std::move(frame_request), std::move(frame_host))))); 1036 std::move(frame_host_interface_broker)))));
1033 CHECK(result.second) << "Inserting a duplicate item."; 1037 CHECK(result.second) << "Inserting a duplicate item.";
1034 } 1038 }
1035 1039
1036 mojom::StoragePartitionService* RenderThreadImpl::GetStoragePartitionService() { 1040 mojom::StoragePartitionService* RenderThreadImpl::GetStoragePartitionService() {
1037 return storage_partition_service_.get(); 1041 return storage_partition_service_.get();
1038 } 1042 }
1039 1043
1040 int RenderThreadImpl::GenerateRoutingID() { 1044 int RenderThreadImpl::GenerateRoutingID() {
1041 int32_t routing_id = MSG_ROUTING_NONE; 1045 int32_t routing_id = MSG_ROUTING_NONE;
1042 render_message_filter()->GenerateRoutingID(&routing_id); 1046 render_message_filter()->GenerateRoutingID(&routing_id);
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 base::allocator::ReleaseFreeMemory(); 2393 base::allocator::ReleaseFreeMemory();
2390 discardable_shared_memory_manager_->ReleaseFreeMemory(); 2394 discardable_shared_memory_manager_->ReleaseFreeMemory();
2391 2395
2392 if (blink_platform_impl_) 2396 if (blink_platform_impl_)
2393 blink::DecommitFreeableMemory(); 2397 blink::DecommitFreeableMemory();
2394 } 2398 }
2395 2399
2396 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate( 2400 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate(
2397 int routing_id, 2401 int routing_id,
2398 mojom::FrameRequest frame_request, 2402 mojom::FrameRequest frame_request,
2399 mojom::FrameHostPtr frame_host) 2403 mojom::FrameHostInterfaceBrokerPtr frame_host_interface_broker)
2400 : routing_id_(routing_id), 2404 : routing_id_(routing_id),
2401 frame_request_(std::move(frame_request)), 2405 frame_request_(std::move(frame_request)),
2402 frame_host_(std::move(frame_host)) { 2406 frame_host_interface_broker_(std::move(frame_host_interface_broker)) {
2403 // The RenderFrame may be deleted before the CreateFrame message is received. 2407 // The RenderFrame may be deleted before the CreateFrame message is received.
2404 // In that case, the RenderFrameHost should cancel the create, which is 2408 // In that case, the RenderFrameHost should cancel the create, which is
2405 // detected by setting an error handler on |frame_host_|. 2409 // detected by setting an error handler on |frame_host_interface_broker_|.
2406 frame_host_.set_connection_error_handler(base::Bind( 2410 frame_host_interface_broker_.set_connection_error_handler(
2407 &RenderThreadImpl::PendingFrameCreate::OnConnectionError, 2411 base::Bind(&RenderThreadImpl::PendingFrameCreate::OnConnectionError,
2408 base::Unretained(this))); 2412 base::Unretained(this)));
2409 } 2413 }
2410 2414
2411 RenderThreadImpl::PendingFrameCreate::~PendingFrameCreate() { 2415 RenderThreadImpl::PendingFrameCreate::~PendingFrameCreate() {
2412 } 2416 }
2413 2417
2414 void RenderThreadImpl::PendingFrameCreate::OnConnectionError() { 2418 void RenderThreadImpl::PendingFrameCreate::OnConnectionError() {
2415 size_t erased = 2419 size_t erased =
2416 RenderThreadImpl::current()->pending_frame_creates_.erase(routing_id_); 2420 RenderThreadImpl::current()->pending_frame_creates_.erase(routing_id_);
2417 DCHECK_EQ(1u, erased); 2421 DCHECK_EQ(1u, erased);
2418 } 2422 }
(...skipping 29 matching lines...) Expand all
2448 } 2452 }
2449 } 2453 }
2450 2454
2451 void RenderThreadImpl::OnRendererInterfaceRequest( 2455 void RenderThreadImpl::OnRendererInterfaceRequest(
2452 mojom::RendererAssociatedRequest request) { 2456 mojom::RendererAssociatedRequest request) {
2453 DCHECK(!renderer_binding_.is_bound()); 2457 DCHECK(!renderer_binding_.is_bound());
2454 renderer_binding_.Bind(std::move(request)); 2458 renderer_binding_.Bind(std::move(request));
2455 } 2459 }
2456 2460
2457 } // namespace content 2461 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698