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

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

Issue 1745603002: Switch LevelDBWrapper::GetAll to use the new Mojo sync IPC mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/dom_storage/local_storage_cached_area.h"
6
7 #include "content/common/storage_partition_service.mojom.h"
8 #include "content/renderer/dom_storage/local_storage_cached_areas.h"
9
10 namespace content {
11
12 LocalStorageCachedArea::LocalStorageCachedArea(
13 const url::Origin& origin,
14 StoragePartitionService* storage_partition_service,
15 LocalStorageCachedAreas* cached_areas)
16 : loaded_(false), origin_(origin), binding_(this),
17 cached_areas_(cached_areas) {
18 storage_partition_service->OpenLocalStorage(
19 origin_.Serialize(), mojo::GetProxy(&leveldb_));
20 }
21
22 LocalStorageCachedArea::~LocalStorageCachedArea() {
23 cached_areas_->LocalStorageCacheAreaClosed(this);
24 }
25
26 unsigned LocalStorageCachedArea::GetLength() {
27 EnsureLoaded();
28 return 0u;
29 }
30
31 base::NullableString16 LocalStorageCachedArea::GetKey(unsigned index) {
32 EnsureLoaded();
33 return base::NullableString16();
34 }
35
36 base::NullableString16 LocalStorageCachedArea::GetItem(
37 const base::string16& key) {
38 EnsureLoaded();
39 return base::NullableString16();
40 }
41
42 bool LocalStorageCachedArea::SetItem(const base::string16& key,
43 const base::string16& value,
44 const GURL& page_url) {
45 EnsureLoaded();
46 return false;
47 }
48
49 void LocalStorageCachedArea::RemoveItem(const base::string16& key,
50 const GURL& page_url) {
51 EnsureLoaded();
52 }
53
54 void LocalStorageCachedArea::Clear(const GURL& page_url) {
55 // No need to prime the cache in this case.
56
57 binding_.Close();
michaeln 2016/03/01 01:38:48 Nice, this is a much nicer api for ignoring mutati
jam 2016/03/01 06:50:53 fyi if the caller forgets to do this, they will ge
58 // TODO:
59 // binding_.CreateInterfacePtrAndBind()
60 }
61
62 void LocalStorageCachedArea::KeyChanged(mojo::Array<uint8_t> key,
63 mojo::Array<uint8_t> new_value,
64 mojo::Array<uint8_t> old_value,
65 const mojo::String& source) {
66 }
67
68 void LocalStorageCachedArea::KeyDeleted(mojo::Array<uint8_t> key,
69 const mojo::String& source) {
70 }
71
72 void LocalStorageCachedArea::AllDeleted(const mojo::String& source) {
73 }
74
75 void LocalStorageCachedArea::EnsureLoaded() {
76 if (loaded_)
77 return;
78
79 loaded_ = true;
80 leveldb::DatabaseError status = leveldb::DatabaseError::OK;
81 mojo::Array<content::KeyValuePtr> data;
82 leveldb_->GetAll(binding_.CreateInterfacePtrAndBind(), &status, &data);
83 }
84
85 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698