OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stack> | 5 #include <stack> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // the net library to create a real job. | 371 // the net library to create a real job. |
372 job_ = handler_->MaybeLoadResource(request_.get(), | 372 job_ = handler_->MaybeLoadResource(request_.get(), |
373 empty_context_.network_delegate()); | 373 empty_context_.network_delegate()); |
374 EXPECT_FALSE(job_); | 374 EXPECT_FALSE(job_); |
375 | 375 |
376 // Simulate an http error of the real network job. | 376 // Simulate an http error of the real network job. |
377 request_->SimulateResponseCode(500); | 377 request_->SimulateResponseCode(500); |
378 | 378 |
379 job_ = handler_->MaybeLoadFallbackForResponse( | 379 job_ = handler_->MaybeLoadFallbackForResponse( |
380 request_.get(), request_->context()->network_delegate()); | 380 request_.get(), request_->context()->network_delegate()); |
381 EXPECT_TRUE(job_); | 381 EXPECT_TRUE(job_.get()); |
382 EXPECT_TRUE(job_->is_delivering_appcache_response()); | 382 EXPECT_TRUE(job_->is_delivering_appcache_response()); |
383 | 383 |
384 int64 cache_id = kNoCacheId; | 384 int64 cache_id = kNoCacheId; |
385 GURL manifest_url; | 385 GURL manifest_url; |
386 handler_->GetExtraResponseInfo(&cache_id, &manifest_url); | 386 handler_->GetExtraResponseInfo(&cache_id, &manifest_url); |
387 EXPECT_EQ(1, cache_id); | 387 EXPECT_EQ(1, cache_id); |
388 EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url); | 388 EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url); |
389 EXPECT_TRUE(host_->main_resource_was_namespace_entry_); | 389 EXPECT_TRUE(host_->main_resource_was_namespace_entry_); |
390 EXPECT_EQ(GURL("http://blah/fallbackurl"), host_->namespace_entry_url_); | 390 EXPECT_EQ(GURL("http://blah/fallbackurl"), host_->namespace_entry_url_); |
391 | 391 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 506 |
507 request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_)); | 507 request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_)); |
508 handler_.reset(host_->CreateRequestHandler(request_.get(), | 508 handler_.reset(host_->CreateRequestHandler(request_.get(), |
509 ResourceType::SUB_RESOURCE)); | 509 ResourceType::SUB_RESOURCE)); |
510 EXPECT_TRUE(handler_.get()); | 510 EXPECT_TRUE(handler_.get()); |
511 job_ = handler_->MaybeLoadResource(request_.get(), | 511 job_ = handler_->MaybeLoadResource(request_.get(), |
512 empty_context_.network_delegate()); | 512 empty_context_.network_delegate()); |
513 EXPECT_TRUE(job_.get()); | 513 EXPECT_TRUE(job_.get()); |
514 EXPECT_TRUE(job_->is_waiting()); | 514 EXPECT_TRUE(job_->is_waiting()); |
515 | 515 |
516 host_->FinishCacheSelection(cache, NULL); | 516 host_->FinishCacheSelection(cache.get(), NULL); |
517 EXPECT_FALSE(job_->is_waiting()); | 517 EXPECT_FALSE(job_->is_waiting()); |
518 EXPECT_TRUE(job_->is_delivering_error_response()); | 518 EXPECT_TRUE(job_->is_delivering_error_response()); |
519 | 519 |
520 AppCacheURLRequestJob* fallback_job; | 520 AppCacheURLRequestJob* fallback_job; |
521 fallback_job = handler_->MaybeLoadFallbackForRedirect( | 521 fallback_job = handler_->MaybeLoadFallbackForRedirect( |
522 request_.get(), | 522 request_.get(), |
523 empty_context_.network_delegate(), | 523 empty_context_.network_delegate(), |
524 GURL("http://blah/redirect")); | 524 GURL("http://blah/redirect")); |
525 EXPECT_FALSE(fallback_job); | 525 EXPECT_FALSE(fallback_job); |
526 fallback_job = handler_->MaybeLoadFallbackForResponse( | 526 fallback_job = handler_->MaybeLoadFallbackForResponse( |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 959 |
960 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { | 960 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { |
961 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); | 961 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); |
962 } | 962 } |
963 | 963 |
964 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { | 964 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { |
965 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); | 965 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); |
966 } | 966 } |
967 | 967 |
968 } // namespace appcache | 968 } // namespace appcache |
OLD | NEW |