Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/hash_tables.h" | 7 #include "base/hash_tables.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/scoped_vector.h" | 9 #include "base/scoped_vector.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 | 897 |
| 898 EXPECT_LT(end, 80); | 898 EXPECT_LT(end, 80); |
| 899 | 899 |
| 900 std::string content_range = base::StringPrintf( | 900 std::string content_range = base::StringPrintf( |
| 901 "Content-Range: bytes %d-%d/80\n", start, end); | 901 "Content-Range: bytes %d-%d/80\n", start, end); |
| 902 response_headers->append(content_range); | 902 response_headers->append(content_range); |
| 903 | 903 |
| 904 if (!request->extra_headers.HasHeader("If-None-Match") || modified_) { | 904 if (!request->extra_headers.HasHeader("If-None-Match") || modified_) { |
| 905 EXPECT_EQ(9, (end - start) % 10); | 905 EXPECT_EQ(9, (end - start) % 10); |
| 906 std::string data; | 906 std::string data; |
| 907 for (int block_start = start; block_start < end; block_start += 10) | 907 for (int block_start = start; block_start < end; block_start += 10) |
|
brettw
2010/11/15 00:09:23
This for statement needs {} now that you made the
tfarina
2010/11/15 01:21:25
Done.
| |
| 908 StringAppendF(&data, "rg: %02d-%02d ", block_start, block_start + 9); | 908 base::StringAppendF(&data, "rg: %02d-%02d ", |
| 909 block_start, block_start + 9); | |
| 909 *response_data = data; | 910 *response_data = data; |
| 910 | 911 |
| 911 if (end - start != 9) { | 912 if (end - start != 9) { |
| 912 // We also have to fix content-length. | 913 // We also have to fix content-length. |
| 913 int len = end - start + 1; | 914 int len = end - start + 1; |
| 914 EXPECT_EQ(0, len % 10); | 915 EXPECT_EQ(0, len % 10); |
| 915 std::string content_length = base::StringPrintf("Content-Length: %d\n", | 916 std::string content_length = base::StringPrintf("Content-Length: %d\n", |
| 916 len); | 917 len); |
| 917 response_headers->replace(response_headers->find("Content-Length:"), | 918 response_headers->replace(response_headers->find("Content-Length:"), |
| 918 content_length.size(), content_length); | 919 content_length.size(), content_length); |
| (...skipping 3924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4843 // Now return 200 when validating the entry so the metadata will be lost. | 4844 // Now return 200 when validating the entry so the metadata will be lost. |
| 4844 MockTransaction trans2(kTypicalGET_Transaction); | 4845 MockTransaction trans2(kTypicalGET_Transaction); |
| 4845 trans2.load_flags = net::LOAD_VALIDATE_CACHE; | 4846 trans2.load_flags = net::LOAD_VALIDATE_CACHE; |
| 4846 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); | 4847 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); |
| 4847 EXPECT_TRUE(response.metadata.get() == NULL); | 4848 EXPECT_TRUE(response.metadata.get() == NULL); |
| 4848 | 4849 |
| 4849 EXPECT_EQ(3, cache.network_layer()->transaction_count()); | 4850 EXPECT_EQ(3, cache.network_layer()->transaction_count()); |
| 4850 EXPECT_EQ(4, cache.disk_cache()->open_count()); | 4851 EXPECT_EQ(4, cache.disk_cache()->open_count()); |
| 4851 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 4852 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| 4852 } | 4853 } |
| OLD | NEW |