| OLD | NEW |
| 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 "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "content/browser/fileapi/mock_url_request_delegate.h" | 8 #include "content/browser/fileapi/mock_url_request_delegate.h" |
| 9 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 9 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool InitializeHandlerCheck(const std::string& url, | 78 bool InitializeHandlerCheck(const std::string& url, |
| 79 const std::string& method, | 79 const std::string& method, |
| 80 bool skip_service_worker, | 80 bool skip_service_worker, |
| 81 ResourceType resource_type) { | 81 ResourceType resource_type) { |
| 82 const GURL kDocUrl(url); | 82 const GURL kDocUrl(url); |
| 83 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( | 83 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( |
| 84 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_, NULL); | 84 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_, NULL); |
| 85 request->set_method(method); | 85 request->set_method(method); |
| 86 FetchRequestMode request_mode = FETCH_REQUEST_MODE_NO_CORS; | |
| 87 ServiceWorkerRequestHandler::InitializeHandler(request.get(), | 86 ServiceWorkerRequestHandler::InitializeHandler(request.get(), |
| 88 context_wrapper(), | 87 context_wrapper(), |
| 89 &blob_storage_context_, | 88 &blob_storage_context_, |
| 90 kMockRenderProcessId, | 89 kMockRenderProcessId, |
| 91 kMockProviderId, | 90 kMockProviderId, |
| 92 skip_service_worker, | 91 skip_service_worker, |
| 93 request_mode, | 92 FETCH_REQUEST_MODE_NO_CORS, |
| 93 FETCH_CREDENTIALS_MODE_OMIT, |
| 94 resource_type, | 94 resource_type, |
| 95 NULL); | 95 NULL); |
| 96 return ServiceWorkerRequestHandler::GetHandler(request.get()) != NULL; | 96 return ServiceWorkerRequestHandler::GetHandler(request.get()) != NULL; |
| 97 } | 97 } |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 TestBrowserThreadBundle browser_thread_bundle_; | 100 TestBrowserThreadBundle browser_thread_bundle_; |
| 101 scoped_ptr<EmbeddedWorkerTestHelper> helper_; | 101 scoped_ptr<EmbeddedWorkerTestHelper> helper_; |
| 102 scoped_refptr<ServiceWorkerRegistration> registration_; | 102 scoped_refptr<ServiceWorkerRegistration> registration_; |
| 103 scoped_refptr<ServiceWorkerVersion> version_; | 103 scoped_refptr<ServiceWorkerVersion> version_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 provider_host_->SetDocumentUrl(GURL("")); | 143 provider_host_->SetDocumentUrl(GURL("")); |
| 144 EXPECT_FALSE(InitializeHandlerCheck( | 144 EXPECT_FALSE(InitializeHandlerCheck( |
| 145 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 145 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 146 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 146 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 147 EXPECT_FALSE(InitializeHandlerCheck( | 147 EXPECT_FALSE(InitializeHandlerCheck( |
| 148 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 148 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 149 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 149 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace content | 152 } // namespace content |
| OLD | NEW |