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