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

Side by Side Diff: content/browser/dom_storage/dom_storage_context_wrapper.cc

Issue 1837883003: Some fleshing out the mojo based localstorage implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: long lived observer Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/dom_storage/dom_storage_context_wrapper.h" 5 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 MojoState(const std::string& mojo_user_id, const base::FilePath& subdirectory) 80 MojoState(const std::string& mojo_user_id, const base::FilePath& subdirectory)
81 : mojo_user_id_(mojo_user_id), 81 : mojo_user_id_(mojo_user_id),
82 subdirectory_(subdirectory), 82 subdirectory_(subdirectory),
83 connection_state_(NO_CONNECTION), 83 connection_state_(NO_CONNECTION),
84 weak_ptr_factory_(this) {} 84 weak_ptr_factory_(this) {}
85 85
86 void OpenLocalStorage(const url::Origin& origin, 86 void OpenLocalStorage(const url::Origin& origin,
87 LevelDBWrapperRequest request); 87 LevelDBWrapperRequest request);
88 88
89 private: 89 private:
90 void LevelDBWrapperImplHasNoBindings(const url::Origin& origin) { 90 void OnLevelDDWrapperHasNoBindings(const url::Origin& origin) {
91 DCHECK(level_db_wrappers_.find(origin) != level_db_wrappers_.end()); 91 DCHECK(level_db_wrappers_.find(origin) != level_db_wrappers_.end());
92 level_db_wrappers_.erase(origin); 92 level_db_wrappers_.erase(origin);
93 } 93 }
94 94
95 // Part of our asynchronous directory opening called from OpenLocalStorage(). 95 // Part of our asynchronous directory opening called from OpenLocalStorage().
96 void OnDirectoryOpened(filesystem::FileError err); 96 void OnDirectoryOpened(filesystem::FileError err);
97 void OnDatabaseOpened(leveldb::DatabaseError status); 97 void OnDatabaseOpened(leveldb::DatabaseError status);
98 98
99 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called 99 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called
100 // directly from that function, or through |on_database_open_callbacks_|. 100 // directly from that function, or through |on_database_open_callbacks_|.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 on_database_opened_callbacks_.clear(); 202 on_database_opened_callbacks_.clear();
203 } 203 }
204 204
205 void DOMStorageContextWrapper::MojoState::BindLocalStorage( 205 void DOMStorageContextWrapper::MojoState::BindLocalStorage(
206 const url::Origin& origin, 206 const url::Origin& origin,
207 LevelDBWrapperRequest request) { 207 LevelDBWrapperRequest request) {
208 if (level_db_wrappers_.find(origin) == level_db_wrappers_.end()) { 208 if (level_db_wrappers_.find(origin) == level_db_wrappers_.end()) {
209 level_db_wrappers_[origin] = make_scoped_ptr(new LevelDBWrapperImpl( 209 level_db_wrappers_[origin] = make_scoped_ptr(new LevelDBWrapperImpl(
210 database_.get(), 210 database_.get(),
211 origin.Serialize(), 211 origin.Serialize(),
212 base::Bind(&MojoState::LevelDBWrapperImplHasNoBindings, 212 kPerStorageAreaQuota + kPerStorageAreaOverQuotaAllowance,
213 base::Bind(&MojoState::OnLevelDDWrapperHasNoBindings,
213 base::Unretained(this), 214 base::Unretained(this),
214 origin))); 215 origin)));
215 } 216 }
216 217
217 level_db_wrappers_[origin]->Bind(std::move(request)); 218 level_db_wrappers_[origin]->Bind(std::move(request));
218 } 219 }
219 220
220 DOMStorageContextWrapper::DOMStorageContextWrapper( 221 DOMStorageContextWrapper::DOMStorageContextWrapper(
221 const std::string& mojo_user_id, 222 const std::string& mojo_user_id,
222 const base::FilePath& profile_path, 223 const base::FilePath& profile_path,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, 328 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE,
328 base::Bind(&DOMStorageContextImpl::Flush, context_)); 329 base::Bind(&DOMStorageContextImpl::Flush, context_));
329 } 330 }
330 331
331 void DOMStorageContextWrapper::OpenLocalStorage(const url::Origin& origin, 332 void DOMStorageContextWrapper::OpenLocalStorage(const url::Origin& origin,
332 LevelDBWrapperRequest request) { 333 LevelDBWrapperRequest request) {
333 mojo_state_->OpenLocalStorage(origin, std::move(request)); 334 mojo_state_->OpenLocalStorage(origin, std::move(request));
334 } 335 }
335 336
336 } // namespace content 337 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/leveldb_wrapper_impl.h » ('j') | content/browser/leveldb_wrapper_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698