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

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

Issue 201070: Implementation of application cache update algorithm.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « webkit/appcache/appcache.h ('k') | webkit/appcache/appcache_group.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webkit/appcache/appcache.h" 5 #include "webkit/appcache/appcache.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "webkit/appcache/appcache_group.h" 8 #include "webkit/appcache/appcache_group.h"
9 #include "webkit/appcache/appcache_host.h" 9 #include "webkit/appcache/appcache_host.h"
10 #include "webkit/appcache/appcache_interfaces.h"
10 #include "webkit/appcache/appcache_service.h" 11 #include "webkit/appcache/appcache_service.h"
11 12
12 namespace appcache { 13 namespace appcache {
13 14
14 AppCache::AppCache(AppCacheService *service, int64 cache_id) 15 AppCache::AppCache(AppCacheService *service, int64 cache_id)
15 : cache_id_(cache_id), 16 : cache_id_(cache_id),
16 manifest_(NULL), 17 owning_group_(NULL),
17 owning_group_(NULL), 18 online_whitelist_all_(false),
18 online_whitelist_all_(false), 19 is_complete_(false),
19 is_complete_(false), 20 service_(service) {
20 service_(service) {
21 service_->AddCache(this); 21 service_->AddCache(this);
22 } 22 }
23 23
24 AppCache::~AppCache() { 24 AppCache::~AppCache() {
25 DCHECK(associated_hosts_.empty()); 25 DCHECK(associated_hosts_.empty());
26 DCHECK(!owning_group_); 26 DCHECK(!owning_group_);
27 service_->RemoveCache(this); 27 service_->RemoveCache(this);
28 } 28 }
29 29
30 void AppCache::UnassociateHost(AppCacheHost* host) { 30 void AppCache::UnassociateHost(AppCacheHost* host) {
31 associated_hosts_.erase(host); 31 associated_hosts_.erase(host);
32 32
33 // Inform group if this cache is no longer in use. 33 // Inform group if this cache is no longer in use.
34 if (associated_hosts_.empty() && owning_group_) 34 if (associated_hosts_.empty() && owning_group_)
35 owning_group_->RemoveCache(this); 35 owning_group_->RemoveCache(this);
36 } 36 }
37 37
38 void AppCache::AddEntry(const GURL& url, const AppCacheEntry& entry) { 38 void AppCache::AddEntry(const GURL& url, const AppCacheEntry& entry) {
39 DCHECK(entries_.find(url) == entries_.end()); 39 DCHECK(entries_.find(url) == entries_.end());
40 entries_.insert(EntryMap::value_type(url, entry)); 40 entries_.insert(EntryMap::value_type(url, entry));
41 } 41 }
42 42
43 void AppCache::AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry) { 43 void AppCache::AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry) {
44 std::pair<EntryMap::iterator, bool> ret = 44 std::pair<EntryMap::iterator, bool> ret =
45 entries_.insert(EntryMap::value_type(url, entry)); 45 entries_.insert(EntryMap::value_type(url, entry));
46 46
47 // Entry already exists. Merge the types of the new and existing entries. 47 // Entry already exists. Merge the types of the new and existing entries.
48 if (!ret.second) 48 if (!ret.second)
49 ret.first->second.add_types(entry.types()); 49 ret.first->second.add_types(entry.types());
50 } 50 }
51 51
52 AppCacheEntry* AppCache::GetEntry(const GURL& url) { 52 AppCacheEntry* AppCache::GetEntry(const GURL& url) {
53 EntryMap::iterator it = entries_.find(url); 53 EntryMap::iterator it = entries_.find(url);
54 return (it != entries_.end()) ? &(it->second) : NULL; 54 return (it != entries_.end()) ? &(it->second) : NULL;
55 } 55 }
56 56
57 void AppCache::InitializeWithManifest(Manifest* manifest) {
58 DCHECK(manifest);
59 fallback_namespaces_.swap(manifest->fallback_namespaces);
60 online_whitelist_namespaces_.swap(manifest->online_whitelist_namespaces);
61 online_whitelist_all_ = manifest->online_whitelist_all;
62 }
63
57 } // namespace appcache 64 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache.h ('k') | webkit/appcache/appcache_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698