Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Skip unittest for CrossSiteTransfer when PlzNavigate Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 mock_protocol_handler_(nullptr) {} 286 mock_protocol_handler_(nullptr) {}
287 ~ServiceWorkerWriteToCacheJobTest() override {} 287 ~ServiceWorkerWriteToCacheJobTest() override {}
288 288
289 void CreateHostForVersion( 289 void CreateHostForVersion(
290 int process_id, 290 int process_id,
291 int provider_id, 291 int provider_id,
292 const scoped_refptr<ServiceWorkerVersion>& version) { 292 const scoped_refptr<ServiceWorkerVersion>& version) {
293 std::unique_ptr<ServiceWorkerProviderHost> host = 293 std::unique_ptr<ServiceWorkerProviderHost> host =
294 CreateProviderHostForServiceWorkerContext( 294 CreateProviderHostForServiceWorkerContext(
295 process_id, provider_id, true /* is_parent_frame_secure */, 295 process_id, provider_id, true /* is_parent_frame_secure */,
296 context()->AsWeakPtr()); 296 context()->AsWeakPtr(), &remote_endpoint_);
297 base::WeakPtr<ServiceWorkerProviderHost> provider_host = host->AsWeakPtr(); 297 base::WeakPtr<ServiceWorkerProviderHost> provider_host = host->AsWeakPtr();
298 context()->AddProviderHost(std::move(host)); 298 context()->AddProviderHost(std::move(host));
299 provider_host->running_hosted_version_ = version; 299 provider_host->running_hosted_version_ = version;
300 } 300 }
301 301
302 void SetUpScriptRequest(int process_id, int provider_id) { 302 void SetUpScriptRequest(int process_id, int provider_id) {
303 request_.reset(); 303 request_.reset();
304 url_request_context_.reset(); 304 url_request_context_.reset();
305 url_request_job_factory_.reset(); 305 url_request_job_factory_.reset();
306 mock_protocol_handler_ = nullptr; 306 mock_protocol_handler_ = nullptr;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 scoped_refptr<ServiceWorkerRegistration> registration_; 434 scoped_refptr<ServiceWorkerRegistration> registration_;
435 scoped_refptr<ServiceWorkerVersion> version_; 435 scoped_refptr<ServiceWorkerVersion> version_;
436 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 436 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
437 std::unique_ptr<net::URLRequestContext> url_request_context_; 437 std::unique_ptr<net::URLRequestContext> url_request_context_;
438 std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; 438 std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_;
439 std::unique_ptr<net::URLRequest> request_; 439 std::unique_ptr<net::URLRequest> request_;
440 MockHttpProtocolHandler* mock_protocol_handler_; 440 MockHttpProtocolHandler* mock_protocol_handler_;
441 441
442 storage::BlobStorageContext blob_storage_context_; 442 storage::BlobStorageContext blob_storage_context_;
443 content::MockResourceContext resource_context_; 443 content::MockResourceContext resource_context_;
444 ServiceWorkerRemoteProviderEndpoint remote_endpoint_;
444 445
445 net::TestDelegate url_request_delegate_; 446 net::TestDelegate url_request_delegate_;
446 int next_provider_id_ = 1; 447 int next_provider_id_ = 1;
447 int64_t next_version_id_ = 1L; 448 int64_t next_version_id_ = 1L;
448 }; 449 };
449 450
450 TEST_F(ServiceWorkerWriteToCacheJobTest, Normal) { 451 TEST_F(ServiceWorkerWriteToCacheJobTest, Normal) {
451 mock_protocol_handler_->SetCreateJobCallback( 452 mock_protocol_handler_->SetCreateJobCallback(
452 base::Bind(&CreateNormalURLRequestJob)); 453 base::Bind(&CreateNormalURLRequestJob));
453 request_->Start(); 454 request_->Start();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 mock_protocol_handler_->SetCreateJobCallback( 681 mock_protocol_handler_->SetCreateJobCallback(
681 base::Bind(&CreateNormalURLRequestJob)); 682 base::Bind(&CreateNormalURLRequestJob));
682 DisableCache(); 683 DisableCache();
683 request_->Start(); 684 request_->Start();
684 base::RunLoop().RunUntilIdle(); 685 base::RunLoop().RunUntilIdle();
685 EXPECT_EQ(net::URLRequestStatus::FAILED, request_->status().status()); 686 EXPECT_EQ(net::URLRequestStatus::FAILED, request_->status().status());
686 EXPECT_EQ(net::ERR_FAILED, request_->status().error()); 687 EXPECT_EQ(net::ERR_FAILED, request_->status().error());
687 } 688 }
688 689
689 } // namespace content 690 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698