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

Side by Side Diff: webkit/appcache/appcache.h

Issue 192043: AppCacheHost cache selection algorithm (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
OLDNEW
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_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 <string> 10 #include <string>
(...skipping 12 matching lines...) Expand all
23 class AppCacheService; 23 class AppCacheService;
24 24
25 // Set of cached resources for an application. A cache exists as long as a 25 // Set of cached resources for an application. A cache exists as long as a
26 // host is associated with it, the cache is in an appcache group or the 26 // host is associated with it, the cache is in an appcache group or the
27 // cache is being created during an appcache upate. 27 // cache is being created during an appcache upate.
28 class AppCache : public base::RefCounted<AppCache> { 28 class AppCache : public base::RefCounted<AppCache> {
29 public: 29 public:
30 AppCache(AppCacheService *service, int64 cache_id); 30 AppCache(AppCacheService *service, int64 cache_id);
31 ~AppCache(); 31 ~AppCache();
32 32
33 int64 cache_id() { return cache_id_; } 33 int64 cache_id() const { return cache_id_; }
34 34
35 AppCacheGroup* owning_group() { return owning_group_; } 35 AppCacheGroup* owning_group() const { return owning_group_; }
36 void set_owning_group(AppCacheGroup* group) { owning_group_ = group; } 36 void set_owning_group(AppCacheGroup* group) { owning_group_ = group; }
37 37
38 bool is_complete() { return is_complete_; } 38 bool is_complete() const { return is_complete_; }
39 void set_complete(bool value) { is_complete_ = value; } 39 void set_complete(bool value) { is_complete_ = value; }
40 40
41 AppCacheService* service() const { return service_; }
42
41 // Adds a new entry. Entry must not already be in cache. 43 // Adds a new entry. Entry must not already be in cache.
42 void AddEntry(const GURL& url, const AppCacheEntry& entry); 44 void AddEntry(const GURL& url, const AppCacheEntry& entry);
43 45
44 // Adds a new entry or modifies an existing entry by merging the types 46 // Adds a new entry or modifies an existing entry by merging the types
45 // of the new entry with the existing entry. 47 // of the new entry with the existing entry.
46 void AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry); 48 void AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry);
47 49
48 // Do not store the returned object as it could be deleted anytime. 50 // Do not store the returned object as it could be deleted anytime.
49 AppCacheEntry* GetEntry(const GURL& url); 51 AppCacheEntry* GetEntry(const GURL& url);
50 52
51 typedef std::map<GURL, AppCacheEntry> EntryMap; 53 typedef std::map<GURL, AppCacheEntry> EntryMap;
52 const EntryMap& entries() { return entries_; } 54 const EntryMap& entries() const { return entries_; }
53 55
54 bool IsNewerThan(AppCache* cache) { 56 bool IsNewerThan(AppCache* cache) const {
55 return update_time_ > cache->update_time_; 57 return update_time_ > cache->update_time_;
56 } 58 }
57 59
58 void set_update_time(base::TimeTicks ticks = base::TimeTicks::Now()) { 60 void set_update_time(base::TimeTicks ticks = base::TimeTicks::Now()) {
59 update_time_ = ticks; 61 update_time_ = ticks;
60 } 62 }
61 63
62 private: 64 private:
63 friend class AppCacheHost; 65 friend class AppCacheHost;
64 66
65 // Use AppCacheHost::set_selected_cache() to manipulate host association. 67 // Use AppCacheHost::AssociateCache() to manipulate host association.
66 void AssociateHost(AppCacheHost* host) { 68 void AssociateHost(AppCacheHost* host) {
67 associated_hosts_.insert(host); 69 associated_hosts_.insert(host);
68 } 70 }
69 void UnassociateHost(AppCacheHost* host); 71 void UnassociateHost(AppCacheHost* host);
70 72
71 int64 cache_id_; 73 const int64 cache_id_;
72 AppCacheEntry* manifest_; // also in entry map 74 AppCacheEntry* manifest_; // also in entry map
73 AppCacheGroup* owning_group_; 75 AppCacheGroup* owning_group_;
74 std::set<AppCacheHost*> associated_hosts_; 76 std::set<AppCacheHost*> associated_hosts_;
75 77
76 EntryMap entries_; // contains entries of all types 78 EntryMap entries_; // contains entries of all types
77 79
78 std::vector<FallbackNamespace> fallback_namespaces_; 80 std::vector<FallbackNamespace> fallback_namespaces_;
79 std::vector<GURL> online_whitelist_namespaces_; 81 std::vector<GURL> online_whitelist_namespaces_;
80 bool online_whitelist_all_; 82 bool online_whitelist_all_;
81 83
82 bool is_complete_; 84 bool is_complete_;
83 85
84 // when this cache was last updated 86 // when this cache was last updated
85 base::TimeTicks update_time_; 87 base::TimeTicks update_time_;
86 88
87 // to notify service when cache is deleted 89 // to notify service when cache is deleted
88 AppCacheService* service_; 90 AppCacheService* service_;
89 }; 91 };
90 92
91 } // namespace appcache 93 } // namespace appcache
92 94
93 #endif // WEBKIT_APPCACHE_APPCACHE_H_ 95 #endif // WEBKIT_APPCACHE_APPCACHE_H_
OLDNEW
« no previous file with comments | « chrome/common/appcache/appcache_dispatcher_host.cc ('k') | webkit/appcache/appcache_backend_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698