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

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

Issue 1686223002: Move InterfaceProvider into the shell::mojom namespace like the rest of the shell interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 365 }
366 366
367 class RenderFrameSetupImpl : public RenderFrameSetup { 367 class RenderFrameSetupImpl : public RenderFrameSetup {
368 public: 368 public:
369 explicit RenderFrameSetupImpl( 369 explicit RenderFrameSetupImpl(
370 mojo::InterfaceRequest<RenderFrameSetup> request) 370 mojo::InterfaceRequest<RenderFrameSetup> request)
371 : routing_id_highmark_(-1), binding_(this, std::move(request)) {} 371 : routing_id_highmark_(-1), binding_(this, std::move(request)) {}
372 372
373 void ExchangeInterfaceProviders( 373 void ExchangeInterfaceProviders(
374 int32_t frame_routing_id, 374 int32_t frame_routing_id,
375 mojo::InterfaceRequest<mojo::InterfaceProvider> services, 375 mojo::shell::mojom::InterfaceProviderRequest services,
376 mojo::InterfaceProviderPtr exposed_services) 376 mojo::shell::mojom::InterfaceProviderPtr exposed_services)
377 override { 377 override {
378 // TODO(morrita): This is for investigating http://crbug.com/415059 and 378 // TODO(morrita): This is for investigating http://crbug.com/415059 and
379 // should be removed once it is fixed. 379 // should be removed once it is fixed.
380 CHECK_LT(routing_id_highmark_, frame_routing_id); 380 CHECK_LT(routing_id_highmark_, frame_routing_id);
381 routing_id_highmark_ = frame_routing_id; 381 routing_id_highmark_ = frame_routing_id;
382 382
383 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); 383 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id);
384 // We can receive a GetServiceProviderForFrame message for a frame not yet 384 // We can receive a GetServiceProviderForFrame message for a frame not yet
385 // created due to a race between the message and a ViewMsg_New IPC that 385 // created due to a race between the message and a ViewMsg_New IPC that
386 // triggers creation of the RenderFrame we want. 386 // triggers creation of the RenderFrame we want.
(...skipping 20 matching lines...) Expand all
407 blink::WebGraphicsContext3D::Attributes attributes; 407 blink::WebGraphicsContext3D::Attributes attributes;
408 attributes.shareResources = true; 408 attributes.shareResources = true;
409 attributes.depth = false; 409 attributes.depth = false;
410 attributes.stencil = false; 410 attributes.stencil = false;
411 attributes.antialias = false; 411 attributes.antialias = false;
412 attributes.noAutomaticFlushes = true; 412 attributes.noAutomaticFlushes = true;
413 return attributes; 413 return attributes;
414 } 414 }
415 415
416 void SetupEmbeddedWorkerOnWorkerThread( 416 void SetupEmbeddedWorkerOnWorkerThread(
417 mojo::InterfaceRequest<mojo::InterfaceProvider> services, 417 mojo::shell::mojom::InterfaceProviderRequest services,
418 mojo::InterfacePtrInfo<mojo::InterfaceProvider> exposed_services) { 418 mojo::shell::mojom::InterfaceProviderPtrInfo exposed_services) {
419 ServiceWorkerContextClient* client = 419 ServiceWorkerContextClient* client =
420 ServiceWorkerContextClient::ThreadSpecificInstance(); 420 ServiceWorkerContextClient::ThreadSpecificInstance();
421 // It is possible for client to be null if for some reason the worker died 421 // It is possible for client to be null if for some reason the worker died
422 // before this call made it to the worker thread. In that case just do 422 // before this call made it to the worker thread. In that case just do
423 // nothing and let mojo close the connection. 423 // nothing and let mojo close the connection.
424 if (!client) 424 if (!client)
425 return; 425 return;
426 client->BindServiceRegistry(std::move(services), 426 client->BindServiceRegistry(std::move(services),
427 mojo::MakeProxy(std::move(exposed_services))); 427 mojo::MakeProxy(std::move(exposed_services)));
428 } 428 }
429 429
430 class EmbeddedWorkerSetupImpl : public EmbeddedWorkerSetup { 430 class EmbeddedWorkerSetupImpl : public EmbeddedWorkerSetup {
431 public: 431 public:
432 explicit EmbeddedWorkerSetupImpl( 432 explicit EmbeddedWorkerSetupImpl(
433 mojo::InterfaceRequest<EmbeddedWorkerSetup> request) 433 mojo::InterfaceRequest<EmbeddedWorkerSetup> request)
434 : binding_(this, std::move(request)) {} 434 : binding_(this, std::move(request)) {}
435 435
436 void ExchangeInterfaceProviders( 436 void ExchangeInterfaceProviders(
437 int32_t thread_id, 437 int32_t thread_id,
438 mojo::InterfaceRequest<mojo::InterfaceProvider> services, 438 mojo::shell::mojom::InterfaceProviderRequest services,
439 mojo::InterfaceProviderPtr exposed_services) override { 439 mojo::shell::mojom::InterfaceProviderPtr exposed_services) override {
440 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask( 440 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask(
441 FROM_HERE, 441 FROM_HERE,
442 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&services), 442 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&services),
443 base::Passed(exposed_services.PassInterface()))); 443 base::Passed(exposed_services.PassInterface())));
444 } 444 }
445 445
446 private: 446 private:
447 mojo::StrongBinding<EmbeddedWorkerSetup> binding_; 447 mojo::StrongBinding<EmbeddedWorkerSetup> binding_;
448 }; 448 };
449 449
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 PendingRenderFrameConnectMap::iterator it = 1080 PendingRenderFrameConnectMap::iterator it =
1081 pending_render_frame_connects_.find(routing_id); 1081 pending_render_frame_connects_.find(routing_id);
1082 if (it == pending_render_frame_connects_.end()) 1082 if (it == pending_render_frame_connects_.end())
1083 return; 1083 return;
1084 1084
1085 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); 1085 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id);
1086 if (!frame) 1086 if (!frame)
1087 return; 1087 return;
1088 1088
1089 scoped_refptr<PendingRenderFrameConnect> connection(it->second); 1089 scoped_refptr<PendingRenderFrameConnect> connection(it->second);
1090 mojo::InterfaceRequest<mojo::InterfaceProvider> services( 1090 mojo::shell::mojom::InterfaceProviderRequest services(
1091 std::move(connection->services())); 1091 std::move(connection->services()));
1092 mojo::InterfaceProviderPtr exposed_services( 1092 mojo::shell::mojom::InterfaceProviderPtr exposed_services(
1093 std::move(connection->exposed_services())); 1093 std::move(connection->exposed_services()));
1094 exposed_services.set_connection_error_handler(mojo::Closure()); 1094 exposed_services.set_connection_error_handler(mojo::Closure());
1095 pending_render_frame_connects_.erase(it); 1095 pending_render_frame_connects_.erase(it);
1096 1096
1097 frame->BindServiceRegistry(std::move(services), std::move(exposed_services)); 1097 frame->BindServiceRegistry(std::move(services), std::move(exposed_services));
1098 } 1098 }
1099 1099
1100 void RenderThreadImpl::RemoveRoute(int32_t routing_id) { 1100 void RenderThreadImpl::RemoveRoute(int32_t routing_id) {
1101 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id); 1101 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id);
1102 } 1102 }
(...skipping 10 matching lines...) Expand all
1113 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32_t routing_id) { 1113 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32_t routing_id) {
1114 RemoveRoute(routing_id); 1114 RemoveRoute(routing_id);
1115 if (devtools_agent_message_filter_.get()) { 1115 if (devtools_agent_message_filter_.get()) {
1116 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( 1116 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread(
1117 routing_id); 1117 routing_id);
1118 } 1118 }
1119 } 1119 }
1120 1120
1121 void RenderThreadImpl::RegisterPendingRenderFrameConnect( 1121 void RenderThreadImpl::RegisterPendingRenderFrameConnect(
1122 int routing_id, 1122 int routing_id,
1123 mojo::InterfaceRequest<mojo::InterfaceProvider> services, 1123 mojo::shell::mojom::InterfaceProviderRequest services,
1124 mojo::InterfaceProviderPtr exposed_services) { 1124 mojo::shell::mojom::InterfaceProviderPtr exposed_services) {
1125 std::pair<PendingRenderFrameConnectMap::iterator, bool> result = 1125 std::pair<PendingRenderFrameConnectMap::iterator, bool> result =
1126 pending_render_frame_connects_.insert(std::make_pair( 1126 pending_render_frame_connects_.insert(std::make_pair(
1127 routing_id, 1127 routing_id,
1128 make_scoped_refptr(new PendingRenderFrameConnect( 1128 make_scoped_refptr(new PendingRenderFrameConnect(
1129 routing_id, std::move(services), std::move(exposed_services))))); 1129 routing_id, std::move(services), std::move(exposed_services)))));
1130 CHECK(result.second) << "Inserting a duplicate item."; 1130 CHECK(result.second) << "Inserting a duplicate item.";
1131 } 1131 }
1132 1132
1133 int RenderThreadImpl::GenerateRoutingID() { 1133 int RenderThreadImpl::GenerateRoutingID() {
1134 int routing_id = MSG_ROUTING_NONE; 1134 int routing_id = MSG_ROUTING_NONE;
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 void RenderThreadImpl::ReleaseFreeMemory() { 2121 void RenderThreadImpl::ReleaseFreeMemory() {
2122 base::allocator::ReleaseFreeMemory(); 2122 base::allocator::ReleaseFreeMemory();
2123 discardable_shared_memory_manager()->ReleaseFreeMemory(); 2123 discardable_shared_memory_manager()->ReleaseFreeMemory();
2124 2124
2125 if (blink_platform_impl_) 2125 if (blink_platform_impl_)
2126 blink::decommitFreeableMemory(); 2126 blink::decommitFreeableMemory();
2127 } 2127 }
2128 2128
2129 RenderThreadImpl::PendingRenderFrameConnect::PendingRenderFrameConnect( 2129 RenderThreadImpl::PendingRenderFrameConnect::PendingRenderFrameConnect(
2130 int routing_id, 2130 int routing_id,
2131 mojo::InterfaceRequest<mojo::InterfaceProvider> services, 2131 mojo::shell::mojom::InterfaceProviderRequest services,
2132 mojo::InterfaceProviderPtr exposed_services) 2132 mojo::shell::mojom::InterfaceProviderPtr exposed_services)
2133 : routing_id_(routing_id), 2133 : routing_id_(routing_id),
2134 services_(std::move(services)), 2134 services_(std::move(services)),
2135 exposed_services_(std::move(exposed_services)) { 2135 exposed_services_(std::move(exposed_services)) {
2136 // The RenderFrame may be deleted before the ExchangeInterfaceProviders 2136 // The RenderFrame may be deleted before the ExchangeInterfaceProviders
2137 // message is received. In that case, the RenderFrameHost should close the 2137 // message is received. In that case, the RenderFrameHost should close the
2138 // connection, which is detected by setting an error handler on 2138 // connection, which is detected by setting an error handler on
2139 // |exposed_services_|. 2139 // |exposed_services_|.
2140 exposed_services_.set_connection_error_handler(base::Bind( 2140 exposed_services_.set_connection_error_handler(base::Bind(
2141 &RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError, 2141 &RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError,
2142 base::Unretained(this))); 2142 base::Unretained(this)));
2143 } 2143 }
2144 2144
2145 RenderThreadImpl::PendingRenderFrameConnect::~PendingRenderFrameConnect() { 2145 RenderThreadImpl::PendingRenderFrameConnect::~PendingRenderFrameConnect() {
2146 } 2146 }
2147 2147
2148 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2148 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2149 size_t erased = 2149 size_t erased =
2150 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2150 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2151 routing_id_); 2151 routing_id_);
2152 DCHECK_EQ(1u, erased); 2152 DCHECK_EQ(1u, erased);
2153 } 2153 }
2154 2154
2155 } // namespace content 2155 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/service_worker/service_worker_context_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698