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

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

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 class RenderFrameSetupImpl : public mojom::RenderFrameSetup { 358 class RenderFrameSetupImpl : public mojom::RenderFrameSetup {
359 public: 359 public:
360 explicit RenderFrameSetupImpl( 360 explicit RenderFrameSetupImpl(
361 mojo::InterfaceRequest<mojom::RenderFrameSetup> request) 361 mojo::InterfaceRequest<mojom::RenderFrameSetup> request)
362 : routing_id_highmark_(-1), binding_(this, std::move(request)) {} 362 : routing_id_highmark_(-1), binding_(this, std::move(request)) {}
363 363
364 void ExchangeInterfaceProviders( 364 void ExchangeInterfaceProviders(
365 int32_t frame_routing_id, 365 int32_t frame_routing_id,
366 mojo::shell::mojom::InterfaceProviderRequest services, 366 shell::mojom::InterfaceProviderRequest services,
367 mojo::shell::mojom::InterfaceProviderPtr exposed_services) 367 shell::mojom::InterfaceProviderPtr exposed_services) override {
368 override {
369 // TODO(morrita): This is for investigating http://crbug.com/415059 and 368 // TODO(morrita): This is for investigating http://crbug.com/415059 and
370 // should be removed once it is fixed. 369 // should be removed once it is fixed.
371 CHECK_LT(routing_id_highmark_, frame_routing_id); 370 CHECK_LT(routing_id_highmark_, frame_routing_id);
372 routing_id_highmark_ = frame_routing_id; 371 routing_id_highmark_ = frame_routing_id;
373 372
374 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id); 373 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(frame_routing_id);
375 // We can receive a GetServiceProviderForFrame message for a frame not yet 374 // We can receive a GetServiceProviderForFrame message for a frame not yet
376 // created due to a race between the message and a ViewMsg_New IPC that 375 // created due to a race between the message and a ViewMsg_New IPC that
377 // triggers creation of the RenderFrame we want. 376 // triggers creation of the RenderFrame we want.
378 if (!frame) { 377 if (!frame) {
(...skipping 10 matching lines...) Expand all
389 int32_t routing_id_highmark_; 388 int32_t routing_id_highmark_;
390 mojo::StrongBinding<mojom::RenderFrameSetup> binding_; 389 mojo::StrongBinding<mojom::RenderFrameSetup> binding_;
391 }; 390 };
392 391
393 void CreateRenderFrameSetup( 392 void CreateRenderFrameSetup(
394 mojo::InterfaceRequest<mojom::RenderFrameSetup> request) { 393 mojo::InterfaceRequest<mojom::RenderFrameSetup> request) {
395 new RenderFrameSetupImpl(std::move(request)); 394 new RenderFrameSetupImpl(std::move(request));
396 } 395 }
397 396
398 void SetupEmbeddedWorkerOnWorkerThread( 397 void SetupEmbeddedWorkerOnWorkerThread(
399 mojo::shell::mojom::InterfaceProviderRequest services, 398 shell::mojom::InterfaceProviderRequest services,
400 mojo::shell::mojom::InterfaceProviderPtrInfo exposed_services) { 399 shell::mojom::InterfaceProviderPtrInfo exposed_services) {
401 ServiceWorkerContextClient* client = 400 ServiceWorkerContextClient* client =
402 ServiceWorkerContextClient::ThreadSpecificInstance(); 401 ServiceWorkerContextClient::ThreadSpecificInstance();
403 // It is possible for client to be null if for some reason the worker died 402 // It is possible for client to be null if for some reason the worker died
404 // before this call made it to the worker thread. In that case just do 403 // before this call made it to the worker thread. In that case just do
405 // nothing and let mojo close the connection. 404 // nothing and let mojo close the connection.
406 if (!client) 405 if (!client)
407 return; 406 return;
408 client->BindServiceRegistry(std::move(services), 407 client->BindServiceRegistry(std::move(services),
409 mojo::MakeProxy(std::move(exposed_services))); 408 mojo::MakeProxy(std::move(exposed_services)));
410 } 409 }
411 410
412 class EmbeddedWorkerSetupImpl : public mojom::EmbeddedWorkerSetup { 411 class EmbeddedWorkerSetupImpl : public mojom::EmbeddedWorkerSetup {
413 public: 412 public:
414 explicit EmbeddedWorkerSetupImpl( 413 explicit EmbeddedWorkerSetupImpl(
415 mojo::InterfaceRequest<mojom::EmbeddedWorkerSetup> request) 414 mojo::InterfaceRequest<mojom::EmbeddedWorkerSetup> request)
416 : binding_(this, std::move(request)) {} 415 : binding_(this, std::move(request)) {}
417 416
418 void ExchangeInterfaceProviders( 417 void ExchangeInterfaceProviders(
419 int32_t thread_id, 418 int32_t thread_id,
420 mojo::shell::mojom::InterfaceProviderRequest services, 419 shell::mojom::InterfaceProviderRequest services,
421 mojo::shell::mojom::InterfaceProviderPtr exposed_services) override { 420 shell::mojom::InterfaceProviderPtr exposed_services) override {
422 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask( 421 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask(
423 FROM_HERE, 422 FROM_HERE,
424 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&services), 423 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&services),
425 base::Passed(exposed_services.PassInterface()))); 424 base::Passed(exposed_services.PassInterface())));
426 } 425 }
427 426
428 private: 427 private:
429 mojo::StrongBinding<mojom::EmbeddedWorkerSetup> binding_; 428 mojo::StrongBinding<mojom::EmbeddedWorkerSetup> binding_;
430 }; 429 };
431 430
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 PendingRenderFrameConnectMap::iterator it = 1041 PendingRenderFrameConnectMap::iterator it =
1043 pending_render_frame_connects_.find(routing_id); 1042 pending_render_frame_connects_.find(routing_id);
1044 if (it == pending_render_frame_connects_.end()) 1043 if (it == pending_render_frame_connects_.end())
1045 return; 1044 return;
1046 1045
1047 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); 1046 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id);
1048 if (!frame) 1047 if (!frame)
1049 return; 1048 return;
1050 1049
1051 scoped_refptr<PendingRenderFrameConnect> connection(it->second); 1050 scoped_refptr<PendingRenderFrameConnect> connection(it->second);
1052 mojo::shell::mojom::InterfaceProviderRequest services( 1051 shell::mojom::InterfaceProviderRequest services(
1053 std::move(connection->services())); 1052 std::move(connection->services()));
1054 mojo::shell::mojom::InterfaceProviderPtr exposed_services( 1053 shell::mojom::InterfaceProviderPtr exposed_services(
1055 std::move(connection->exposed_services())); 1054 std::move(connection->exposed_services()));
1056 exposed_services.set_connection_error_handler(mojo::Closure()); 1055 exposed_services.set_connection_error_handler(mojo::Closure());
1057 pending_render_frame_connects_.erase(it); 1056 pending_render_frame_connects_.erase(it);
1058 1057
1059 frame->BindServiceRegistry(std::move(services), std::move(exposed_services)); 1058 frame->BindServiceRegistry(std::move(services), std::move(exposed_services));
1060 } 1059 }
1061 1060
1062 void RenderThreadImpl::RemoveRoute(int32_t routing_id) { 1061 void RenderThreadImpl::RemoveRoute(int32_t routing_id) {
1063 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id); 1062 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id);
1064 } 1063 }
(...skipping 10 matching lines...) Expand all
1075 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32_t routing_id) { 1074 void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32_t routing_id) {
1076 RemoveRoute(routing_id); 1075 RemoveRoute(routing_id);
1077 if (devtools_agent_message_filter_.get()) { 1076 if (devtools_agent_message_filter_.get()) {
1078 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread( 1077 devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread(
1079 routing_id); 1078 routing_id);
1080 } 1079 }
1081 } 1080 }
1082 1081
1083 void RenderThreadImpl::RegisterPendingRenderFrameConnect( 1082 void RenderThreadImpl::RegisterPendingRenderFrameConnect(
1084 int routing_id, 1083 int routing_id,
1085 mojo::shell::mojom::InterfaceProviderRequest services, 1084 shell::mojom::InterfaceProviderRequest services,
1086 mojo::shell::mojom::InterfaceProviderPtr exposed_services) { 1085 shell::mojom::InterfaceProviderPtr exposed_services) {
1087 std::pair<PendingRenderFrameConnectMap::iterator, bool> result = 1086 std::pair<PendingRenderFrameConnectMap::iterator, bool> result =
1088 pending_render_frame_connects_.insert(std::make_pair( 1087 pending_render_frame_connects_.insert(std::make_pair(
1089 routing_id, 1088 routing_id,
1090 make_scoped_refptr(new PendingRenderFrameConnect( 1089 make_scoped_refptr(new PendingRenderFrameConnect(
1091 routing_id, std::move(services), std::move(exposed_services))))); 1090 routing_id, std::move(services), std::move(exposed_services)))));
1092 CHECK(result.second) << "Inserting a duplicate item."; 1091 CHECK(result.second) << "Inserting a duplicate item.";
1093 } 1092 }
1094 1093
1095 mojom::StoragePartitionService* RenderThreadImpl::GetStoragePartitionService() { 1094 mojom::StoragePartitionService* RenderThreadImpl::GetStoragePartitionService() {
1096 return storage_partition_service_.get(); 1095 return storage_partition_service_.get();
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 void RenderThreadImpl::ReleaseFreeMemory() { 2119 void RenderThreadImpl::ReleaseFreeMemory() {
2121 base::allocator::ReleaseFreeMemory(); 2120 base::allocator::ReleaseFreeMemory();
2122 discardable_shared_memory_manager()->ReleaseFreeMemory(); 2121 discardable_shared_memory_manager()->ReleaseFreeMemory();
2123 2122
2124 if (blink_platform_impl_) 2123 if (blink_platform_impl_)
2125 blink::decommitFreeableMemory(); 2124 blink::decommitFreeableMemory();
2126 } 2125 }
2127 2126
2128 RenderThreadImpl::PendingRenderFrameConnect::PendingRenderFrameConnect( 2127 RenderThreadImpl::PendingRenderFrameConnect::PendingRenderFrameConnect(
2129 int routing_id, 2128 int routing_id,
2130 mojo::shell::mojom::InterfaceProviderRequest services, 2129 shell::mojom::InterfaceProviderRequest services,
2131 mojo::shell::mojom::InterfaceProviderPtr exposed_services) 2130 shell::mojom::InterfaceProviderPtr exposed_services)
2132 : routing_id_(routing_id), 2131 : routing_id_(routing_id),
2133 services_(std::move(services)), 2132 services_(std::move(services)),
2134 exposed_services_(std::move(exposed_services)) { 2133 exposed_services_(std::move(exposed_services)) {
2135 // The RenderFrame may be deleted before the ExchangeInterfaceProviders 2134 // The RenderFrame may be deleted before the ExchangeInterfaceProviders
2136 // message is received. In that case, the RenderFrameHost should close the 2135 // message is received. In that case, the RenderFrameHost should close the
2137 // connection, which is detected by setting an error handler on 2136 // connection, which is detected by setting an error handler on
2138 // |exposed_services_|. 2137 // |exposed_services_|.
2139 exposed_services_.set_connection_error_handler(base::Bind( 2138 exposed_services_.set_connection_error_handler(base::Bind(
2140 &RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError, 2139 &RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError,
2141 base::Unretained(this))); 2140 base::Unretained(this)));
2142 } 2141 }
2143 2142
2144 RenderThreadImpl::PendingRenderFrameConnect::~PendingRenderFrameConnect() { 2143 RenderThreadImpl::PendingRenderFrameConnect::~PendingRenderFrameConnect() {
2145 } 2144 }
2146 2145
2147 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2146 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2148 size_t erased = 2147 size_t erased =
2149 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2148 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2150 routing_id_); 2149 routing_id_);
2151 DCHECK_EQ(1u, erased); 2150 DCHECK_EQ(1u, erased);
2152 } 2151 }
2153 2152
2154 } // namespace content 2153 } // 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