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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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_transaction.cc ('k') | net/http/http_chunked_decoder.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) 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 17 #include "base/run_loop.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/test/simple_test_clock.h" 20 #include "base/test/simple_test_clock.h"
20 #include "net/base/cache_type.h" 21 #include "net/base/cache_type.h"
21 #include "net/base/elements_upload_data_stream.h" 22 #include "net/base/elements_upload_data_stream.h"
22 #include "net/base/host_port_pair.h" 23 #include "net/base/host_port_pair.h"
23 #include "net/base/ip_endpoint.h" 24 #include "net/base/ip_endpoint.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // Verifies the response headers (|response|) match a partial content 485 // Verifies the response headers (|response|) match a partial content
485 // response for the range starting at |start| and ending at |end|. 486 // response for the range starting at |start| and ending at |end|.
486 void Verify206Response(const std::string& response, int start, int end) { 487 void Verify206Response(const std::string& response, int start, int end) {
487 std::string raw_headers( 488 std::string raw_headers(
488 HttpUtil::AssembleRawHeaders(response.data(), response.size())); 489 HttpUtil::AssembleRawHeaders(response.data(), response.size()));
489 scoped_refptr<HttpResponseHeaders> headers( 490 scoped_refptr<HttpResponseHeaders> headers(
490 new HttpResponseHeaders(raw_headers)); 491 new HttpResponseHeaders(raw_headers));
491 492
492 ASSERT_EQ(206, headers->response_code()); 493 ASSERT_EQ(206, headers->response_code());
493 494
494 int64 range_start, range_end, object_size; 495 int64_t range_start, range_end, object_size;
495 ASSERT_TRUE( 496 ASSERT_TRUE(
496 headers->GetContentRange(&range_start, &range_end, &object_size)); 497 headers->GetContentRange(&range_start, &range_end, &object_size));
497 int64 content_length = headers->GetContentLength(); 498 int64_t content_length = headers->GetContentLength();
498 499
499 int length = end - start + 1; 500 int length = end - start + 1;
500 ASSERT_EQ(length, content_length); 501 ASSERT_EQ(length, content_length);
501 ASSERT_EQ(start, range_start); 502 ASSERT_EQ(start, range_start);
502 ASSERT_EQ(end, range_end); 503 ASSERT_EQ(end, range_end);
503 } 504 }
504 505
505 // Creates a truncated entry that can be resumed using byte ranges. 506 // Creates a truncated entry that can be resumed using byte ranges.
506 void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) { 507 void CreateTruncatedEntry(std::string raw_headers, MockHttpCache* cache) {
507 // Create a disk cache entry that stores an incomplete resource. 508 // Create a disk cache entry that stores an incomplete resource.
(...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 EXPECT_EQ(0, cache.disk_cache()->create_count()); 2918 EXPECT_EQ(0, cache.disk_cache()->create_count());
2918 } 2919 }
2919 2920
2920 TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Hit) { 2921 TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Hit) {
2921 MockHttpCache cache; 2922 MockHttpCache cache;
2922 2923
2923 // Test that we hit the cache for POST requests. 2924 // Test that we hit the cache for POST requests.
2924 2925
2925 MockTransaction transaction(kSimplePOST_Transaction); 2926 MockTransaction transaction(kSimplePOST_Transaction);
2926 2927
2927 const int64 kUploadId = 1; // Just a dummy value. 2928 const int64_t kUploadId = 1; // Just a dummy value.
2928 2929
2929 std::vector<scoped_ptr<UploadElementReader>> element_readers; 2930 std::vector<scoped_ptr<UploadElementReader>> element_readers;
2930 element_readers.push_back( 2931 element_readers.push_back(
2931 make_scoped_ptr(new UploadBytesElementReader("hello", 5))); 2932 make_scoped_ptr(new UploadBytesElementReader("hello", 5)));
2932 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 2933 ElementsUploadDataStream upload_data_stream(std::move(element_readers),
2933 kUploadId); 2934 kUploadId);
2934 MockHttpRequest request(transaction); 2935 MockHttpRequest request(transaction);
2935 request.upload_data_stream = &upload_data_stream; 2936 request.upload_data_stream = &upload_data_stream;
2936 2937
2937 // Populate the cache. 2938 // Populate the cache.
(...skipping 12 matching lines...) Expand all
2950 EXPECT_EQ(1, cache.disk_cache()->create_count()); 2951 EXPECT_EQ(1, cache.disk_cache()->create_count());
2951 } 2952 }
2952 2953
2953 // Test that we don't hit the cache for POST requests if there is a byte range. 2954 // Test that we don't hit the cache for POST requests if there is a byte range.
2954 TEST(HttpCache, SimplePOST_WithRanges) { 2955 TEST(HttpCache, SimplePOST_WithRanges) {
2955 MockHttpCache cache; 2956 MockHttpCache cache;
2956 2957
2957 MockTransaction transaction(kSimplePOST_Transaction); 2958 MockTransaction transaction(kSimplePOST_Transaction);
2958 transaction.request_headers = "Range: bytes = 0-4\r\n"; 2959 transaction.request_headers = "Range: bytes = 0-4\r\n";
2959 2960
2960 const int64 kUploadId = 1; // Just a dummy value. 2961 const int64_t kUploadId = 1; // Just a dummy value.
2961 2962
2962 std::vector<scoped_ptr<UploadElementReader>> element_readers; 2963 std::vector<scoped_ptr<UploadElementReader>> element_readers;
2963 element_readers.push_back( 2964 element_readers.push_back(
2964 make_scoped_ptr(new UploadBytesElementReader("hello", 5))); 2965 make_scoped_ptr(new UploadBytesElementReader("hello", 5)));
2965 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 2966 ElementsUploadDataStream upload_data_stream(std::move(element_readers),
2966 kUploadId); 2967 kUploadId);
2967 2968
2968 MockHttpRequest request(transaction); 2969 MockHttpRequest request(transaction);
2969 request.upload_data_stream = &upload_data_stream; 2970 request.upload_data_stream = &upload_data_stream;
2970 2971
(...skipping 4760 matching lines...) Expand 10 before | Expand all | Expand 10 after
7731 EXPECT_EQ(1, cache.disk_cache()->open_count()); 7732 EXPECT_EQ(1, cache.disk_cache()->open_count());
7732 EXPECT_EQ(1, cache.disk_cache()->create_count()); 7733 EXPECT_EQ(1, cache.disk_cache()->create_count());
7733 EXPECT_TRUE(response_info.was_cached); 7734 EXPECT_TRUE(response_info.was_cached);
7734 7735
7735 // The new SSL state is reported. 7736 // The new SSL state is reported.
7736 EXPECT_EQ(status2, response_info.ssl_info.connection_status); 7737 EXPECT_EQ(status2, response_info.ssl_info.connection_status);
7737 EXPECT_TRUE(cert2->Equals(response_info.ssl_info.cert.get())); 7738 EXPECT_TRUE(cert2->Equals(response_info.ssl_info.cert.get()));
7738 } 7739 }
7739 7740
7740 } // namespace net 7741 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_chunked_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698