| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/link_header_support.h" | 5 #include "content/browser/service_worker/link_header_support.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/browser/loader/resource_request_info_impl.h" | 10 #include "content/browser/loader/resource_request_info_impl.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 false /* is_parent_frame_secure */, | 99 false /* is_parent_frame_secure */, |
| 100 context()->AsWeakPtr(), | 100 context()->AsWeakPtr(), |
| 101 &remote_endpoints_.back()); | 101 &remote_endpoints_.back()); |
| 102 provider_host_ = host->AsWeakPtr(); | 102 provider_host_ = host->AsWeakPtr(); |
| 103 EXPECT_FALSE( | 103 EXPECT_FALSE( |
| 104 context()->GetProviderHost(host->process_id(), host->provider_id())); | 104 context()->GetProviderHost(host->process_id(), host->provider_id())); |
| 105 context()->AddProviderHost(std::move(host)); | 105 context()->AddProviderHost(std::move(host)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void CreateServiceWorkerProviderHost() { | 108 void CreateServiceWorkerProviderHost() { |
| 109 remote_endpoints_.emplace_back(); |
| 110 std::unique_ptr<ServiceWorkerProviderHost> host = |
| 111 CreateProviderHostForServiceWorkerContext( |
| 112 render_process_id(), kMockProviderId, |
| 113 true /* is_parent_frame_secure */, context()->AsWeakPtr(), |
| 114 &remote_endpoints_.back()); |
| 115 provider_host_ = host->AsWeakPtr(); |
| 116 EXPECT_FALSE( |
| 117 context()->GetProviderHost(host->process_id(), host->provider_id())); |
| 118 context()->AddProviderHost(std::move(host)); |
| 119 |
| 109 scoped_refptr<ServiceWorkerRegistration> registration = | 120 scoped_refptr<ServiceWorkerRegistration> registration = |
| 110 new ServiceWorkerRegistration(GURL("https://host/scope"), 1L, | 121 new ServiceWorkerRegistration(GURL("https://host/scope"), 1L, |
| 111 context()->AsWeakPtr()); | 122 context()->AsWeakPtr()); |
| 112 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( | 123 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
| 113 registration.get(), GURL("https://host/script.js"), 1L, | 124 registration.get(), GURL("https://host/script.js"), 1L, |
| 114 context()->AsWeakPtr()); | 125 context()->AsWeakPtr()); |
| 115 | 126 |
| 116 remote_endpoints_.emplace_back(); | 127 provider_host_->running_hosted_version_ = version; |
| 117 std::unique_ptr<ServiceWorkerProviderHost> host = | |
| 118 CreateProviderHostForServiceWorkerContext( | |
| 119 render_process_id(), true /* is_parent_frame_secure */, | |
| 120 version.get(), context()->AsWeakPtr(), &remote_endpoints_.back()); | |
| 121 provider_host_ = host->AsWeakPtr(); | |
| 122 EXPECT_FALSE( | |
| 123 context()->GetProviderHost(host->process_id(), host->provider_id())); | |
| 124 context()->AddProviderHost(std::move(host)); | |
| 125 } | 128 } |
| 126 | 129 |
| 127 std::unique_ptr<net::URLRequest> CreateRequest(const GURL& request_url, | 130 std::unique_ptr<net::URLRequest> CreateRequest(const GURL& request_url, |
| 128 ResourceType resource_type, | 131 ResourceType resource_type, |
| 129 int provider_id) { | 132 int provider_id) { |
| 130 std::unique_ptr<net::URLRequest> request = request_context_.CreateRequest( | 133 std::unique_ptr<net::URLRequest> request = request_context_.CreateRequest( |
| 131 request_url, net::DEFAULT_PRIORITY, &request_delegate_, | 134 request_url, net::DEFAULT_PRIORITY, &request_delegate_, |
| 132 TRAFFIC_ANNOTATION_FOR_TESTS); | 135 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 133 ResourceRequestInfo::AllocateForTesting( | 136 ResourceRequestInfo::AllocateForTesting( |
| 134 request.get(), resource_type, &resource_context_, | 137 request.get(), resource_type, &resource_context_, |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 provider_host()->provider_id()) | 442 provider_host()->provider_id()) |
| 440 .get(), | 443 .get(), |
| 441 "<../foo.js>; rel=serviceworker", context_wrapper()); | 444 "<../foo.js>; rel=serviceworker", context_wrapper()); |
| 442 base::RunLoop().RunUntilIdle(); | 445 base::RunLoop().RunUntilIdle(); |
| 443 | 446 |
| 444 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); | 447 std::vector<ServiceWorkerRegistrationInfo> registrations = GetRegistrations(); |
| 445 ASSERT_EQ(1u, registrations.size()); | 448 ASSERT_EQ(1u, registrations.size()); |
| 446 } | 449 } |
| 447 | 450 |
| 448 } // namespace content | 451 } // namespace content |
| OLD | NEW |