Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: content/browser/appcache/appcache_storage.h

Issue 2902653002: Get main frame and subframe AppCache loads to work. (Closed)
Patch Set: Address review comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_STORAGE_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h"
18 #include "content/browser/appcache/appcache_working_set.h" 19 #include "content/browser/appcache/appcache_working_set.h"
19 #include "content/common/content_export.h" 20 #include "content/common/content_export.h"
20 #include "net/base/completion_callback.h" 21 #include "net/base/completion_callback.h"
21 22
22 class GURL; 23 class GURL;
23 24
24 namespace content { 25 namespace content {
25 FORWARD_DECLARE_TEST(AppCacheStorageTest, DelegateReferences); 26 FORWARD_DECLARE_TEST(AppCacheStorageTest, DelegateReferences);
26 FORWARD_DECLARE_TEST(AppCacheStorageTest, UsageMap); 27 FORWARD_DECLARE_TEST(AppCacheStorageTest, UsageMap);
27 class AppCache; 28 class AppCache;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // persistently such that the responses will be deleted upon restart 188 // persistently such that the responses will be deleted upon restart
188 // if they aren't deleted prior to shutdown. 189 // if they aren't deleted prior to shutdown.
189 virtual void DoomResponses(const GURL& manifest_url, 190 virtual void DoomResponses(const GURL& manifest_url,
190 const std::vector<int64_t>& response_ids) = 0; 191 const std::vector<int64_t>& response_ids) = 0;
191 192
192 // Schedules the lazy deletion of responses without persistently saving 193 // Schedules the lazy deletion of responses without persistently saving
193 // the response ids. 194 // the response ids.
194 virtual void DeleteResponses(const GURL& manifest_url, 195 virtual void DeleteResponses(const GURL& manifest_url,
195 const std::vector<int64_t>& response_ids) = 0; 196 const std::vector<int64_t>& response_ids) = 0;
196 197
198 // Returns true if the AppCacheStorage instance is initialized.
199 virtual bool IsInitialized() = 0;
200
197 // Generates unique storage ids for different object types. 201 // Generates unique storage ids for different object types.
198 int64_t NewCacheId() { return ++last_cache_id_; } 202 int64_t NewCacheId() { return ++last_cache_id_; }
199 int64_t NewGroupId() { return ++last_group_id_; } 203 int64_t NewGroupId() { return ++last_group_id_; }
200 204
201 // The working set of object instances currently in memory. 205 // The working set of object instances currently in memory.
202 AppCacheWorkingSet* working_set() { return &working_set_; } 206 AppCacheWorkingSet* working_set() { return &working_set_; }
203 207
204 // A map of origins to usage. 208 // A map of origins to usage.
205 const UsageMap* usage_map() { return &usage_map_; } 209 const UsageMap* usage_map() { return &usage_map_; }
206 210
207 // Simple ptr back to the service object that owns us. 211 // Simple ptr back to the service object that owns us.
208 AppCacheServiceImpl* service() { return service_; } 212 AppCacheServiceImpl* service() { return service_; }
209 213
214 // Returns a weak pointer reference to the AppCacheStorage instance.
215 base::WeakPtr<AppCacheStorage> GetWeakPtr();
216
210 protected: 217 protected:
211 friend class content::AppCacheQuotaClientTest; 218 friend class content::AppCacheQuotaClientTest;
212 friend class content::AppCacheResponseTest; 219 friend class content::AppCacheResponseTest;
213 friend class content::AppCacheStorageTest; 220 friend class content::AppCacheStorageTest;
214 221
215 // Helper to call a collection of delegates. 222 // Helper to call a collection of delegates.
216 #define FOR_EACH_DELEGATE(delegates, func_and_args) \ 223 #define FOR_EACH_DELEGATE(delegates, func_and_args) \
217 do { \ 224 do { \
218 for (DelegateReferenceVector::iterator it = delegates.begin(); \ 225 for (DelegateReferenceVector::iterator it = delegates.begin(); \
219 it != delegates.end(); ++it) { \ 226 it != delegates.end(); ++it) { \
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 326
320 // Note that the ResponseInfoLoadTask items add themselves to this map. 327 // Note that the ResponseInfoLoadTask items add themselves to this map.
321 std::map<int64_t, std::unique_ptr<ResponseInfoLoadTask>> pending_info_loads_; 328 std::map<int64_t, std::unique_ptr<ResponseInfoLoadTask>> pending_info_loads_;
322 329
323 // The set of last ids must be retrieved from storage prior to being used. 330 // The set of last ids must be retrieved from storage prior to being used.
324 static const int64_t kUnitializedId; 331 static const int64_t kUnitializedId;
325 332
326 FRIEND_TEST_ALL_PREFIXES(content::AppCacheStorageTest, DelegateReferences); 333 FRIEND_TEST_ALL_PREFIXES(content::AppCacheStorageTest, DelegateReferences);
327 FRIEND_TEST_ALL_PREFIXES(content::AppCacheStorageTest, UsageMap); 334 FRIEND_TEST_ALL_PREFIXES(content::AppCacheStorageTest, UsageMap);
328 335
336 // The WeakPtrFactory below must occur last in the class definition so they
337 // get destroyed last.
338 base::WeakPtrFactory<AppCacheStorage> weak_factory_;
339
329 DISALLOW_COPY_AND_ASSIGN(AppCacheStorage); 340 DISALLOW_COPY_AND_ASSIGN(AppCacheStorage);
330 }; 341 };
331 342
332 } // namespace content 343 } // namespace content
333 344
334 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_H_ 345 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_request_handler.cc ('k') | content/browser/appcache/appcache_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698