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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 registration_ = nullptr; | 84 registration_ = nullptr; |
85 helper_.reset(); | 85 helper_.reset(); |
86 } | 86 } |
87 | 87 |
88 ServiceWorkerContextCore* context() const { return helper_->context(); } | 88 ServiceWorkerContextCore* context() const { return helper_->context(); } |
89 | 89 |
90 void SetUpProvider() { | 90 void SetUpProvider() { |
91 std::unique_ptr<ServiceWorkerProviderHost> host = | 91 std::unique_ptr<ServiceWorkerProviderHost> host = |
92 CreateProviderHostForServiceWorkerContext( | 92 CreateProviderHostForServiceWorkerContext( |
93 helper_->mock_render_process_id(), 1 /* provider_id */, | 93 helper_->mock_render_process_id(), 1 /* provider_id */, |
94 true /* is_parent_frame_secure */, context()->AsWeakPtr()); | 94 true /* is_parent_frame_secure */, context()->AsWeakPtr(), |
| 95 &remote_endpoint_); |
95 provider_host_ = host->AsWeakPtr(); | 96 provider_host_ = host->AsWeakPtr(); |
96 context()->AddProviderHost(std::move(host)); | 97 context()->AddProviderHost(std::move(host)); |
97 provider_host_->running_hosted_version_ = version_; | 98 provider_host_->running_hosted_version_ = version_; |
98 } | 99 } |
99 | 100 |
100 std::unique_ptr<net::URLRequest> CreateRequest(const GURL& url) { | 101 std::unique_ptr<net::URLRequest> CreateRequest(const GURL& url) { |
101 return url_request_context_.CreateRequest(url, net::DEFAULT_PRIORITY, | 102 return url_request_context_.CreateRequest(url, net::DEFAULT_PRIORITY, |
102 &url_request_delegate_, | 103 &url_request_delegate_, |
103 TRAFFIC_ANNOTATION_FOR_TESTS); | 104 TRAFFIC_ANNOTATION_FOR_TESTS); |
104 } | 105 } |
(...skipping 24 matching lines...) Expand all Loading... |
129 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 130 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
130 scoped_refptr<ServiceWorkerRegistration> registration_; | 131 scoped_refptr<ServiceWorkerRegistration> registration_; |
131 scoped_refptr<ServiceWorkerVersion> version_; | 132 scoped_refptr<ServiceWorkerVersion> version_; |
132 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 133 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
133 net::URLRequestContext url_request_context_; | 134 net::URLRequestContext url_request_context_; |
134 net::TestDelegate url_request_delegate_; | 135 net::TestDelegate url_request_delegate_; |
135 net::URLRequestJobFactoryImpl url_request_job_factory_; | 136 net::URLRequestJobFactoryImpl url_request_job_factory_; |
136 GURL scope_; | 137 GURL scope_; |
137 GURL script_url_; | 138 GURL script_url_; |
138 GURL import_script_url_; | 139 GURL import_script_url_; |
| 140 ServiceWorkerRemoteProviderEndpoint remote_endpoint_; |
139 storage::BlobStorageContext blob_storage_context_; | 141 storage::BlobStorageContext blob_storage_context_; |
140 }; | 142 }; |
141 | 143 |
142 TEST_F(ServiceWorkerContextRequestHandlerTest, UpdateBefore24Hours) { | 144 TEST_F(ServiceWorkerContextRequestHandlerTest, UpdateBefore24Hours) { |
143 // Give the registration a very recent last update time and pretend | 145 // Give the registration a very recent last update time and pretend |
144 // we're installing a new version. | 146 // we're installing a new version. |
145 registration_->set_last_update_check(base::Time::Now()); | 147 registration_->set_last_update_check(base::Time::Now()); |
146 version_->SetStatus(ServiceWorkerVersion::NEW); | 148 version_->SetStatus(ServiceWorkerVersion::NEW); |
147 | 149 |
148 // Conduct a resource fetch for the main script. | 150 // Conduct a resource fetch for the main script. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 EXPECT_EQ(net::ERR_FAILED, url_request_delegate_.request_status()); | 433 EXPECT_EQ(net::ERR_FAILED, url_request_delegate_.request_status()); |
432 histograms.ExpectUniqueSample( | 434 histograms.ExpectUniqueSample( |
433 "ServiceWorker.ContextRequestHandlerStatus.NewWorker.MainScript", | 435 "ServiceWorker.ContextRequestHandlerStatus.NewWorker.MainScript", |
434 static_cast<int>(ServiceWorkerContextRequestHandler::CreateJobStatus:: | 436 static_cast<int>(ServiceWorkerContextRequestHandler::CreateJobStatus:: |
435 ERROR_NO_CONTEXT), | 437 ERROR_NO_CONTEXT), |
436 1); | 438 1); |
437 } | 439 } |
438 } | 440 } |
439 | 441 |
440 } // namespace content | 442 } // namespace content |
OLD | NEW |