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 "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 6060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6071 | 6071 |
6072 // We should be able to keep reading. | 6072 // We should be able to keep reading. |
6073 rv = trans->Read(buf.get(), 256, callback.callback()); | 6073 rv = trans->Read(buf.get(), 256, callback.callback()); |
6074 EXPECT_GT(callback.GetResult(rv), 0); | 6074 EXPECT_GT(callback.GetResult(rv), 0); |
6075 rv = trans->Read(buf.get(), 256, callback.callback()); | 6075 rv = trans->Read(buf.get(), 256, callback.callback()); |
6076 EXPECT_EQ(callback.GetResult(rv), 0); | 6076 EXPECT_EQ(callback.GetResult(rv), 0); |
6077 | 6077 |
6078 RemoveMockTransaction(&mock_transaction); | 6078 RemoveMockTransaction(&mock_transaction); |
6079 } | 6079 } |
6080 | 6080 |
6081 // Verify that the entry is marked as incomplete. | 6081 // Verify that the entry is inactive (doomed) and marked as incomplete. |
6082 disk_cache::Entry* entry; | 6082 disk_cache::Entry* entry; |
6083 ASSERT_TRUE(cache.OpenBackendEntry(kSimpleGET_Transaction.url, &entry)); | 6083 ASSERT_TRUE(cache.OpenBackendDoomedEntry(kSimpleGET_Transaction.url, &entry)); |
6084 net::HttpResponseInfo response; | 6084 net::HttpResponseInfo response; |
6085 bool truncated = false; | 6085 bool truncated = false; |
6086 EXPECT_TRUE(MockHttpCache::ReadResponseInfo(entry, &response, &truncated)); | 6086 EXPECT_TRUE(MockHttpCache::ReadResponseInfo(entry, &response, &truncated)); |
6087 EXPECT_TRUE(truncated); | 6087 EXPECT_TRUE(truncated); |
6088 entry->Close(); | 6088 entry->Close(); |
6089 } | 6089 } |
6090 | 6090 |
6091 // Tests that we handle truncated enries when StopCaching is called. | 6091 // Tests that we handle truncated enries when StopCaching is called. |
6092 TEST(HttpCache, StopCachingTruncatedEntry) { | 6092 TEST(HttpCache, StopCachingTruncatedEntry) { |
6093 MockHttpCache cache; | 6093 MockHttpCache cache; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6386 base::MessageLoop::current()->RunUntilIdle(); | 6386 base::MessageLoop::current()->RunUntilIdle(); |
6387 | 6387 |
6388 // Read bytes 20-29 and 50-59 from the network, bytes 30-49 from the cache. | 6388 // Read bytes 20-29 and 50-59 from the network, bytes 30-49 from the cache. |
6389 transaction.request_headers = "Range: bytes = 20-59\r\n" EXTRA_HEADER; | 6389 transaction.request_headers = "Range: bytes = 20-59\r\n" EXTRA_HEADER; |
6390 transaction.data = "rg: 20-29 rg: 30-39 rg: 40-49 rg: 50-59 "; | 6390 transaction.data = "rg: 20-29 rg: 30-39 rg: 40-49 rg: 50-59 "; |
6391 received_bytes = RunTransactionAndGetReceivedBytes(cache, transaction); | 6391 received_bytes = RunTransactionAndGetReceivedBytes(cache, transaction); |
6392 EXPECT_EQ(range_response_size * 2, received_bytes); | 6392 EXPECT_EQ(range_response_size * 2, received_bytes); |
6393 | 6393 |
6394 RemoveMockTransaction(&kRangeGET_TransactionOK); | 6394 RemoveMockTransaction(&kRangeGET_TransactionOK); |
6395 } | 6395 } |
OLD | NEW |