| 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 <utility> |
| 8 |
| 7 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 8 #include "content/browser/fileapi/mock_url_request_delegate.h" | 10 #include "content/browser/fileapi/mock_url_request_delegate.h" |
| 9 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 11 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 12 #include "content/browser/service_worker/service_worker_context_core.h" |
| 11 #include "content/browser/service_worker/service_worker_provider_host.h" | 13 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 12 #include "content/browser/service_worker/service_worker_registration.h" | 14 #include "content/browser/service_worker/service_worker_registration.h" |
| 13 #include "content/common/resource_request_body.h" | 15 #include "content/common/resource_request_body.h" |
| 14 #include "content/common/service_worker/service_worker_utils.h" | 16 #include "content/common/service_worker/service_worker_utils.h" |
| 15 #include "content/public/common/request_context_frame_type.h" | 17 #include "content/public/common/request_context_frame_type.h" |
| 16 #include "content/public/common/request_context_type.h" | 18 #include "content/public/common/request_context_type.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 GURL("http://host/script.js"), | 48 GURL("http://host/script.js"), |
| 47 1L, | 49 1L, |
| 48 context()->AsWeakPtr()); | 50 context()->AsWeakPtr()); |
| 49 | 51 |
| 50 // An empty host. | 52 // An empty host. |
| 51 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 53 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| 52 helper_->mock_render_process_id(), MSG_ROUTING_NONE, kMockProviderId, | 54 helper_->mock_render_process_id(), MSG_ROUTING_NONE, kMockProviderId, |
| 53 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); | 55 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); |
| 54 host->SetDocumentUrl(GURL("http://host/scope/")); | 56 host->SetDocumentUrl(GURL("http://host/scope/")); |
| 55 provider_host_ = host->AsWeakPtr(); | 57 provider_host_ = host->AsWeakPtr(); |
| 56 context()->AddProviderHost(host.Pass()); | 58 context()->AddProviderHost(std::move(host)); |
| 57 | 59 |
| 58 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); | 60 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); |
| 59 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 60 | 62 |
| 61 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 63 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
| 62 registration_->SetActiveVersion(version_); | 64 registration_->SetActiveVersion(version_); |
| 63 context()->storage()->StoreRegistration( | 65 context()->storage()->StoreRegistration( |
| 64 registration_.get(), | 66 registration_.get(), |
| 65 version_.get(), | 67 version_.get(), |
| 66 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 68 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 provider_host_->SetDocumentUrl(GURL("")); | 152 provider_host_->SetDocumentUrl(GURL("")); |
| 151 EXPECT_FALSE(InitializeHandlerCheck( | 153 EXPECT_FALSE(InitializeHandlerCheck( |
| 152 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 154 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 153 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 155 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 154 EXPECT_FALSE(InitializeHandlerCheck( | 156 EXPECT_FALSE(InitializeHandlerCheck( |
| 155 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 157 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 156 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 158 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 157 } | 159 } |
| 158 | 160 |
| 159 } // namespace content | 161 } // namespace content |
| OLD | NEW |