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_controllee_request_handl
er.h" | 5 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); | 103 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); |
104 | 104 |
105 std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 105 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
106 records.push_back( | 106 records.push_back( |
107 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); | 107 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); |
108 version_->script_cache_map()->SetResources(records); | 108 version_->script_cache_map()->SetResources(records); |
109 version_->SetMainScriptHttpResponseInfo( | 109 version_->SetMainScriptHttpResponseInfo( |
110 EmbeddedWorkerTestHelper::CreateHttpResponseInfo()); | 110 EmbeddedWorkerTestHelper::CreateHttpResponseInfo()); |
111 | 111 |
112 // An empty host. | 112 // An empty host. |
| 113 remote_endpoints_.emplace_back(); |
113 std::unique_ptr<ServiceWorkerProviderHost> host = | 114 std::unique_ptr<ServiceWorkerProviderHost> host = |
114 CreateProviderHostForWindow( | 115 CreateProviderHostForWindow( |
115 helper_->mock_render_process_id(), kMockProviderId, | 116 helper_->mock_render_process_id(), kMockProviderId, |
116 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr()); | 117 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr(), |
| 118 &remote_endpoints_.back()); |
117 provider_host_ = host->AsWeakPtr(); | 119 provider_host_ = host->AsWeakPtr(); |
118 context()->AddProviderHost(std::move(host)); | 120 context()->AddProviderHost(std::move(host)); |
119 | 121 |
120 context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 122 context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
121 base::RunLoop().RunUntilIdle(); | 123 base::RunLoop().RunUntilIdle(); |
122 } | 124 } |
123 | 125 |
124 void TearDown() override { | 126 void TearDown() override { |
125 version_ = NULL; | 127 version_ = NULL; |
126 registration_ = NULL; | 128 registration_ = NULL; |
127 helper_.reset(); | 129 helper_.reset(); |
128 } | 130 } |
129 | 131 |
130 ServiceWorkerContextCore* context() const { return helper_->context(); } | 132 ServiceWorkerContextCore* context() const { return helper_->context(); } |
131 | 133 |
132 protected: | 134 protected: |
133 TestBrowserThreadBundle browser_thread_bundle_; | 135 TestBrowserThreadBundle browser_thread_bundle_; |
134 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 136 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
135 scoped_refptr<ServiceWorkerRegistration> registration_; | 137 scoped_refptr<ServiceWorkerRegistration> registration_; |
136 scoped_refptr<ServiceWorkerVersion> version_; | 138 scoped_refptr<ServiceWorkerVersion> version_; |
137 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 139 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
138 net::URLRequestContext url_request_context_; | 140 net::URLRequestContext url_request_context_; |
139 net::TestDelegate url_request_delegate_; | 141 net::TestDelegate url_request_delegate_; |
140 MockResourceContext mock_resource_context_; | 142 MockResourceContext mock_resource_context_; |
141 GURL scope_; | 143 GURL scope_; |
142 GURL script_url_; | 144 GURL script_url_; |
| 145 std::vector<ServiceWorkerRemoteProviderEndpoint> remote_endpoints_; |
143 }; | 146 }; |
144 | 147 |
145 class ServiceWorkerTestContentBrowserClient : public TestContentBrowserClient { | 148 class ServiceWorkerTestContentBrowserClient : public TestContentBrowserClient { |
146 public: | 149 public: |
147 ServiceWorkerTestContentBrowserClient() {} | 150 ServiceWorkerTestContentBrowserClient() {} |
148 bool AllowServiceWorker( | 151 bool AllowServiceWorker( |
149 const GURL& scope, | 152 const GURL& scope, |
150 const GURL& first_party, | 153 const GURL& first_party, |
151 content::ResourceContext* context, | 154 content::ResourceContext* context, |
152 const base::Callback<WebContents*(void)>& wc_getter) override { | 155 const base::Callback<WebContents*(void)>& wc_getter) override { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 EXPECT_FALSE(sub_cors_job->ShouldFallbackToNetwork()); | 371 EXPECT_FALSE(sub_cors_job->ShouldFallbackToNetwork()); |
369 EXPECT_FALSE(sub_cors_job->ShouldForwardToServiceWorker()); | 372 EXPECT_FALSE(sub_cors_job->ShouldForwardToServiceWorker()); |
370 | 373 |
371 base::RunLoop().RunUntilIdle(); | 374 base::RunLoop().RunUntilIdle(); |
372 | 375 |
373 EXPECT_FALSE(sub_cors_job->ShouldFallbackToNetwork()); | 376 EXPECT_FALSE(sub_cors_job->ShouldFallbackToNetwork()); |
374 EXPECT_FALSE(sub_cors_job->ShouldForwardToServiceWorker()); | 377 EXPECT_FALSE(sub_cors_job->ShouldForwardToServiceWorker()); |
375 } | 378 } |
376 | 379 |
377 } // namespace content | 380 } // namespace content |
OLD | NEW |