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 WEBKIT_APPCACHE_APPCACHE_ENTRY_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_ENTRY_H_ |
6 #define WEBKIT_APPCACHE_APPCACHE_ENTRY_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_ENTRY_H_ |
7 | 7 |
8 #include "googleurl/src/gurl.h" | |
9 | |
10 namespace appcache { | 8 namespace appcache { |
11 | 9 |
12 // A cached entry is identified by a URL and is classified into one | 10 // 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 | 11 // (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. | 12 // with the URL as a map key or the user of this class already knows the URL. |
15 class AppCacheEntry { | 13 class AppCacheEntry { |
16 public: | 14 public: |
17 | 15 |
18 // An entry can be of more than one type so use a bitmask. | 16 // An entry can be of more than one type so use a bitmask. |
19 enum Type { | 17 enum Type { |
20 MASTER = 1 << 0, | 18 MASTER = 1 << 0, |
21 MANIFEST = 1 << 1, | 19 MANIFEST = 1 << 1, |
22 EXPLICIT = 1 << 2, | 20 EXPLICIT = 1 << 2, |
23 FOREIGN = 1 << 3, | 21 FOREIGN = 1 << 3, |
24 FALLBACK = 1 << 4, | 22 FALLBACK = 1 << 4, |
25 }; | 23 }; |
26 | 24 |
27 explicit AppCacheEntry(int type) : types_(type) {} | 25 explicit AppCacheEntry(int type) : types_(type) {} |
28 | 26 |
29 int types() const { return types_; } | 27 int types() const { return types_; } |
30 void add_types(int added_types) { types_ |= added_types; } | 28 void add_types(int added_types) { types_ |= added_types; } |
31 bool IsMaster() const { return types_ & MASTER; } | 29 bool IsMaster() const { return (types_ & MASTER) != 0; } |
32 bool IsManifest() const { return types_ & MANIFEST; } | 30 bool IsManifest() const { return (types_ & MANIFEST) != 0; } |
33 bool IsExplicit() const { return types_ & EXPLICIT; } | 31 bool IsExplicit() const { return (types_ & EXPLICIT) != 0; } |
34 bool IsForeign() const { return types_ & FOREIGN; } | 32 bool IsForeign() const { return (types_ & FOREIGN) != 0; } |
35 bool IsFallback() const { return types_ & FALLBACK; } | 33 bool IsFallback() const { return (types_ & FALLBACK) != 0; } |
36 | 34 |
37 private: | 35 private: |
38 int types_; | 36 int types_; |
39 | 37 |
40 // TODO(jennb): response storage key | 38 // TODO(jennb): response storage key |
41 }; | 39 }; |
42 | 40 |
43 } // namespace appcache | 41 } // namespace appcache |
44 | 42 |
45 #endif // WEBKIT_APPCACHE_APPCACHE_RESOURCE_H_ | 43 #endif // WEBKIT_APPCACHE_APPCACHE_RESOURCE_H_ |
OLD | NEW |