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

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

Issue 1814003002: Implement the renderer side of the mojo based local storage implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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_area.h" 5 #include "content/renderer/dom_storage/local_storage_area.h"
6 6
7 #include "base/rand_util.h"
8 #include "base/strings/string_number_conversions.h"
7 #include "third_party/WebKit/public/platform/WebURL.h" 9 #include "third_party/WebKit/public/platform/WebURL.h"
8 10
9 using blink::WebString; 11 using blink::WebString;
10 using blink::WebURL; 12 using blink::WebURL;
11 13
12 namespace content { 14 namespace content {
13 15
14 LocalStorageArea::LocalStorageArea( 16 LocalStorageArea::LocalStorageArea(LocalStorageCachedArea* cached_area)
15 scoped_refptr<LocalStorageCachedArea> cached_area) 17 : cached_area_(cached_area),
16 : cached_area_(std::move(cached_area)) { 18 id_(base::Uint64ToString(base::RandUint64())) {
19 cached_area_->LocalStorageAreaCreated(this);
17 } 20 }
18 21
19 LocalStorageArea::~LocalStorageArea() { 22 LocalStorageArea::~LocalStorageArea() {
23 cached_area_->LocalStorageAreaDestroyed(this);
20 } 24 }
21 25
22 unsigned LocalStorageArea::length() { 26 unsigned LocalStorageArea::length() {
23 return cached_area_->GetLength(); 27 return cached_area_->GetLength();
24 } 28 }
25 29
26 WebString LocalStorageArea::key(unsigned index) { 30 WebString LocalStorageArea::key(unsigned index) {
27 return cached_area_->GetKey(index); 31 return cached_area_->GetKey(index);
28 } 32 }
29 33
30 WebString LocalStorageArea::getItem(const WebString& key) { 34 WebString LocalStorageArea::getItem(const WebString& key) {
31 return cached_area_->GetItem(key); 35 return cached_area_->GetItem(key);
32 } 36 }
33 37
34 void LocalStorageArea::setItem( 38 void LocalStorageArea::setItem(
35 const WebString& key, const WebString& value, const WebURL& page_url, 39 const WebString& key, const WebString& value, const WebURL& page_url,
36 WebStorageArea::Result& result) { 40 WebStorageArea::Result& result) {
37 if (!cached_area_->SetItem(key, value, page_url)) 41 if (!cached_area_->SetItem(key, value, page_url, id_))
38 result = ResultBlockedByQuota; 42 result = ResultBlockedByQuota;
39 else 43 else
40 result = ResultOK; 44 result = ResultOK;
41 } 45 }
42 46
43 void LocalStorageArea::removeItem( 47 void LocalStorageArea::removeItem(
44 const WebString& key, const WebURL& page_url) { 48 const WebString& key, const WebURL& page_url) {
45 cached_area_->RemoveItem(key, page_url); 49 cached_area_->RemoveItem(key, page_url, id_);
46 } 50 }
47 51
48 void LocalStorageArea::clear(const WebURL& page_url) { 52 void LocalStorageArea::clear(const WebURL& page_url) {
53 cached_area_->Clear(page_url, id_);
49 } 54 }
50 55
51 } // namespace content 56 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698