Chromium Code Reviews| 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); | |
| 141 | |
|
jennb
2011/12/07 21:55:08
Extra blank line?
michaeln
2011/12/08 01:39:00
Done (locally, not uploaded yet)
| |
| 132 | 142 |
| 133 // Use AppCacheHost::Associate*Cache() to manipulate host association. | 143 // Use AppCacheHost::Associate*Cache() to manipulate host association. |
| 134 void AssociateHost(AppCacheHost* host) { | 144 void AssociateHost(AppCacheHost* host) { |
| 135 associated_hosts_.insert(host); | 145 associated_hosts_.insert(host); |
| 136 } | 146 } |
| 137 void UnassociateHost(AppCacheHost* host); | 147 void UnassociateHost(AppCacheHost* host); |
| 138 | 148 |
| 139 const int64 cache_id_; | 149 const int64 cache_id_; |
| 140 scoped_refptr<AppCacheGroup> owning_group_; | 150 scoped_refptr<AppCacheGroup> owning_group_; |
| 141 AppCacheHosts associated_hosts_; | 151 AppCacheHosts associated_hosts_; |
| 142 | 152 |
| 143 EntryMap entries_; // contains entries of all types | 153 EntryMap entries_; // contains entries of all types |
| 144 | 154 |
| 145 std::vector<FallbackNamespace> fallback_namespaces_; | 155 NamespaceVector intercept_namespaces_; |
| 156 NamespaceVector fallback_namespaces_; | |
| 146 std::vector<GURL> online_whitelist_namespaces_; | 157 std::vector<GURL> online_whitelist_namespaces_; |
| 147 bool online_whitelist_all_; | 158 bool online_whitelist_all_; |
| 148 | 159 |
| 149 bool is_complete_; | 160 bool is_complete_; |
| 150 | 161 |
| 151 // when this cache was last updated | 162 // when this cache was last updated |
| 152 base::Time update_time_; | 163 base::Time update_time_; |
| 153 | 164 |
| 154 int64 cache_size_; | 165 int64 cache_size_; |
| 155 | 166 |
| 156 // to notify service when cache is deleted | 167 // to notify service when cache is deleted |
| 157 AppCacheService* service_; | 168 AppCacheService* service_; |
| 158 | 169 |
| 159 FRIEND_TEST_ALL_PREFIXES(AppCacheTest, InitializeWithManifest); | 170 FRIEND_TEST_ALL_PREFIXES(AppCacheTest, InitializeWithManifest); |
| 160 | 171 |
| 161 DISALLOW_COPY_AND_ASSIGN(AppCache); | 172 DISALLOW_COPY_AND_ASSIGN(AppCache); |
| 162 }; | 173 }; |
| 163 | 174 |
| 164 } // namespace appcache | 175 } // namespace appcache |
| 165 | 176 |
| 166 #endif // WEBKIT_APPCACHE_APPCACHE_H_ | 177 #endif // WEBKIT_APPCACHE_APPCACHE_H_ |
| OLD | NEW |