OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_H_ |
6 #define WEBKIT_APPCACHE_APPCACHE_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void set_update_time(base::Time ticks) { update_time_ = ticks; } | 85 void set_update_time(base::Time ticks) { update_time_ = ticks; } |
86 | 86 |
87 // Initializes the cache with information in the manifest. | 87 // Initializes the cache with information in the manifest. |
88 // Do not use the manifest after this call. | 88 // Do not use the manifest after this call. |
89 void InitializeWithManifest(Manifest* manifest); | 89 void InitializeWithManifest(Manifest* manifest); |
90 | 90 |
91 // Initializes the cache with the information in the database records. | 91 // Initializes the cache with the information in the database records. |
92 void InitializeWithDatabaseRecords( | 92 void InitializeWithDatabaseRecords( |
93 const AppCacheDatabase::CacheRecord& cache_record, | 93 const AppCacheDatabase::CacheRecord& cache_record, |
94 const std::vector<AppCacheDatabase::EntryRecord>& entries, | 94 const std::vector<AppCacheDatabase::EntryRecord>& entries, |
95 const std::vector<AppCacheDatabase::FallbackNameSpaceRecord>& fallbacks, | 95 const std::vector<AppCacheDatabase::NamespaceRecord>& intercepts, |
| 96 const std::vector<AppCacheDatabase::NamespaceRecord>& fallbacks, |
96 const std::vector<AppCacheDatabase::OnlineWhiteListRecord>& whitelists); | 97 const std::vector<AppCacheDatabase::OnlineWhiteListRecord>& whitelists); |
97 | 98 |
98 // Returns the database records to be stored in the AppCacheDatabase | 99 // Returns the database records to be stored in the AppCacheDatabase |
99 // to represent this cache. | 100 // to represent this cache. |
100 void ToDatabaseRecords( | 101 void ToDatabaseRecords( |
101 const AppCacheGroup* group, | 102 const AppCacheGroup* group, |
102 AppCacheDatabase::CacheRecord* cache_record, | 103 AppCacheDatabase::CacheRecord* cache_record, |
103 std::vector<AppCacheDatabase::EntryRecord>* entries, | 104 std::vector<AppCacheDatabase::EntryRecord>* entries, |
104 std::vector<AppCacheDatabase::FallbackNameSpaceRecord>* fallbacks, | 105 std::vector<AppCacheDatabase::NamespaceRecord>* intercepts, |
| 106 std::vector<AppCacheDatabase::NamespaceRecord>* fallbacks, |
105 std::vector<AppCacheDatabase::OnlineWhiteListRecord>* whitelists); | 107 std::vector<AppCacheDatabase::OnlineWhiteListRecord>* whitelists); |
106 | 108 |
107 bool FindResponseForRequest(const GURL& url, | 109 bool FindResponseForRequest(const GURL& url, |
108 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, | 110 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, |
109 GURL* found_fallback_namespace, bool* found_network_namespace); | 111 GURL* found_fallback_namespace, bool* found_network_namespace); |
110 | 112 |
111 // Populates the 'infos' vector with an element per entry in the appcache. | 113 // Populates the 'infos' vector with an element per entry in the appcache. |
112 void ToResourceInfoVector(AppCacheResourceInfoVector* infos) const; | 114 void ToResourceInfoVector(AppCacheResourceInfoVector* infos) const; |
113 | 115 |
114 static bool IsInNetworkNamespace( | 116 static bool IsInNetworkNamespace( |
115 const GURL& url, | 117 const GURL& url, |
116 const std::vector<GURL> &namespaces); | 118 const std::vector<GURL> &namespaces); |
117 | 119 |
118 private: | 120 private: |
119 friend class AppCacheGroup; | 121 friend class AppCacheGroup; |
120 friend class AppCacheHost; | 122 friend class AppCacheHost; |
121 friend class AppCacheStorageImplTest; | 123 friend class AppCacheStorageImplTest; |
122 friend class AppCacheUpdateJobTest; | 124 friend class AppCacheUpdateJobTest; |
123 friend class base::RefCounted<AppCache>; | 125 friend class base::RefCounted<AppCache>; |
124 | 126 |
125 ~AppCache(); | 127 ~AppCache(); |
126 | 128 |
127 // Use AppCacheGroup::Add/RemoveCache() to manipulate owning group. | 129 // Use AppCacheGroup::Add/RemoveCache() to manipulate owning group. |
128 void set_owning_group(AppCacheGroup* group) { owning_group_ = group; } | 130 void set_owning_group(AppCacheGroup* group) { owning_group_ = group; } |
129 | 131 |
130 // FindResponseForRequest helpers | 132 // FindResponseForRequest helpers |
131 FallbackNamespace* FindFallbackNamespace(const GURL& url); | 133 const Namespace* FindInterceptNamespace(const GURL& url) { |
| 134 return FindNamespace(intercept_namespaces_, url); |
| 135 } |
| 136 const Namespace* FindFallbackNamespace(const GURL& url) { |
| 137 return FindNamespace(fallback_namespaces_, url); |
| 138 } |
| 139 const Namespace* FindNamespace(const NamespaceVector& namespaces, |
| 140 const GURL& url); |
132 | 141 |
133 // Use AppCacheHost::Associate*Cache() to manipulate host association. | 142 // Use AppCacheHost::Associate*Cache() to manipulate host association. |
134 void AssociateHost(AppCacheHost* host) { | 143 void AssociateHost(AppCacheHost* host) { |
135 associated_hosts_.insert(host); | 144 associated_hosts_.insert(host); |
136 } | 145 } |
137 void UnassociateHost(AppCacheHost* host); | 146 void UnassociateHost(AppCacheHost* host); |
138 | 147 |
139 const int64 cache_id_; | 148 const int64 cache_id_; |
140 scoped_refptr<AppCacheGroup> owning_group_; | 149 scoped_refptr<AppCacheGroup> owning_group_; |
141 AppCacheHosts associated_hosts_; | 150 AppCacheHosts associated_hosts_; |
142 | 151 |
143 EntryMap entries_; // contains entries of all types | 152 EntryMap entries_; // contains entries of all types |
144 | 153 |
145 std::vector<FallbackNamespace> fallback_namespaces_; | 154 NamespaceVector intercept_namespaces_; |
| 155 NamespaceVector fallback_namespaces_; |
146 std::vector<GURL> online_whitelist_namespaces_; | 156 std::vector<GURL> online_whitelist_namespaces_; |
147 bool online_whitelist_all_; | 157 bool online_whitelist_all_; |
148 | 158 |
149 bool is_complete_; | 159 bool is_complete_; |
150 | 160 |
151 // when this cache was last updated | 161 // when this cache was last updated |
152 base::Time update_time_; | 162 base::Time update_time_; |
153 | 163 |
154 int64 cache_size_; | 164 int64 cache_size_; |
155 | 165 |
156 // to notify service when cache is deleted | 166 // to notify service when cache is deleted |
157 AppCacheService* service_; | 167 AppCacheService* service_; |
158 | 168 |
159 FRIEND_TEST_ALL_PREFIXES(AppCacheTest, InitializeWithManifest); | 169 FRIEND_TEST_ALL_PREFIXES(AppCacheTest, InitializeWithManifest); |
160 | 170 |
161 DISALLOW_COPY_AND_ASSIGN(AppCache); | 171 DISALLOW_COPY_AND_ASSIGN(AppCache); |
162 }; | 172 }; |
163 | 173 |
164 } // namespace appcache | 174 } // namespace appcache |
165 | 175 |
166 #endif // WEBKIT_APPCACHE_APPCACHE_H_ | 176 #endif // WEBKIT_APPCACHE_APPCACHE_H_ |
OLD | NEW |