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

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

Issue 548773002: [ServiceWorker] Don't pass OPTIONS request to the ServiceWorker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move include 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_request_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26 matching lines...) Expand all
37 ServiceWorkerRequestHandler::GetHandler(request); 37 ServiceWorkerRequestHandler::GetHandler(request);
38 if (!handler) 38 if (!handler)
39 return NULL; 39 return NULL;
40 return handler->MaybeCreateJob(request, network_delegate); 40 return handler->MaybeCreateJob(request, network_delegate);
41 } 41 }
42 42
43 private: 43 private:
44 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor); 44 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor);
45 }; 45 };
46 46
47 // This is work around to avoid hijacking CORS preflight.
48 // TODO(horo): Remove this check when we implement "HTTP fetch" correctly.
49 // http://fetch.spec.whatwg.org/#concept-http-fetch
50 bool IsMethodSupportedForServiceWroker(const std::string& method) {
51 return method != "OPTIONS";
52 }
53
47 } // namespace 54 } // namespace
48 55
49 void ServiceWorkerRequestHandler::InitializeHandler( 56 void ServiceWorkerRequestHandler::InitializeHandler(
50 net::URLRequest* request, 57 net::URLRequest* request,
51 ServiceWorkerContextWrapper* context_wrapper, 58 ServiceWorkerContextWrapper* context_wrapper,
52 storage::BlobStorageContext* blob_storage_context, 59 storage::BlobStorageContext* blob_storage_context,
53 int process_id, 60 int process_id,
54 int provider_id, 61 int provider_id,
55 bool skip_service_worker, 62 bool skip_service_worker,
56 ResourceType resource_type, 63 ResourceType resource_type,
57 scoped_refptr<ResourceRequestBody> body) { 64 scoped_refptr<ResourceRequestBody> body) {
58 if (!request->url().SchemeIsHTTPOrHTTPS()) 65 if (!request->url().SchemeIsHTTPOrHTTPS() ||
66 !IsMethodSupportedForServiceWroker(request->method())) {
59 return; 67 return;
68 }
60 69
61 if (!context_wrapper || !context_wrapper->context() || 70 if (!context_wrapper || !context_wrapper->context() ||
62 provider_id == kInvalidServiceWorkerProviderId) { 71 provider_id == kInvalidServiceWorkerProviderId) {
63 return; 72 return;
64 } 73 }
65 74
66 ServiceWorkerProviderHost* provider_host = 75 ServiceWorkerProviderHost* provider_host =
67 context_wrapper->context()->GetProviderHost(process_id, provider_id); 76 context_wrapper->context()->GetProviderHost(process_id, provider_id);
68 if (!provider_host || !provider_host->IsContextAlive()) 77 if (!provider_host || !provider_host->IsContextAlive())
69 return; 78 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 112 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
104 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 113 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
105 ResourceType resource_type) 114 ResourceType resource_type)
106 : context_(context), 115 : context_(context),
107 provider_host_(provider_host), 116 provider_host_(provider_host),
108 blob_storage_context_(blob_storage_context), 117 blob_storage_context_(blob_storage_context),
109 resource_type_(resource_type) { 118 resource_type_(resource_type) {
110 } 119 }
111 120
112 } // namespace content 121 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_request_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698