OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CONTENT_BROWSER_APPCACHE_APPCACHE_ENTRY_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_ENTRY_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_ENTRY_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_ENTRY_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include "content/common/appcache_interfaces.h" | 10 #include "content/common/appcache_interfaces.h" |
9 | 11 |
10 namespace content { | 12 namespace content { |
11 | 13 |
12 // A cached entry is identified by a URL and is classified into one | 14 // A cached entry is identified by a URL and is classified into one |
13 // (or more) categories. URL is not stored here as this class is stored | 15 // (or more) categories. URL is not stored here as this class is stored |
14 // with the URL as a map key or the user of this class already knows the URL. | 16 // with the URL as a map key or the user of this class already knows the URL. |
15 class AppCacheEntry { | 17 class AppCacheEntry { |
16 public: | 18 public: |
17 | 19 |
18 // An entry can be of more than one type so use a bitmask. | 20 // An entry can be of more than one type so use a bitmask. |
19 // Note: These bit values are stored on disk. | 21 // Note: These bit values are stored on disk. |
20 enum Type { | 22 enum Type { |
21 MASTER = 1 << 0, | 23 MASTER = 1 << 0, |
22 MANIFEST = 1 << 1, | 24 MANIFEST = 1 << 1, |
23 EXPLICIT = 1 << 2, | 25 EXPLICIT = 1 << 2, |
24 FOREIGN = 1 << 3, | 26 FOREIGN = 1 << 3, |
25 FALLBACK = 1 << 4, | 27 FALLBACK = 1 << 4, |
26 INTERCEPT = 1 << 5, | 28 INTERCEPT = 1 << 5, |
27 EXECUTABLE = 1 << 6, | 29 EXECUTABLE = 1 << 6, |
28 }; | 30 }; |
29 | 31 |
30 AppCacheEntry() | 32 AppCacheEntry() |
31 : types_(0), response_id_(kAppCacheNoResponseId), response_size_(0) {} | 33 : types_(0), response_id_(kAppCacheNoResponseId), response_size_(0) {} |
32 | 34 |
33 explicit AppCacheEntry(int type) | 35 explicit AppCacheEntry(int type) |
34 : types_(type), response_id_(kAppCacheNoResponseId), response_size_(0) {} | 36 : types_(type), response_id_(kAppCacheNoResponseId), response_size_(0) {} |
35 | 37 |
36 AppCacheEntry(int type, int64 response_id) | 38 AppCacheEntry(int type, int64_t response_id) |
37 : types_(type), response_id_(response_id), response_size_(0) {} | 39 : types_(type), response_id_(response_id), response_size_(0) {} |
38 | 40 |
39 AppCacheEntry(int type, int64 response_id, int64 response_size) | 41 AppCacheEntry(int type, int64_t response_id, int64_t response_size) |
40 : types_(type), response_id_(response_id), response_size_(response_size) {} | 42 : types_(type), |
| 43 response_id_(response_id), |
| 44 response_size_(response_size) {} |
41 | 45 |
42 int types() const { return types_; } | 46 int types() const { return types_; } |
43 void add_types(int added_types) { types_ |= added_types; } | 47 void add_types(int added_types) { types_ |= added_types; } |
44 bool IsMaster() const { return (types_ & MASTER) != 0; } | 48 bool IsMaster() const { return (types_ & MASTER) != 0; } |
45 bool IsManifest() const { return (types_ & MANIFEST) != 0; } | 49 bool IsManifest() const { return (types_ & MANIFEST) != 0; } |
46 bool IsExplicit() const { return (types_ & EXPLICIT) != 0; } | 50 bool IsExplicit() const { return (types_ & EXPLICIT) != 0; } |
47 bool IsForeign() const { return (types_ & FOREIGN) != 0; } | 51 bool IsForeign() const { return (types_ & FOREIGN) != 0; } |
48 bool IsFallback() const { return (types_ & FALLBACK) != 0; } | 52 bool IsFallback() const { return (types_ & FALLBACK) != 0; } |
49 bool IsIntercept() const { return (types_ & INTERCEPT) != 0; } | 53 bool IsIntercept() const { return (types_ & INTERCEPT) != 0; } |
50 bool IsExecutable() const { return (types_ & EXECUTABLE) != 0; } | 54 bool IsExecutable() const { return (types_ & EXECUTABLE) != 0; } |
51 | 55 |
52 int64 response_id() const { return response_id_; } | 56 int64_t response_id() const { return response_id_; } |
53 void set_response_id(int64 id) { response_id_ = id; } | 57 void set_response_id(int64_t id) { response_id_ = id; } |
54 bool has_response_id() const { return response_id_ != kAppCacheNoResponseId; } | 58 bool has_response_id() const { return response_id_ != kAppCacheNoResponseId; } |
55 | 59 |
56 int64 response_size() const { return response_size_; } | 60 int64_t response_size() const { return response_size_; } |
57 void set_response_size(int64 size) { response_size_ = size; } | 61 void set_response_size(int64_t size) { response_size_ = size; } |
58 | 62 |
59 private: | 63 private: |
60 int types_; | 64 int types_; |
61 int64 response_id_; | 65 int64_t response_id_; |
62 int64 response_size_; | 66 int64_t response_size_; |
63 }; | 67 }; |
64 | 68 |
65 } // namespace content | 69 } // namespace content |
66 | 70 |
67 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_ENTRY_H_ | 71 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_ENTRY_H_ |
OLD | NEW |