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_context_request_handler.
h" | 5 #include "content/browser/service_worker/service_worker_context_request_handler.
h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // A new unstored registration/version. | 42 // A new unstored registration/version. |
43 scope_ = GURL("http://host/scope/"); | 43 scope_ = GURL("http://host/scope/"); |
44 script_url_ = GURL("http://host/script.js"); | 44 script_url_ = GURL("http://host/script.js"); |
45 registration_ = new ServiceWorkerRegistration( | 45 registration_ = new ServiceWorkerRegistration( |
46 scope_, 1L, context()->AsWeakPtr()); | 46 scope_, 1L, context()->AsWeakPtr()); |
47 version_ = new ServiceWorkerVersion( | 47 version_ = new ServiceWorkerVersion( |
48 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); | 48 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); |
49 | 49 |
50 // An empty host. | 50 // An empty host. |
51 std::unique_ptr<ServiceWorkerProviderHost> host( | 51 std::unique_ptr<ServiceWorkerProviderHost> host( |
52 new ServiceWorkerProviderHost( | 52 new ServiceWorkerProviderHost(helper_->mock_render_process_id(), |
53 helper_->mock_render_process_id(), | 53 MSG_ROUTING_NONE /* render_frame_id */, |
54 MSG_ROUTING_NONE /* render_frame_id */, 1 /* provider_id */, | 54 1 /* provider_id */, |
55 SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 55 SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
56 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, | 56 context()->AsWeakPtr(), nullptr)); |
57 context()->AsWeakPtr(), nullptr)); | |
58 provider_host_ = host->AsWeakPtr(); | 57 provider_host_ = host->AsWeakPtr(); |
59 context()->AddProviderHost(std::move(host)); | 58 context()->AddProviderHost(std::move(host)); |
60 | 59 |
61 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); | 60 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); |
62 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
63 } | 62 } |
64 | 63 |
65 void TearDown() override { | 64 void TearDown() override { |
66 version_ = nullptr; | 65 version_ = nullptr; |
67 registration_ = nullptr; | 66 registration_ = nullptr; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 ServiceWorkerWriteToCacheJob* sw_job = | 181 ServiceWorkerWriteToCacheJob* sw_job = |
183 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); | 182 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); |
184 | 183 |
185 // Verify that the request is properly annotated as originating from a | 184 // Verify that the request is properly annotated as originating from a |
186 // Service Worker. | 185 // Service Worker. |
187 EXPECT_TRUE(ResourceRequestInfo::OriginatedFromServiceWorker( | 186 EXPECT_TRUE(ResourceRequestInfo::OriginatedFromServiceWorker( |
188 sw_job->net_request_.get())); | 187 sw_job->net_request_.get())); |
189 } | 188 } |
190 | 189 |
191 } // namespace content | 190 } // namespace content |
OLD | NEW |