OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/cache_util.h" | 5 #include "media/blink/cache_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 if (code == kHttpPartialContent && | 40 if (code == kHttpPartialContent && |
41 !net::HttpUtil::HasStrongValidators( | 41 !net::HttpUtil::HasStrongValidators( |
42 http_version, | 42 http_version, |
43 response.httpHeaderField("etag").utf8(), | 43 response.httpHeaderField("etag").utf8(), |
44 response.httpHeaderField("Last-Modified").utf8(), | 44 response.httpHeaderField("Last-Modified").utf8(), |
45 response.httpHeaderField("Date").utf8())) { | 45 response.httpHeaderField("Date").utf8())) { |
46 reasons |= kNoStrongValidatorOnPartialResponse; | 46 reasons |= kNoStrongValidatorOnPartialResponse; |
47 } | 47 } |
48 | 48 |
49 std::string cache_control_header = | 49 std::string cache_control_header = |
50 response.httpHeaderField("cache-control").utf8(); | 50 base::ToLowerASCII(response.httpHeaderField("cache-control").utf8()); |
51 base::StringToLowerASCII(&cache_control_header); | |
52 if (cache_control_header.find("no-cache") != std::string::npos) | 51 if (cache_control_header.find("no-cache") != std::string::npos) |
53 reasons |= kNoCache; | 52 reasons |= kNoCache; |
54 if (cache_control_header.find("no-store") != std::string::npos) | 53 if (cache_control_header.find("no-store") != std::string::npos) |
55 reasons |= kNoStore; | 54 reasons |= kNoStore; |
56 if (cache_control_header.find("must-revalidate") != std::string::npos) | 55 if (cache_control_header.find("must-revalidate") != std::string::npos) |
57 reasons |= kHasMustRevalidate; | 56 reasons |= kHasMustRevalidate; |
58 | 57 |
59 const TimeDelta kMinimumAgeForUsefulness = | 58 const TimeDelta kMinimumAgeForUsefulness = |
60 TimeDelta::FromSeconds(3600); // Arbitrary value. | 59 TimeDelta::FromSeconds(3600); // Arbitrary value. |
61 | 60 |
(...skipping 16 matching lines...) Expand all Loading... |
78 &expires) && | 77 &expires) && |
79 date > Time() && expires > Time() && | 78 date > Time() && expires > Time() && |
80 (expires - date) < kMinimumAgeForUsefulness) { | 79 (expires - date) < kMinimumAgeForUsefulness) { |
81 reasons |= kExpiresTooSoon; | 80 reasons |= kExpiresTooSoon; |
82 } | 81 } |
83 | 82 |
84 return reasons; | 83 return reasons; |
85 } | 84 } |
86 | 85 |
87 } // namespace media | 86 } // namespace media |
OLD | NEW |