| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 base::Time::FromString("Wed, 28 Nov 2007 00:40:09 GMT", &request_time); | 859 base::Time::FromString("Wed, 28 Nov 2007 00:40:09 GMT", &request_time); |
| 860 base::Time::FromString("Wed, 28 Nov 2007 00:40:12 GMT", &response_time); | 860 base::Time::FromString("Wed, 28 Nov 2007 00:40:12 GMT", &response_time); |
| 861 base::Time::FromString("Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); | 861 base::Time::FromString("Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); |
| 862 | 862 |
| 863 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 863 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 864 std::string headers(tests[i].headers); | 864 std::string headers(tests[i].headers); |
| 865 HeadersToRaw(&headers); | 865 HeadersToRaw(&headers); |
| 866 scoped_refptr<net::HttpResponseHeaders> parsed( | 866 scoped_refptr<net::HttpResponseHeaders> parsed( |
| 867 new net::HttpResponseHeaders(headers)); | 867 new net::HttpResponseHeaders(headers)); |
| 868 | 868 |
| 869 bool requires_validation = | 869 base::Time freshness_expiry = |
| 870 parsed->RequiresValidation(request_time, response_time, current_time); | 870 parsed->GetFreshnessExpiry(request_time, response_time); |
| 871 bool requires_validation = freshness_expiry <= current_time; |
| 871 EXPECT_EQ(tests[i].requires_validation, requires_validation); | 872 EXPECT_EQ(tests[i].requires_validation, requires_validation); |
| 872 } | 873 } |
| 873 } | 874 } |
| 874 | 875 |
| 875 TEST(HttpResponseHeadersTest, Update) { | 876 TEST(HttpResponseHeadersTest, Update) { |
| 876 const struct { | 877 const struct { |
| 877 const char* orig_headers; | 878 const char* orig_headers; |
| 878 const char* new_headers; | 879 const char* new_headers; |
| 879 const char* expected_headers; | 880 const char* expected_headers; |
| 880 } tests[] = { | 881 } tests[] = { |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2039 net::HttpResponseHeaders::ChromeProxyInfo chrome_proxy_info; | 2040 net::HttpResponseHeaders::ChromeProxyInfo chrome_proxy_info; |
| 2040 EXPECT_EQ(tests[i].expected_result, | 2041 EXPECT_EQ(tests[i].expected_result, |
| 2041 parsed->GetChromeProxyInfo(&chrome_proxy_info)); | 2042 parsed->GetChromeProxyInfo(&chrome_proxy_info)); |
| 2042 EXPECT_EQ(tests[i].expected_retry_delay, | 2043 EXPECT_EQ(tests[i].expected_retry_delay, |
| 2043 chrome_proxy_info.bypass_duration.InSeconds()); | 2044 chrome_proxy_info.bypass_duration.InSeconds()); |
| 2044 EXPECT_EQ(tests[i].expected_bypass_all, | 2045 EXPECT_EQ(tests[i].expected_bypass_all, |
| 2045 chrome_proxy_info.bypass_all); | 2046 chrome_proxy_info.bypass_all); |
| 2046 } | 2047 } |
| 2047 } | 2048 } |
| 2048 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | 2049 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
| OLD | NEW |