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

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

Issue 588153002: [ServiceWorker] Plumbing the request mode from the renderer to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_request_handler.h" 5 #include "content/browser/service_worker/service_worker_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 } // namespace 54 } // namespace
55 55
56 void ServiceWorkerRequestHandler::InitializeHandler( 56 void ServiceWorkerRequestHandler::InitializeHandler(
57 net::URLRequest* request, 57 net::URLRequest* request,
58 ServiceWorkerContextWrapper* context_wrapper, 58 ServiceWorkerContextWrapper* context_wrapper,
59 storage::BlobStorageContext* blob_storage_context, 59 storage::BlobStorageContext* blob_storage_context,
60 int process_id, 60 int process_id,
61 int provider_id, 61 int provider_id,
62 bool skip_service_worker, 62 bool skip_service_worker,
63 FetchRequestMode request_mode,
63 ResourceType resource_type, 64 ResourceType resource_type,
64 scoped_refptr<ResourceRequestBody> body) { 65 scoped_refptr<ResourceRequestBody> body) {
65 if (!request->url().SchemeIsHTTPOrHTTPS() || 66 if (!request->url().SchemeIsHTTPOrHTTPS() ||
66 !IsMethodSupportedForServiceWroker(request->method())) { 67 !IsMethodSupportedForServiceWroker(request->method())) {
67 return; 68 return;
68 } 69 }
69 70
70 if (!context_wrapper || !context_wrapper->context() || 71 if (!context_wrapper || !context_wrapper->context() ||
71 provider_id == kInvalidServiceWorkerProviderId) { 72 provider_id == kInvalidServiceWorkerProviderId) {
72 return; 73 return;
73 } 74 }
74 75
75 ServiceWorkerProviderHost* provider_host = 76 ServiceWorkerProviderHost* provider_host =
76 context_wrapper->context()->GetProviderHost(process_id, provider_id); 77 context_wrapper->context()->GetProviderHost(process_id, provider_id);
77 if (!provider_host || !provider_host->IsContextAlive()) 78 if (!provider_host || !provider_host->IsContextAlive())
78 return; 79 return;
79 80
80 if (skip_service_worker) { 81 if (skip_service_worker) {
81 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) 82 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
82 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); 83 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
83 return; 84 return;
84 } 85 }
85 86
86 scoped_ptr<ServiceWorkerRequestHandler> handler( 87 scoped_ptr<ServiceWorkerRequestHandler> handler(
87 provider_host->CreateRequestHandler( 88 provider_host->CreateRequestHandler(request_mode,
88 resource_type, blob_storage_context->AsWeakPtr(), body)); 89 resource_type,
90 blob_storage_context->AsWeakPtr(),
91 body));
89 if (!handler) 92 if (!handler)
90 return; 93 return;
91 94
92 request->SetUserData(&kUserDataKey, handler.release()); 95 request->SetUserData(&kUserDataKey, handler.release());
93 } 96 }
94 97
95 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( 98 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
96 net::URLRequest* request) { 99 net::URLRequest* request) {
97 return reinterpret_cast<ServiceWorkerRequestHandler*>( 100 return reinterpret_cast<ServiceWorkerRequestHandler*>(
98 request->GetUserData(&kUserDataKey)); 101 request->GetUserData(&kUserDataKey));
(...skipping 13 matching lines...) Expand all
112 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 115 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
113 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 116 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
114 ResourceType resource_type) 117 ResourceType resource_type)
115 : context_(context), 118 : context_(context),
116 provider_host_(provider_host), 119 provider_host_(provider_host),
117 blob_storage_context_(blob_storage_context), 120 blob_storage_context_(blob_storage_context),
118 resource_type_(resource_type) { 121 resource_type_(resource_type) {
119 } 122 }
120 123
121 } // namespace content 124 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698