OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/dom_storage/dom_storage_cached_area.h" | 5 #include "content/renderer/dom_storage/dom_storage_cached_area.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include <limits> |
| 8 |
8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "content/common/dom_storage/dom_storage_map.h" | 11 #include "content/common/dom_storage/dom_storage_map.h" |
11 #include "content/renderer/dom_storage/dom_storage_proxy.h" | 12 #include "content/renderer/dom_storage/dom_storage_proxy.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 DOMStorageCachedArea::DOMStorageCachedArea(int64 namespace_id, | 16 DOMStorageCachedArea::DOMStorageCachedArea(int64_t namespace_id, |
16 const GURL& origin, | 17 const GURL& origin, |
17 DOMStorageProxy* proxy) | 18 DOMStorageProxy* proxy) |
18 : ignore_all_mutations_(false), | 19 : ignore_all_mutations_(false), |
19 namespace_id_(namespace_id), | 20 namespace_id_(namespace_id), |
20 origin_(origin), | 21 origin_(origin), |
21 proxy_(proxy), | 22 proxy_(proxy), |
22 weak_factory_(this) {} | 23 weak_factory_(this) {} |
23 | 24 |
24 DOMStorageCachedArea::~DOMStorageCachedArea() {} | 25 DOMStorageCachedArea::~DOMStorageCachedArea() {} |
25 | 26 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // It's a remove item event. | 128 // It's a remove item event. |
128 base::string16 unused; | 129 base::string16 unused; |
129 map_->RemoveItem(key.string(), &unused); | 130 map_->RemoveItem(key.string(), &unused); |
130 return; | 131 return; |
131 } | 132 } |
132 | 133 |
133 // It's a set item event. | 134 // It's a set item event. |
134 // We turn off quota checking here to accomodate the over budget | 135 // We turn off quota checking here to accomodate the over budget |
135 // allowance that's provided in the browser process. | 136 // allowance that's provided in the browser process. |
136 base::NullableString16 unused; | 137 base::NullableString16 unused; |
137 map_->set_quota(kint32max); | 138 map_->set_quota(std::numeric_limits<int32_t>::max()); |
138 map_->SetItem(key.string(), new_value.string(), &unused); | 139 map_->SetItem(key.string(), new_value.string(), &unused); |
139 map_->set_quota(kPerStorageAreaQuota); | 140 map_->set_quota(kPerStorageAreaQuota); |
140 } | 141 } |
141 | 142 |
142 size_t DOMStorageCachedArea::MemoryBytesUsedByCache() const { | 143 size_t DOMStorageCachedArea::MemoryBytesUsedByCache() const { |
143 return map_.get() ? map_->bytes_used() : 0; | 144 return map_.get() ? map_->bytes_used() : 0; |
144 } | 145 } |
145 | 146 |
146 void DOMStorageCachedArea::Prime(int connection_id) { | 147 void DOMStorageCachedArea::Prime(int connection_id) { |
147 DCHECK(!map_.get()); | 148 DCHECK(!map_.get()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ignore_key_mutations_.erase(found); | 227 ignore_key_mutations_.erase(found); |
227 } | 228 } |
228 | 229 |
229 void DOMStorageCachedArea::OnClearComplete(bool success) { | 230 void DOMStorageCachedArea::OnClearComplete(bool success) { |
230 DCHECK(success); | 231 DCHECK(success); |
231 DCHECK(ignore_all_mutations_); | 232 DCHECK(ignore_all_mutations_); |
232 ignore_all_mutations_ = false; | 233 ignore_all_mutations_ = false; |
233 } | 234 } |
234 | 235 |
235 } // namespace content | 236 } // namespace content |
OLD | NEW |