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

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

Issue 527713002: [ServiceWorker] Introduce skip_service_worker flag and remove LOAD_BYPASS_CACHE check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce skip_service_worker flag Created 6 years, 3 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"
11 #include "content/browser/service_worker/service_worker_provider_host.h" 11 #include "content/browser/service_worker/service_worker_provider_host.h"
12 #include "content/browser/service_worker/service_worker_registration.h" 12 #include "content/browser/service_worker/service_worker_registration.h"
13 #include "content/browser/service_worker/service_worker_url_request_job.h" 13 #include "content/browser/service_worker/service_worker_url_request_job.h"
14 #include "content/browser/service_worker/service_worker_utils.h" 14 #include "content/browser/service_worker/service_worker_utils.h"
15 #include "content/common/resource_request_body.h" 15 #include "content/common/resource_request_body.h"
16 #include "content/common/service_worker/service_worker_types.h" 16 #include "content/common/service_worker/service_worker_types.h"
17 #include "net/base/net_util.h"
17 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_interceptor.h" 19 #include "net/url_request/url_request_interceptor.h"
19 #include "webkit/browser/blob/blob_storage_context.h" 20 #include "webkit/browser/blob/blob_storage_context.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 namespace { 24 namespace {
24 25
25 int kUserDataKey; // Key value is not important. 26 int kUserDataKey; // Key value is not important.
26 27
(...skipping 17 matching lines...) Expand all
44 }; 45 };
45 46
46 } // namespace 47 } // namespace
47 48
48 void ServiceWorkerRequestHandler::InitializeHandler( 49 void ServiceWorkerRequestHandler::InitializeHandler(
49 net::URLRequest* request, 50 net::URLRequest* request,
50 ServiceWorkerContextWrapper* context_wrapper, 51 ServiceWorkerContextWrapper* context_wrapper,
51 storage::BlobStorageContext* blob_storage_context, 52 storage::BlobStorageContext* blob_storage_context,
52 int process_id, 53 int process_id,
53 int provider_id, 54 int provider_id,
55 bool skip_service_worker,
54 ResourceType resource_type, 56 ResourceType resource_type,
55 scoped_refptr<ResourceRequestBody> body) { 57 scoped_refptr<ResourceRequestBody> body) {
56 if (!request->url().SchemeIsHTTPOrHTTPS()) 58 if (!request->url().SchemeIsHTTPOrHTTPS())
57 return; 59 return;
58 60
59 if (!context_wrapper || !context_wrapper->context() || 61 if (!context_wrapper || !context_wrapper->context() ||
60 provider_id == kInvalidServiceWorkerProviderId) { 62 provider_id == kInvalidServiceWorkerProviderId) {
61 return; 63 return;
62 } 64 }
63 65
64 ServiceWorkerProviderHost* provider_host = 66 ServiceWorkerProviderHost* provider_host =
65 context_wrapper->context()->GetProviderHost(process_id, provider_id); 67 context_wrapper->context()->GetProviderHost(process_id, provider_id);
66 if (!provider_host || !provider_host->IsContextAlive()) 68 if (!provider_host || !provider_host->IsContextAlive())
67 return; 69 return;
68 70
71 if (skip_service_worker) {
72 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
73 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
74 return;
75 }
76
69 scoped_ptr<ServiceWorkerRequestHandler> handler( 77 scoped_ptr<ServiceWorkerRequestHandler> handler(
70 provider_host->CreateRequestHandler( 78 provider_host->CreateRequestHandler(
71 resource_type, blob_storage_context->AsWeakPtr(), body)); 79 resource_type, blob_storage_context->AsWeakPtr(), body));
72 if (!handler) 80 if (!handler)
73 return; 81 return;
74 82
75 request->SetUserData(&kUserDataKey, handler.release()); 83 request->SetUserData(&kUserDataKey, handler.release());
76 } 84 }
77 85
78 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( 86 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
(...skipping 16 matching lines...) Expand all
95 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 103 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
96 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 104 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
97 ResourceType resource_type) 105 ResourceType resource_type)
98 : context_(context), 106 : context_(context),
99 provider_host_(provider_host), 107 provider_host_(provider_host),
100 blob_storage_context_(blob_storage_context), 108 blob_storage_context_(blob_storage_context),
101 resource_type_(resource_type) { 109 resource_type_(resource_type) {
102 } 110 }
103 111
104 } // namespace content 112 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_request_handler.h ('k') | content/child/request_extra_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698