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 #ifndef MEDIA_BLINK_CACHE_UTIL_H_ | 5 #ifndef MEDIA_BLINK_CACHE_UTIL_H_ |
6 #define MEDIA_BLINK_CACHE_UTIL_H_ | 6 #define MEDIA_BLINK_CACHE_UTIL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/time/time.h" | 10 #include "base/time/time.h" |
12 #include "media/blink/media_blink_export.h" | 11 #include "media/blink/media_blink_export.h" |
13 | 12 |
14 namespace blink { | 13 namespace blink { |
15 class WebURLResponse; | 14 class WebURLResponse; |
16 } | 15 } |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 | 18 |
20 // Reasons that a cached WebURLResponse will *not* prevent a future request to | 19 // Reasons that a cached WebURLResponse will *not* prevent a future request to |
21 // the server. Reported via UMA, so don't change/reuse previously-existing | 20 // the server. Reported via UMA, so don't change/reuse previously-existing |
22 // values. | 21 // values. |
23 enum UncacheableReason { | 22 enum UncacheableReason { |
24 kNoData = 1 << 0, // Not 200 or 206. | 23 kNoData = 1 << 0, // Not 200 or 206. |
25 kPre11PartialResponse = 1 << 1, // 206 but HTTP version < 1.1. | 24 kPre11PartialResponse = 1 << 1, // 206 but HTTP version < 1.1. |
26 kNoStrongValidatorOnPartialResponse = 1 << 2, // 206, no strong validator. | 25 kNoStrongValidatorOnPartialResponse = 1 << 2, // 206, no strong validator. |
27 kShortMaxAge = 1 << 3, // Max age less than 1h (arbitrary value). | 26 kShortMaxAge = 1 << 3, // Max age less than 1h (arbitrary value). |
28 kExpiresTooSoon = 1 << 4, // Expires in less than 1h (arbitrary value). | 27 kExpiresTooSoon = 1 << 4, // Expires in less than 1h (arbitrary value). |
29 kHasMustRevalidate = 1 << 5, // Response asks for revalidation. | 28 kHasMustRevalidate = 1 << 5, // Response asks for revalidation. |
30 kNoCache = 1 << 6, // Response included a no-cache header. | 29 kNoCache = 1 << 6, // Response included a no-cache header. |
31 kNoStore = 1 << 7, // Response included a no-store header. | 30 kNoStore = 1 << 7, // Response included a no-store header. |
32 kMaxReason // Needs to be one more than max legitimate reason. | 31 kMaxReason // Needs to be one more than max legitimate reason. |
33 }; | 32 }; |
34 | 33 |
35 // Return the logical OR of the reasons "response" cannot be used for a future | 34 // Return the logical OR of the reasons "response" cannot be used for a future |
36 // request (using the disk cache), or 0 if it might be useful. | 35 // request (using the disk cache), or 0 if it might be useful. |
37 uint32 MEDIA_BLINK_EXPORT | 36 uint32_t MEDIA_BLINK_EXPORT |
38 GetReasonsForUncacheability(const blink::WebURLResponse& response); | 37 GetReasonsForUncacheability(const blink::WebURLResponse& response); |
39 | 38 |
40 // Returns when we should evict data from this response from our | 39 // Returns when we should evict data from this response from our |
41 // memory cache. Note that we may still cache data longer if | 40 // memory cache. Note that we may still cache data longer if |
42 // a audio/video tag is currently using it. Returns a TimeDelta | 41 // a audio/video tag is currently using it. Returns a TimeDelta |
43 // which is should be added to base::Time::Now() or base::TimeTicks::Now(). | 42 // which is should be added to base::Time::Now() or base::TimeTicks::Now(). |
44 base::TimeDelta MEDIA_BLINK_EXPORT | 43 base::TimeDelta MEDIA_BLINK_EXPORT |
45 GetCacheValidUntil(const blink::WebURLResponse& response); | 44 GetCacheValidUntil(const blink::WebURLResponse& response); |
46 | 45 |
47 } // namespace media | 46 } // namespace media |
48 | 47 |
49 #endif // MEDIA_BLINK_CACHE_UTIL_H_ | 48 #endif // MEDIA_BLINK_CACHE_UTIL_H_ |
OLD | NEW |