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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 459003002: Plumbs URLRequestContext and CacheBlobStorageContext down to cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cache1
Patch Set: Addresses michaeln's comments from PS5 Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/fileapi/chrome_blob_storage_context.h"
9 #include "content/browser/message_port_message_filter.h" 10 #include "content/browser/message_port_message_filter.h"
10 #include "content/browser/message_port_service.h" 11 #include "content/browser/message_port_service.h"
11 #include "content/browser/service_worker/embedded_worker_registry.h" 12 #include "content/browser/service_worker/embedded_worker_registry.h"
12 #include "content/browser/service_worker/service_worker_context_core.h" 13 #include "content/browser/service_worker/service_worker_context_core.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" 14 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "content/browser/service_worker/service_worker_handle.h" 15 #include "content/browser/service_worker/service_worker_handle.h"
15 #include "content/browser/service_worker/service_worker_registration.h" 16 #include "content/browser/service_worker/service_worker_registration.h"
16 #include "content/browser/service_worker/service_worker_utils.h" 17 #include "content/browser/service_worker/service_worker_utils.h"
17 #include "content/common/service_worker/embedded_worker_messages.h" 18 #include "content/common/service_worker/embedded_worker_messages.h"
18 #include "content/common/service_worker/service_worker_messages.h" 19 #include "content/common/service_worker/service_worker_messages.h"
19 #include "ipc/ipc_message_macros.h" 20 #include "ipc/ipc_message_macros.h"
21 #include "net/url_request/url_request_context_getter.h"
20 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" 22 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
24 #include "webkit/browser/blob/blob_storage_context.h"
22 25
23 using blink::WebServiceWorkerError; 26 using blink::WebServiceWorkerError;
24 27
25 namespace content { 28 namespace content {
26 29
27 namespace { 30 namespace {
28 31
29 const char kShutdownErrorMessage[] = 32 const char kShutdownErrorMessage[] =
30 "The Service Worker system has shutdown."; 33 "The Service Worker system has shutdown.";
31 34
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 70
68 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { 71 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {
69 if (GetContext()) { 72 if (GetContext()) {
70 GetContext()->RemoveAllProviderHostsForProcess(render_process_id_); 73 GetContext()->RemoveAllProviderHostsForProcess(render_process_id_);
71 GetContext()->embedded_worker_registry()->RemoveChildProcessSender( 74 GetContext()->embedded_worker_registry()->RemoveChildProcessSender(
72 render_process_id_); 75 render_process_id_);
73 } 76 }
74 } 77 }
75 78
76 void ServiceWorkerDispatcherHost::Init( 79 void ServiceWorkerDispatcherHost::Init(
77 ServiceWorkerContextWrapper* context_wrapper) { 80 ServiceWorkerContextWrapper* context_wrapper,
81 net::URLRequestContextGetter* request_context,
82 ChromeBlobStorageContext* blob_storage) {
78 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 83 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
79 BrowserThread::PostTask( 84 BrowserThread::PostTask(BrowserThread::IO,
80 BrowserThread::IO, FROM_HERE, 85 FROM_HERE,
81 base::Bind(&ServiceWorkerDispatcherHost::Init, 86 base::Bind(&ServiceWorkerDispatcherHost::Init,
82 this, make_scoped_refptr(context_wrapper))); 87 this,
88 make_scoped_refptr(context_wrapper),
89 make_scoped_refptr(request_context),
90 make_scoped_refptr(blob_storage)));
83 return; 91 return;
84 } 92 }
85 context_wrapper_ = context_wrapper; 93 context_wrapper_ = context_wrapper;
86 GetContext()->embedded_worker_registry()->AddChildProcessSender( 94 GetContext()->embedded_worker_registry()->AddChildProcessSender(
87 render_process_id_, this); 95 render_process_id_, this);
96 if (blob_storage->context())
michaeln 2014/08/13 02:03:37 can that ever be null?
jkarlin 2014/08/13 11:56:42 No, not on the IO thread. Done.
97 context_wrapper_->SetBlobParametersForCache(
98 request_context->GetURLRequestContext(),
99 blob_storage->context()->AsWeakPtr());
88 } 100 }
89 101
90 void ServiceWorkerDispatcherHost::OnFilterAdded(IPC::Sender* sender) { 102 void ServiceWorkerDispatcherHost::OnFilterAdded(IPC::Sender* sender) {
91 BrowserMessageFilter::OnFilterAdded(sender); 103 BrowserMessageFilter::OnFilterAdded(sender);
92 channel_ready_ = true; 104 channel_ready_ = true;
93 std::vector<IPC::Message*> messages; 105 std::vector<IPC::Message*> messages;
94 pending_messages_.release(&messages); 106 pending_messages_.release(&messages);
95 for (size_t i = 0; i < messages.size(); ++i) { 107 for (size_t i = 0; i < messages.size(); ++i) {
96 BrowserMessageFilter::Send(messages[i]); 108 BrowserMessageFilter::Send(messages[i]);
97 } 109 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 status, &error_type, &error_message); 501 status, &error_type, &error_message);
490 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 502 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
491 thread_id, request_id, error_type, error_message)); 503 thread_id, request_id, error_type, error_message));
492 } 504 }
493 505
494 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { 506 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() {
495 return context_wrapper_->context(); 507 return context_wrapper_->context();
496 } 508 }
497 509
498 } // namespace content 510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698