Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / appcache / appcache_working_set.cc
blob4394097aee09cd7d4f38928ec09ab98da674e3ec
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
3 // found in the LICENSE file.
5 #include "content/browser/appcache/appcache_working_set.h"
7 #include "base/logging.h"
8 #include "content/browser/appcache/appcache.h"
9 #include "content/browser/appcache/appcache_group.h"
10 #include "content/browser/appcache/appcache_response.h"
12 namespace content {
14 AppCacheWorkingSet::AppCacheWorkingSet() : is_disabled_(false) {}
16 AppCacheWorkingSet::~AppCacheWorkingSet() {
17 DCHECK(caches_.empty());
18 DCHECK(groups_.empty());
19 DCHECK(groups_by_origin_.empty());
22 void AppCacheWorkingSet::Disable() {
23 if (is_disabled_)
24 return;
25 is_disabled_ = true;
26 caches_.clear();
27 groups_.clear();
28 groups_by_origin_.clear();
29 response_infos_.clear();
32 void AppCacheWorkingSet::AddCache(AppCache* cache) {
33 if (is_disabled_)
34 return;
35 DCHECK(cache->cache_id() != kAppCacheNoCacheId);
36 int64 cache_id = cache->cache_id();
37 DCHECK(caches_.find(cache_id) == caches_.end());
38 caches_.insert(CacheMap::value_type(cache_id, cache));
41 void AppCacheWorkingSet::RemoveCache(AppCache* cache) {
42 caches_.erase(cache->cache_id());
45 void AppCacheWorkingSet::AddGroup(AppCacheGroup* group) {
46 if (is_disabled_)
47 return;
48 const GURL& url = group->manifest_url();
49 DCHECK(groups_.find(url) == groups_.end());
50 groups_.insert(GroupMap::value_type(url, group));
51 groups_by_origin_[url.GetOrigin()].insert(GroupMap::value_type(url, group));
54 void AppCacheWorkingSet::RemoveGroup(AppCacheGroup* group) {
55 const GURL& url = group->manifest_url();
56 groups_.erase(url);
58 GURL origin_url = url.GetOrigin();
59 GroupMap* groups_in_origin = GetMutableGroupsInOrigin(origin_url);
60 if (groups_in_origin) {
61 groups_in_origin->erase(url);
62 if (groups_in_origin->empty())
63 groups_by_origin_.erase(origin_url);
67 void AppCacheWorkingSet::AddResponseInfo(AppCacheResponseInfo* info) {
68 if (is_disabled_)
69 return;
70 DCHECK(info->response_id() != kAppCacheNoResponseId);
71 int64 response_id = info->response_id();
72 DCHECK(response_infos_.find(response_id) == response_infos_.end());
73 response_infos_.insert(ResponseInfoMap::value_type(response_id, info));
76 void AppCacheWorkingSet::RemoveResponseInfo(AppCacheResponseInfo* info) {
77 response_infos_.erase(info->response_id());
80 } // namespace