OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
11 #include <set> | 12 #include <set> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "content/browser/appcache/appcache_database.h" | 19 #include "content/browser/appcache/appcache_database.h" |
19 #include "content/browser/appcache/appcache_entry.h" | 20 #include "content/browser/appcache/appcache_entry.h" |
20 #include "content/browser/appcache/appcache_manifest_parser.h" | 21 #include "content/browser/appcache/appcache_manifest_parser.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // of the new entry with the existing entry. Returns true if a new entry | 62 // of the new entry with the existing entry. Returns true if a new entry |
62 // is added, false if the flags are merged into an existing entry. | 63 // is added, false if the flags are merged into an existing entry. |
63 bool AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry); | 64 bool AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry); |
64 | 65 |
65 // Removes an entry from the EntryMap, the URL must be in the set. | 66 // Removes an entry from the EntryMap, the URL must be in the set. |
66 void RemoveEntry(const GURL& url); | 67 void RemoveEntry(const GURL& url); |
67 | 68 |
68 // Do not store or delete the returned ptr, they're owned by 'this'. | 69 // Do not store or delete the returned ptr, they're owned by 'this'. |
69 AppCacheEntry* GetEntry(const GURL& url); | 70 AppCacheEntry* GetEntry(const GURL& url); |
70 const AppCacheEntry* GetEntryWithResponseId(int64_t response_id) { | 71 const AppCacheEntry* GetEntryWithResponseId(int64_t response_id) { |
71 return GetEntryAndUrlWithResponseId(response_id, NULL); | 72 return GetEntryAndUrlWithResponseId(response_id, nullptr); |
72 } | 73 } |
73 const AppCacheEntry* GetEntryAndUrlWithResponseId(int64_t response_id, | 74 const AppCacheEntry* GetEntryAndUrlWithResponseId(int64_t response_id, |
74 GURL* optional_url); | 75 GURL* optional_url); |
75 const EntryMap& entries() const { return entries_; } | 76 const EntryMap& entries() const { return entries_; } |
76 | 77 |
77 // The AppCache owns the collection of executable handlers that have | 78 // The AppCache owns the collection of executable handlers that have |
78 // been started for this instance. The getter looks up an existing | 79 // been started for this instance. The getter looks up an existing |
79 // handler returning null if not found, the GetOrCreate method will | 80 // handler returning null if not found, the GetOrCreate method will |
80 // cons one up if not found. | 81 // cons one up if not found. |
81 // Do not store the returned ptrs, they're owned by 'this'. | 82 // Do not store the returned ptrs, they're owned by 'this'. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 void set_owning_group(AppCacheGroup* group) { owning_group_ = group; } | 162 void set_owning_group(AppCacheGroup* group) { owning_group_ = group; } |
162 | 163 |
163 // FindResponseForRequest helpers | 164 // FindResponseForRequest helpers |
164 const AppCacheNamespace* FindInterceptNamespace(const GURL& url) { | 165 const AppCacheNamespace* FindInterceptNamespace(const GURL& url) { |
165 return FindNamespace(intercept_namespaces_, url); | 166 return FindNamespace(intercept_namespaces_, url); |
166 } | 167 } |
167 const AppCacheNamespace* FindFallbackNamespace(const GURL& url) { | 168 const AppCacheNamespace* FindFallbackNamespace(const GURL& url) { |
168 return FindNamespace(fallback_namespaces_, url); | 169 return FindNamespace(fallback_namespaces_, url); |
169 } | 170 } |
170 bool IsInNetworkNamespace(const GURL& url) { | 171 bool IsInNetworkNamespace(const GURL& url) { |
171 return FindNamespace(online_whitelist_namespaces_, url) != NULL; | 172 return FindNamespace(online_whitelist_namespaces_, url) != nullptr; |
172 } | 173 } |
173 | 174 |
174 GURL GetNamespaceEntryUrl(const AppCacheNamespaceVector& namespaces, | 175 GURL GetNamespaceEntryUrl(const AppCacheNamespaceVector& namespaces, |
175 const GURL& namespace_url) const; | 176 const GURL& namespace_url) const; |
176 | 177 |
177 // Use AppCacheHost::Associate*Cache() to manipulate host association. | 178 // Use AppCacheHost::Associate*Cache() to manipulate host association. |
178 void AssociateHost(AppCacheHost* host) { | 179 void AssociateHost(AppCacheHost* host) { |
179 associated_hosts_.insert(host); | 180 associated_hosts_.insert(host); |
180 } | 181 } |
181 void UnassociateHost(AppCacheHost* host); | 182 void UnassociateHost(AppCacheHost* host); |
182 | 183 |
183 const int64_t cache_id_; | 184 const int64_t cache_id_; |
184 scoped_refptr<AppCacheGroup> owning_group_; | 185 scoped_refptr<AppCacheGroup> owning_group_; |
185 AppCacheHosts associated_hosts_; | 186 AppCacheHosts associated_hosts_; |
186 | 187 |
187 EntryMap entries_; // contains entries of all types | 188 EntryMap entries_; // contains entries of all types |
188 | 189 |
189 AppCacheNamespaceVector intercept_namespaces_; | 190 AppCacheNamespaceVector intercept_namespaces_; |
190 AppCacheNamespaceVector fallback_namespaces_; | 191 AppCacheNamespaceVector fallback_namespaces_; |
191 AppCacheNamespaceVector online_whitelist_namespaces_; | 192 AppCacheNamespaceVector online_whitelist_namespaces_; |
192 bool online_whitelist_all_; | 193 bool online_whitelist_all_; |
193 | 194 |
194 bool is_complete_; | 195 bool is_complete_; |
195 | 196 |
196 // when this cache was last updated | 197 // when this cache was last updated |
197 base::Time update_time_; | 198 base::Time update_time_; |
198 | 199 |
199 int64_t cache_size_; | 200 int64_t cache_size_; |
200 | 201 |
201 typedef std::map<int64_t, AppCacheExecutableHandler*> HandlerMap; | 202 typedef std::map<int64_t, std::unique_ptr<AppCacheExecutableHandler>> |
| 203 HandlerMap; |
202 HandlerMap executable_handlers_; | 204 HandlerMap executable_handlers_; |
203 | 205 |
204 // to notify storage when cache is deleted | 206 // to notify storage when cache is deleted |
205 AppCacheStorage* storage_; | 207 AppCacheStorage* storage_; |
206 | 208 |
207 FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, InitializeWithManifest); | 209 FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, InitializeWithManifest); |
208 FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, ToFromDatabaseRecords); | 210 FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, ToFromDatabaseRecords); |
209 DISALLOW_COPY_AND_ASSIGN(AppCache); | 211 DISALLOW_COPY_AND_ASSIGN(AppCache); |
210 }; | 212 }; |
211 | 213 |
212 } // namespace content | 214 } // namespace content |
213 | 215 |
214 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_H_ | 216 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_H_ |
OLD | NEW |