| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 bool InitializeHandlerCheck(const std::string& url, | 85 bool InitializeHandlerCheck(const std::string& url, |
| 86 const std::string& method, | 86 const std::string& method, |
| 87 bool skip_service_worker, | 87 bool skip_service_worker, |
| 88 ResourceType resource_type) { | 88 ResourceType resource_type) { |
| 89 const GURL kDocUrl(url); | 89 const GURL kDocUrl(url); |
| 90 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( | 90 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( |
| 91 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); | 91 kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); |
| 92 request->set_method(method); | 92 request->set_method(method); |
| 93 ServiceWorkerRequestHandler::InitializeHandler( | 93 ServiceWorkerRequestHandler::InitializeHandler( |
| 94 request.get(), | 94 request.get(), context_wrapper(), &blob_storage_context_, |
| 95 context_wrapper(), | 95 kMockRenderProcessId, kMockProviderId, skip_service_worker, |
| 96 &blob_storage_context_, | 96 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_OMIT, |
| 97 kMockRenderProcessId, | 97 FetchRedirectMode::FOLLOW_MODE, resource_type, |
| 98 kMockProviderId, | 98 REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, |
| 99 skip_service_worker, | |
| 100 FETCH_REQUEST_MODE_NO_CORS, | |
| 101 FETCH_CREDENTIALS_MODE_OMIT, | |
| 102 resource_type, | |
| 103 REQUEST_CONTEXT_TYPE_HYPERLINK, | |
| 104 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, | |
| 105 nullptr); | 99 nullptr); |
| 106 return ServiceWorkerRequestHandler::GetHandler(request.get()) != nullptr; | 100 return ServiceWorkerRequestHandler::GetHandler(request.get()) != nullptr; |
| 107 } | 101 } |
| 108 | 102 |
| 109 protected: | 103 protected: |
| 110 TestBrowserThreadBundle browser_thread_bundle_; | 104 TestBrowserThreadBundle browser_thread_bundle_; |
| 111 scoped_ptr<EmbeddedWorkerTestHelper> helper_; | 105 scoped_ptr<EmbeddedWorkerTestHelper> helper_; |
| 112 scoped_refptr<ServiceWorkerRegistration> registration_; | 106 scoped_refptr<ServiceWorkerRegistration> registration_; |
| 113 scoped_refptr<ServiceWorkerVersion> version_; | 107 scoped_refptr<ServiceWorkerVersion> version_; |
| 114 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 108 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 provider_host_->SetDocumentUrl(GURL("")); | 147 provider_host_->SetDocumentUrl(GURL("")); |
| 154 EXPECT_FALSE(InitializeHandlerCheck( | 148 EXPECT_FALSE(InitializeHandlerCheck( |
| 155 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 149 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 156 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 150 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 157 EXPECT_FALSE(InitializeHandlerCheck( | 151 EXPECT_FALSE(InitializeHandlerCheck( |
| 158 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 152 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 159 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 153 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 160 } | 154 } |
| 161 | 155 |
| 162 } // namespace content | 156 } // namespace content |
| OLD | NEW |