| 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 enum Type { | 19 enum Type { |
| 20 MASTER = 1 << 0, | 20 MASTER = 1 << 0, |
| 21 MANIFEST = 1 << 1, | 21 MANIFEST = 1 << 1, |
| 22 EXPLICIT = 1 << 2, | 22 EXPLICIT = 1 << 2, |
| 23 FOREIGN = 1 << 3, | 23 FOREIGN = 1 << 3, |
| 24 FALLBACK = 1 << 4, | 24 FALLBACK = 1 << 4, |
| 25 INTERCEPT = 1 << 5, |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 AppCacheEntry() | 28 AppCacheEntry() |
| 28 : types_(0), response_id_(kNoResponseId), response_size_(0) {} | 29 : types_(0), response_id_(kNoResponseId), response_size_(0) {} |
| 29 | 30 |
| 30 explicit AppCacheEntry(int type) | 31 explicit AppCacheEntry(int type) |
| 31 : types_(type), response_id_(kNoResponseId), response_size_(0) {} | 32 : types_(type), response_id_(kNoResponseId), response_size_(0) {} |
| 32 | 33 |
| 33 AppCacheEntry(int type, int64 response_id) | 34 AppCacheEntry(int type, int64 response_id) |
| 34 : types_(type), response_id_(response_id), response_size_(0) {} | 35 : types_(type), response_id_(response_id), response_size_(0) {} |
| 35 | 36 |
| 36 AppCacheEntry(int type, int64 response_id, int64 response_size) | 37 AppCacheEntry(int type, int64 response_id, int64 response_size) |
| 37 : types_(type), response_id_(response_id), response_size_(response_size) {} | 38 : types_(type), response_id_(response_id), response_size_(response_size) {} |
| 38 | 39 |
| 39 int types() const { return types_; } | 40 int types() const { return types_; } |
| 40 void add_types(int added_types) { types_ |= added_types; } | 41 void add_types(int added_types) { types_ |= added_types; } |
| 41 bool IsMaster() const { return (types_ & MASTER) != 0; } | 42 bool IsMaster() const { return (types_ & MASTER) != 0; } |
| 42 bool IsManifest() const { return (types_ & MANIFEST) != 0; } | 43 bool IsManifest() const { return (types_ & MANIFEST) != 0; } |
| 43 bool IsExplicit() const { return (types_ & EXPLICIT) != 0; } | 44 bool IsExplicit() const { return (types_ & EXPLICIT) != 0; } |
| 44 bool IsForeign() const { return (types_ & FOREIGN) != 0; } | 45 bool IsForeign() const { return (types_ & FOREIGN) != 0; } |
| 45 bool IsFallback() const { return (types_ & FALLBACK) != 0; } | 46 bool IsFallback() const { return (types_ & FALLBACK) != 0; } |
| 47 bool IsIntercept() const { return (types_ & INTERCEPT) != 0; } |
| 46 | 48 |
| 47 int64 response_id() const { return response_id_; } | 49 int64 response_id() const { return response_id_; } |
| 48 void set_response_id(int64 id) { response_id_ = id; } | 50 void set_response_id(int64 id) { response_id_ = id; } |
| 49 bool has_response_id() const { return response_id_ != kNoResponseId; } | 51 bool has_response_id() const { return response_id_ != kNoResponseId; } |
| 50 | 52 |
| 51 int64 response_size() const { return response_size_; } | 53 int64 response_size() const { return response_size_; } |
| 52 void set_response_size(int64 size) { response_size_ = size; } | 54 void set_response_size(int64 size) { response_size_ = size; } |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 int types_; | 57 int types_; |
| 56 int64 response_id_; | 58 int64 response_id_; |
| 57 int64 response_size_; | 59 int64 response_size_; |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 } // namespace appcache | 62 } // namespace appcache |
| 61 | 63 |
| 62 #endif // WEBKIT_APPCACHE_APPCACHE_RESOURCE_H_ | 64 #endif // WEBKIT_APPCACHE_APPCACHE_RESOURCE_H_ |
| OLD | NEW |