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

Side by Side Diff: content/renderer/dom_storage/local_storage_cached_area.cc

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/local_storage_cached_area.h" 5 #include "content/renderer/dom_storage/local_storage_cached_area.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // remove it from our cache if we haven't already changed it and are waiting 173 // remove it from our cache if we haven't already changed it and are waiting
174 // for the confirmation callback. In the latter case, we won't do anything 174 // for the confirmation callback. In the latter case, we won't do anything
175 // because ignore_key_mutations_ won't be updated until the callback runs. 175 // because ignore_key_mutations_ won't be updated until the callback runs.
176 if (ignore_key_mutations_.find(key_string) != ignore_key_mutations_.end()) { 176 if (ignore_key_mutations_.find(key_string) != ignore_key_mutations_.end()) {
177 base::string16 unused; 177 base::string16 unused;
178 map_->RemoveItem(key_string, &unused); 178 map_->RemoveItem(key_string, &unused);
179 } 179 }
180 } 180 }
181 181
182 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent( 182 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent(
183 key_string, Uint8VectorToString16(old_value), base::NullableString16(), 183 blink::WebString::fromUTF16(key_string),
184 origin_.GetURL(), page_url, originating_area); 184 blink::WebString::fromUTF16(Uint8VectorToString16(old_value)),
185 blink::WebString(), origin_.GetURL(), page_url, originating_area);
185 } 186 }
186 187
187 void LocalStorageCachedArea::AllDeleted(const std::string& source) { 188 void LocalStorageCachedArea::AllDeleted(const std::string& source) {
188 GURL page_url; 189 GURL page_url;
189 std::string storage_area_id; 190 std::string storage_area_id;
190 UnpackSource(source, &page_url, &storage_area_id); 191 UnpackSource(source, &page_url, &storage_area_id);
191 192
192 blink::WebStorageArea* originating_area = nullptr; 193 blink::WebStorageArea* originating_area = nullptr;
193 if (areas_.find(storage_area_id) != areas_.end()) { 194 if (areas_.find(storage_area_id) != areas_.end()) {
194 // The source storage area is in this process. 195 // The source storage area is in this process.
195 originating_area = areas_[storage_area_id]; 196 originating_area = areas_[storage_area_id];
196 } else if (map_ && !ignore_all_mutations_) { 197 } else if (map_ && !ignore_all_mutations_) {
197 scoped_refptr<DOMStorageMap> old = map_; 198 scoped_refptr<DOMStorageMap> old = map_;
198 map_ = new DOMStorageMap(kPerStorageAreaQuota); 199 map_ = new DOMStorageMap(kPerStorageAreaQuota);
199 200
200 // We have to retain local additions which happened after this clear 201 // We have to retain local additions which happened after this clear
201 // operation from another process. 202 // operation from another process.
202 auto iter = ignore_key_mutations_.begin(); 203 auto iter = ignore_key_mutations_.begin();
203 while (iter != ignore_key_mutations_.end()) { 204 while (iter != ignore_key_mutations_.end()) {
204 base::NullableString16 value = old->GetItem(iter->first); 205 base::NullableString16 value = old->GetItem(iter->first);
205 if (!value.is_null()) { 206 if (!value.is_null()) {
206 base::NullableString16 unused; 207 base::NullableString16 unused;
207 map_->SetItem(iter->first, value.string(), &unused); 208 map_->SetItem(iter->first, value.string(), &unused);
208 } 209 }
209 ++iter; 210 ++iter;
210 } 211 }
211 } 212 }
212 213
213 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent( 214 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent(
214 base::NullableString16(), base::NullableString16(), 215 blink::WebString(), blink::WebString(), blink::WebString(),
215 base::NullableString16(), origin_.GetURL(), page_url, originating_area); 216 origin_.GetURL(), page_url, originating_area);
216 } 217 }
217 218
218 void LocalStorageCachedArea::GetAllComplete(const std::string& source) { 219 void LocalStorageCachedArea::GetAllComplete(const std::string& source) {
219 // Since the GetAll method is synchronous, we need this asynchronously 220 // Since the GetAll method is synchronous, we need this asynchronously
220 // delivered notification to avoid applying changes to the returned array 221 // delivered notification to avoid applying changes to the returned array
221 // that we already have. 222 // that we already have.
222 if (source == get_all_request_id_) { 223 if (source == get_all_request_id_) {
223 DCHECK(ignore_all_mutations_); 224 DCHECK(ignore_all_mutations_);
224 DCHECK(!get_all_request_id_.empty()); 225 DCHECK(!get_all_request_id_.empty());
225 ignore_all_mutations_ = false; 226 ignore_all_mutations_ = false;
(...skipping 26 matching lines...) Expand all
252 // We turn off quota checking here to accomodate the over budget allowance 253 // We turn off quota checking here to accomodate the over budget allowance
253 // that's provided in the browser process. 254 // that's provided in the browser process.
254 base::NullableString16 unused; 255 base::NullableString16 unused;
255 map_->set_quota(std::numeric_limits<int32_t>::max()); 256 map_->set_quota(std::numeric_limits<int32_t>::max());
256 map_->SetItem(key_string, new_value_string, &unused); 257 map_->SetItem(key_string, new_value_string, &unused);
257 map_->set_quota(kPerStorageAreaQuota); 258 map_->set_quota(kPerStorageAreaQuota);
258 } 259 }
259 } 260 }
260 261
261 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent( 262 blink::WebStorageEventDispatcher::dispatchLocalStorageEvent(
262 key_string, old_value, new_value_string, origin_.GetURL(), page_url, 263 blink::WebString::fromUTF16(key_string),
264 blink::WebString::fromUTF16(old_value),
265 blink::WebString::fromUTF16(new_value_string), origin_.GetURL(), page_url,
263 originating_area); 266 originating_area);
264 } 267 }
265 268
266 void LocalStorageCachedArea::EnsureLoaded() { 269 void LocalStorageCachedArea::EnsureLoaded() {
267 if (map_) 270 if (map_)
268 return; 271 return;
269 272
270 base::TimeTicks before = base::TimeTicks::Now(); 273 base::TimeTicks before = base::TimeTicks::Now();
271 ignore_all_mutations_ = true; 274 ignore_all_mutations_ = true;
272 get_all_request_id_ = base::Uint64ToString(base::RandUint64()); 275 get_all_request_id_ = base::Uint64ToString(base::RandUint64());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 337 }
335 338
336 void LocalStorageCachedArea::Reset() { 339 void LocalStorageCachedArea::Reset() {
337 map_ = NULL; 340 map_ = NULL;
338 ignore_key_mutations_.clear(); 341 ignore_key_mutations_.clear();
339 ignore_all_mutations_ = false; 342 ignore_all_mutations_ = false;
340 weak_factory_.InvalidateWeakPtrs(); 343 weak_factory_.InvalidateWeakPtrs();
341 } 344 }
342 345
343 } // namespace content 346 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/dom_storage/local_storage_area.cc ('k') | content/renderer/dom_storage/webstoragearea_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698