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

Unified Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 2840343002: network service: pass a URLLoaderFactory to renderers on SW registration
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/service_worker/service_worker_messages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_blink_platform_impl.cc
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index b8c509a4639be4eb678d72a76e81e132d2e932b4..97fcca998c5a262574d0a908df75149dcd0b2b3d 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -31,6 +31,7 @@
#include "content/child/indexed_db/webidbfactory_impl.h"
#include "content/child/quota_dispatcher.h"
#include "content/child/quota_message_filter.h"
+#include "content/child/service_worker/service_worker_dispatcher.h"
#include "content/child/storage_util.h"
#include "content/child/thread_safe_sender.h"
#include "content/child/web_database_observer_impl.h"
@@ -307,21 +308,28 @@ std::unique_ptr<blink::WebURLLoader>
RendererBlinkPlatformImpl::CreateURLLoader() {
ChildThreadImpl* child_thread = ChildThreadImpl::current();
- mojom::URLLoaderFactory* factory =
- url_loader_factory_ ? url_loader_factory_.get()
- : network_service_url_loader_factory_.get();
- if (!factory && child_thread) {
- bool network_service_enabled =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableNetworkService);
- if (network_service_enabled) {
- connector_->BindInterface(mojom::kNetworkServiceName,
- &network_service_url_loader_factory_);
- factory = network_service_url_loader_factory_.get();
- } else {
+ const bool network_service_enabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNetworkService);
+
+ mojom::URLLoaderFactory* factory = nullptr;
+ if (!network_service_enabled) {
+ if (child_thread) {
child_thread->channel()->GetRemoteAssociatedInterface(
&url_loader_factory_);
- factory = url_loader_factory_.get();
+ }
+ factory = url_loader_factory_.get();
+ } else {
+ ServiceWorkerDispatcher* sw_dispatcher =
+ ServiceWorkerDispatcher::GetThreadSpecificInstance();
+ if (sw_dispatcher && sw_dispatcher->GetURLLoaderFactory()) {
+ factory = sw_dispatcher->GetURLLoaderFactory();
+ } else {
+ if (!network_service_url_loader_factory_) {
+ connector_->BindInterface(mojom::kNetworkServiceName,
+ &network_service_url_loader_factory_);
+ }
+ factory = network_service_url_loader_factory_.get();
}
}
« no previous file with comments | « content/common/service_worker/service_worker_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698