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

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 3390026: net: Append base:: in the StringPrintf calls. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix include order Created 10 years, 3 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
« no previous file with comments | « net/http/http_cache.cc ('k') | net/http/http_net_log_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-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"
11 #include "base/stringprintf.h"
11 #include "net/base/cache_type.h" 12 #include "net/base/cache_type.h"
12 #include "net/base/cert_status_flags.h" 13 #include "net/base/cert_status_flags.h"
14 #include "net/base/load_flags.h"
13 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
14 #include "net/base/load_flags.h"
15 #include "net/base/net_log_unittest.h" 16 #include "net/base/net_log_unittest.h"
16 #include "net/base/ssl_cert_request_info.h" 17 #include "net/base/ssl_cert_request_info.h"
17 #include "net/disk_cache/disk_cache.h" 18 #include "net/disk_cache/disk_cache.h"
18 #include "net/http/http_byte_range.h" 19 #include "net/http/http_byte_range.h"
19 #include "net/http/http_request_headers.h" 20 #include "net/http/http_request_headers.h"
20 #include "net/http/http_request_info.h" 21 #include "net/http/http_request_info.h"
21 #include "net/http/http_response_headers.h" 22 #include "net/http/http_response_headers.h"
22 #include "net/http/http_response_info.h" 23 #include "net/http/http_response_info.h"
23 #include "net/http/http_transaction.h" 24 #include "net/http/http_transaction.h"
24 #include "net/http/http_transaction_unittest.h" 25 #include "net/http/http_transaction_unittest.h"
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 response_status->assign("HTTP/1.1 416 Requested Range Not Satisfiable"); 887 response_status->assign("HTTP/1.1 416 Requested Range Not Satisfiable");
887 return; 888 return;
888 } 889 }
889 890
890 EXPECT_TRUE(byte_range.ComputeBounds(80)); 891 EXPECT_TRUE(byte_range.ComputeBounds(80));
891 int start = static_cast<int>(byte_range.first_byte_position()); 892 int start = static_cast<int>(byte_range.first_byte_position());
892 int end = static_cast<int>(byte_range.last_byte_position()); 893 int end = static_cast<int>(byte_range.last_byte_position());
893 894
894 EXPECT_LT(end, 80); 895 EXPECT_LT(end, 80);
895 896
896 std::string content_range = StringPrintf("Content-Range: bytes %d-%d/80\n", 897 std::string content_range = base::StringPrintf(
897 start, end); 898 "Content-Range: bytes %d-%d/80\n", start, end);
898 response_headers->append(content_range); 899 response_headers->append(content_range);
899 900
900 if (!request->extra_headers.HasHeader("If-None-Match") || modified_) { 901 if (!request->extra_headers.HasHeader("If-None-Match") || modified_) {
901 EXPECT_EQ(9, (end - start) % 10); 902 EXPECT_EQ(9, (end - start) % 10);
902 std::string data; 903 std::string data;
903 for (int block_start = start; block_start < end; block_start += 10) 904 for (int block_start = start; block_start < end; block_start += 10)
904 StringAppendF(&data, "rg: %02d-%02d ", block_start, block_start + 9); 905 StringAppendF(&data, "rg: %02d-%02d ", block_start, block_start + 9);
905 *response_data = data; 906 *response_data = data;
906 907
907 if (end - start != 9) { 908 if (end - start != 9) {
908 // We also have to fix content-length. 909 // We also have to fix content-length.
909 int len = end - start + 1; 910 int len = end - start + 1;
910 EXPECT_EQ(0, len % 10); 911 EXPECT_EQ(0, len % 10);
911 std::string content_length = StringPrintf("Content-Length: %d\n", len); 912 std::string content_length = base::StringPrintf("Content-Length: %d\n",
913 len);
912 response_headers->replace(response_headers->find("Content-Length:"), 914 response_headers->replace(response_headers->find("Content-Length:"),
913 content_length.size(), content_length); 915 content_length.size(), content_length);
914 } 916 }
915 if (bad_200_) { 917 if (bad_200_) {
916 // We return a range, but with a response code of 200. 918 // We return a range, but with a response code of 200.
917 response_status->assign("HTTP/1.1 200 Success"); 919 response_status->assign("HTTP/1.1 200 Success");
918 } 920 }
919 } else { 921 } else {
920 response_status->assign("HTTP/1.1 304 Not Modified"); 922 response_status->assign("HTTP/1.1 304 Not Modified");
921 response_data->clear(); 923 response_data->clear();
(...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after
4816 // Now return 200 when validating the entry so the metadata will be lost. 4818 // Now return 200 when validating the entry so the metadata will be lost.
4817 MockTransaction trans2(kTypicalGET_Transaction); 4819 MockTransaction trans2(kTypicalGET_Transaction);
4818 trans2.load_flags = net::LOAD_VALIDATE_CACHE; 4820 trans2.load_flags = net::LOAD_VALIDATE_CACHE;
4819 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); 4821 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response);
4820 EXPECT_TRUE(response.metadata.get() == NULL); 4822 EXPECT_TRUE(response.metadata.get() == NULL);
4821 4823
4822 EXPECT_EQ(3, cache.network_layer()->transaction_count()); 4824 EXPECT_EQ(3, cache.network_layer()->transaction_count());
4823 EXPECT_EQ(4, cache.disk_cache()->open_count()); 4825 EXPECT_EQ(4, cache.disk_cache()->open_count());
4824 EXPECT_EQ(1, cache.disk_cache()->create_count()); 4826 EXPECT_EQ(1, cache.disk_cache()->create_count());
4825 } 4827 }
OLDNEW
« no previous file with comments | « net/http/http_cache.cc ('k') | net/http/http_net_log_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698