| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 version_ = nullptr; | 83 version_ = nullptr; |
| 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(), | 93 helper_->mock_render_process_id(), 1 /* provider_id */, |
| 94 true /* is_parent_frame_secure */, version_.get(), | 94 true /* is_parent_frame_secure */, context()->AsWeakPtr(), |
| 95 context()->AsWeakPtr(), &remote_endpoint_); | 95 &remote_endpoint_); |
| 96 provider_host_ = host->AsWeakPtr(); | 96 provider_host_ = host->AsWeakPtr(); |
| 97 context()->AddProviderHost(std::move(host)); | 97 context()->AddProviderHost(std::move(host)); |
| 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 } |
| 105 | 106 |
| 106 // Creates a ServiceWorkerContextHandler directly. | 107 // Creates a ServiceWorkerContextHandler directly. |
| 107 std::unique_ptr<ServiceWorkerContextRequestHandler> CreateHandler( | 108 std::unique_ptr<ServiceWorkerContextRequestHandler> CreateHandler( |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 EXPECT_EQ(net::ERR_FAILED, url_request_delegate_.request_status()); | 433 EXPECT_EQ(net::ERR_FAILED, url_request_delegate_.request_status()); |
| 433 histograms.ExpectUniqueSample( | 434 histograms.ExpectUniqueSample( |
| 434 "ServiceWorker.ContextRequestHandlerStatus.NewWorker.MainScript", | 435 "ServiceWorker.ContextRequestHandlerStatus.NewWorker.MainScript", |
| 435 static_cast<int>(ServiceWorkerContextRequestHandler::CreateJobStatus:: | 436 static_cast<int>(ServiceWorkerContextRequestHandler::CreateJobStatus:: |
| 436 ERROR_NO_CONTEXT), | 437 ERROR_NO_CONTEXT), |
| 437 1); | 438 1); |
| 438 } | 439 } |
| 439 } | 440 } |
| 440 | 441 |
| 441 } // namespace content | 442 } // namespace content |
| OLD | NEW |