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 CONTENT_BROWSER_APPCACHE_APPCACHE_WORKING_SET_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_WORKING_SET_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_WORKING_SET_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_WORKING_SET_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 | 11 |
10 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 | 17 |
16 class AppCache; | 18 class AppCache; |
17 class AppCacheGroup; | 19 class AppCacheGroup; |
18 class AppCacheResponseInfo; | 20 class AppCacheResponseInfo; |
19 | 21 |
20 // Represents the working set of appcache object instances | 22 // Represents the working set of appcache object instances |
21 // currently in memory. | 23 // currently in memory. |
22 class CONTENT_EXPORT AppCacheWorkingSet { | 24 class CONTENT_EXPORT AppCacheWorkingSet { |
23 public: | 25 public: |
24 typedef std::map<GURL, AppCacheGroup*> GroupMap; | 26 typedef std::map<GURL, AppCacheGroup*> GroupMap; |
25 | 27 |
26 AppCacheWorkingSet(); | 28 AppCacheWorkingSet(); |
27 ~AppCacheWorkingSet(); | 29 ~AppCacheWorkingSet(); |
28 | 30 |
29 void Disable(); | 31 void Disable(); |
30 bool is_disabled() const { return is_disabled_; } | 32 bool is_disabled() const { return is_disabled_; } |
31 | 33 |
32 void AddCache(AppCache* cache); | 34 void AddCache(AppCache* cache); |
33 void RemoveCache(AppCache* cache); | 35 void RemoveCache(AppCache* cache); |
34 AppCache* GetCache(int64 id) { | 36 AppCache* GetCache(int64_t id) { |
35 CacheMap::iterator it = caches_.find(id); | 37 CacheMap::iterator it = caches_.find(id); |
36 return (it != caches_.end()) ? it->second : NULL; | 38 return (it != caches_.end()) ? it->second : NULL; |
37 } | 39 } |
38 | 40 |
39 void AddGroup(AppCacheGroup* group); | 41 void AddGroup(AppCacheGroup* group); |
40 void RemoveGroup(AppCacheGroup* group); | 42 void RemoveGroup(AppCacheGroup* group); |
41 AppCacheGroup* GetGroup(const GURL& manifest_url) { | 43 AppCacheGroup* GetGroup(const GURL& manifest_url) { |
42 GroupMap::iterator it = groups_.find(manifest_url); | 44 GroupMap::iterator it = groups_.find(manifest_url); |
43 return (it != groups_.end()) ? it->second : NULL; | 45 return (it != groups_.end()) ? it->second : NULL; |
44 } | 46 } |
45 | 47 |
46 const GroupMap* GetGroupsInOrigin(const GURL& origin_url) { | 48 const GroupMap* GetGroupsInOrigin(const GURL& origin_url) { |
47 return GetMutableGroupsInOrigin(origin_url); | 49 return GetMutableGroupsInOrigin(origin_url); |
48 } | 50 } |
49 | 51 |
50 void AddResponseInfo(AppCacheResponseInfo* response_info); | 52 void AddResponseInfo(AppCacheResponseInfo* response_info); |
51 void RemoveResponseInfo(AppCacheResponseInfo* response_info); | 53 void RemoveResponseInfo(AppCacheResponseInfo* response_info); |
52 AppCacheResponseInfo* GetResponseInfo(int64 id) { | 54 AppCacheResponseInfo* GetResponseInfo(int64_t id) { |
53 ResponseInfoMap::iterator it = response_infos_.find(id); | 55 ResponseInfoMap::iterator it = response_infos_.find(id); |
54 return (it != response_infos_.end()) ? it->second : NULL; | 56 return (it != response_infos_.end()) ? it->second : NULL; |
55 } | 57 } |
56 | 58 |
57 private: | 59 private: |
58 typedef base::hash_map<int64, AppCache*> CacheMap; | 60 typedef base::hash_map<int64_t, AppCache*> CacheMap; |
59 typedef std::map<GURL, GroupMap> GroupsByOriginMap; | 61 typedef std::map<GURL, GroupMap> GroupsByOriginMap; |
60 typedef base::hash_map<int64, AppCacheResponseInfo*> ResponseInfoMap; | 62 typedef base::hash_map<int64_t, AppCacheResponseInfo*> ResponseInfoMap; |
61 | 63 |
62 GroupMap* GetMutableGroupsInOrigin(const GURL& origin_url) { | 64 GroupMap* GetMutableGroupsInOrigin(const GURL& origin_url) { |
63 GroupsByOriginMap::iterator it = groups_by_origin_.find(origin_url); | 65 GroupsByOriginMap::iterator it = groups_by_origin_.find(origin_url); |
64 return (it != groups_by_origin_.end()) ? &it->second : NULL; | 66 return (it != groups_by_origin_.end()) ? &it->second : NULL; |
65 } | 67 } |
66 | 68 |
67 CacheMap caches_; | 69 CacheMap caches_; |
68 GroupMap groups_; | 70 GroupMap groups_; |
69 GroupsByOriginMap groups_by_origin_; // origin -> (manifest -> group) | 71 GroupsByOriginMap groups_by_origin_; // origin -> (manifest -> group) |
70 ResponseInfoMap response_infos_; | 72 ResponseInfoMap response_infos_; |
71 bool is_disabled_; | 73 bool is_disabled_; |
72 }; | 74 }; |
73 | 75 |
74 } // namespace content | 76 } // namespace content |
75 | 77 |
76 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_WORKING_SET_H_ | 78 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_WORKING_SET_H_ |
OLD | NEW |