| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // A new unstored registration/version. | 44 // A new unstored registration/version. |
| 45 registration_ = new ServiceWorkerRegistration( | 45 registration_ = new ServiceWorkerRegistration( |
| 46 GURL("http://host/scope/"), 1L, context()->AsWeakPtr()); | 46 GURL("http://host/scope/"), 1L, context()->AsWeakPtr()); |
| 47 version_ = new ServiceWorkerVersion(registration_.get(), | 47 version_ = new ServiceWorkerVersion(registration_.get(), |
| 48 GURL("http://host/script.js"), | 48 GURL("http://host/script.js"), |
| 49 1L, | 49 1L, |
| 50 context()->AsWeakPtr()); | 50 context()->AsWeakPtr()); |
| 51 | 51 |
| 52 // An empty host. | 52 // An empty host. |
| 53 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 53 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| 54 kMockRenderProcessId, | 54 kMockRenderProcessId, MSG_ROUTING_NONE, kMockProviderId, |
| 55 MSG_ROUTING_NONE, | 55 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); |
| 56 kMockProviderId, | |
| 57 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, | |
| 58 context()->AsWeakPtr(), | |
| 59 nullptr)); | |
| 60 host->SetDocumentUrl(GURL("http://host/scope/")); | 56 host->SetDocumentUrl(GURL("http://host/scope/")); |
| 61 provider_host_ = host->AsWeakPtr(); | 57 provider_host_ = host->AsWeakPtr(); |
| 62 context()->AddProviderHost(host.Pass()); | 58 context()->AddProviderHost(host.Pass()); |
| 63 | 59 |
| 64 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); | 60 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); |
| 65 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 66 | 62 |
| 67 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 63 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
| 68 registration_->SetActiveVersion(version_.get()); | 64 registration_->SetActiveVersion(version_.get()); |
| 69 context()->storage()->StoreRegistration( | 65 context()->storage()->StoreRegistration( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 provider_host_->SetDocumentUrl(GURL("")); | 152 provider_host_->SetDocumentUrl(GURL("")); |
| 157 EXPECT_FALSE(InitializeHandlerCheck( | 153 EXPECT_FALSE(InitializeHandlerCheck( |
| 158 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 154 "http://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 159 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 155 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 160 EXPECT_FALSE(InitializeHandlerCheck( | 156 EXPECT_FALSE(InitializeHandlerCheck( |
| 161 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); | 157 "https://host/scope/doc", "GET", true, RESOURCE_TYPE_IMAGE)); |
| 162 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); | 158 EXPECT_STREQ("", provider_host_->document_url().spec().c_str()); |
| 163 } | 159 } |
| 164 | 160 |
| 165 } // namespace content | 161 } // namespace content |
| OLD | NEW |