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 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 const scoped_refptr<net::HttpResponseHeaders>& headers() { return headers_; } | 55 const scoped_refptr<net::HttpResponseHeaders>& headers() { return headers_; } |
56 | 56 |
57 // Return a pointer to a TimeDelta object. For use when the value doesn't | 57 // Return a pointer to a TimeDelta object. For use when the value doesn't |
58 // matter. | 58 // matter. |
59 TimeDelta* TimeDeltaPointer() { return &delta_; } | 59 TimeDelta* TimeDeltaPointer() { return &delta_; } |
60 | 60 |
61 // Get the max-age value. This should only be used in tests where a valid | 61 // Get the max-age value. This should only be used in tests where a valid |
62 // max-age parameter is expected to be present. | 62 // max-age parameter is expected to be present. |
63 TimeDelta GetMaxAgeValue() { | 63 TimeDelta GetMaxAgeValue() { |
64 DCHECK(headers_) << "Call InitializeHeadersWithCacheControl() first"; | 64 DCHECK(headers_.get()) << "Call InitializeHeadersWithCacheControl() first"; |
65 TimeDelta max_age_value; | 65 TimeDelta max_age_value; |
66 EXPECT_TRUE(headers()->GetMaxAgeValue(&max_age_value)); | 66 EXPECT_TRUE(headers()->GetMaxAgeValue(&max_age_value)); |
67 return max_age_value; | 67 return max_age_value; |
68 } | 68 } |
69 | 69 |
70 // Get the stale-while-revalidate value. This should only be used in tests | 70 // Get the stale-while-revalidate value. This should only be used in tests |
71 // where a valid max-age parameter is expected to be present. | 71 // where a valid max-age parameter is expected to be present. |
72 TimeDelta GetStaleWhileRevalidateValue() { | 72 TimeDelta GetStaleWhileRevalidateValue() { |
73 DCHECK(headers_) << "Call InitializeHeadersWithCacheControl() first"; | 73 DCHECK(headers_.get()) << "Call InitializeHeadersWithCacheControl() first"; |
74 TimeDelta stale_while_revalidate_value; | 74 TimeDelta stale_while_revalidate_value; |
75 EXPECT_TRUE( | 75 EXPECT_TRUE( |
76 headers()->GetStaleWhileRevalidateValue(&stale_while_revalidate_value)); | 76 headers()->GetStaleWhileRevalidateValue(&stale_while_revalidate_value)); |
77 return stale_while_revalidate_value; | 77 return stale_while_revalidate_value; |
78 } | 78 } |
79 | 79 |
80 private: | 80 private: |
81 scoped_refptr<net::HttpResponseHeaders> headers_; | 81 scoped_refptr<net::HttpResponseHeaders> headers_; |
82 TimeDelta delta_; | 82 TimeDelta delta_; |
83 }; | 83 }; |
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 } | 2247 } |
2248 | 2248 |
2249 TEST_F(HttpResponseHeadersCacheControlTest, | 2249 TEST_F(HttpResponseHeadersCacheControlTest, |
2250 FirstStaleWhileRevalidateValueUsed) { | 2250 FirstStaleWhileRevalidateValueUsed) { |
2251 InitializeHeadersWithCacheControl( | 2251 InitializeHeadersWithCacheControl( |
2252 "stale-while-revalidate=1,stale-while-revalidate=7200"); | 2252 "stale-while-revalidate=1,stale-while-revalidate=7200"); |
2253 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); | 2253 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); |
2254 } | 2254 } |
2255 | 2255 |
2256 } // end namespace | 2256 } // end namespace |
OLD | NEW |