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

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

Issue 2583253002: Start adding tests for LevelDBWrapper, and fix a bunch of bugs. (Closed)
Patch Set: fix StringPiece conversion 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
« no previous file with comments | « no previous file | content/browser/leveldb_wrapper_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Part of our asynchronous directory opening called from OpenLocalStorage(). 118 // Part of our asynchronous directory opening called from OpenLocalStorage().
119 void OnDirectoryOpened(filesystem::mojom::FileError err); 119 void OnDirectoryOpened(filesystem::mojom::FileError err);
120 void OnDatabaseOpened(leveldb::mojom::DatabaseError status); 120 void OnDatabaseOpened(leveldb::mojom::DatabaseError status);
121 121
122 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called 122 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called
123 // directly from that function, or through |on_database_open_callbacks_|. 123 // directly from that function, or through |on_database_open_callbacks_|.
124 void BindLocalStorage(const url::Origin& origin, 124 void BindLocalStorage(const url::Origin& origin,
125 mojom::LevelDBObserverPtr observer, 125 mojom::LevelDBObserverPtr observer,
126 mojom::LevelDBWrapperRequest request); 126 mojom::LevelDBWrapperRequest request);
127 127
128 // Maps between an origin and its prefixed LevelDB view.
129 std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_;
130
131 service_manager::Connector* const connector_; 128 service_manager::Connector* const connector_;
132 const base::FilePath subdirectory_; 129 const base::FilePath subdirectory_;
133 130
134 enum ConnectionState { 131 enum ConnectionState {
135 NO_CONNECTION, 132 NO_CONNECTION,
136 CONNECTION_IN_PROGRESS, 133 CONNECTION_IN_PROGRESS,
137 CONNECTION_FINISHED 134 CONNECTION_FINISHED
138 } connection_state_; 135 } connection_state_;
139 136
140 std::unique_ptr<service_manager::Connection> file_service_connection_; 137 std::unique_ptr<service_manager::Connection> file_service_connection_;
141 138
142 file::mojom::FileSystemPtr file_system_; 139 file::mojom::FileSystemPtr file_system_;
143 filesystem::mojom::DirectoryPtr directory_; 140 filesystem::mojom::DirectoryPtr directory_;
144 141
145 leveldb::mojom::LevelDBServicePtr leveldb_service_; 142 leveldb::mojom::LevelDBServicePtr leveldb_service_;
146 leveldb::mojom::LevelDBDatabasePtr database_; 143 leveldb::mojom::LevelDBDatabasePtr database_;
147 144
148 std::vector<base::Closure> on_database_opened_callbacks_; 145 std::vector<base::Closure> on_database_opened_callbacks_;
149 146
147 // Maps between an origin and its prefixed LevelDB view.
148 std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_;
149
150 base::WeakPtrFactory<MojoState> weak_ptr_factory_; 150 base::WeakPtrFactory<MojoState> weak_ptr_factory_;
151 }; 151 };
152 152
153 void DOMStorageContextWrapper::MojoState::OpenLocalStorage( 153 void DOMStorageContextWrapper::MojoState::OpenLocalStorage(
154 const url::Origin& origin, 154 const url::Origin& origin,
155 mojom::LevelDBObserverPtr observer, 155 mojom::LevelDBObserverPtr observer,
156 mojom::LevelDBWrapperRequest request) { 156 mojom::LevelDBWrapperRequest request) {
157 // If we don't have a filesystem_connection_, we'll need to establish one. 157 // If we don't have a filesystem_connection_, we'll need to establish one.
158 if (connection_state_ == NO_CONNECTION) { 158 if (connection_state_ == NO_CONNECTION) {
159 CHECK(connector_); 159 CHECK(connector_);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 463 }
464 464
465 void DOMStorageContextWrapper::PurgeMemory(DOMStorageContextImpl::PurgeOption 465 void DOMStorageContextWrapper::PurgeMemory(DOMStorageContextImpl::PurgeOption
466 purge_option) { 466 purge_option) {
467 context_->task_runner()->PostTask( 467 context_->task_runner()->PostTask(
468 FROM_HERE, 468 FROM_HERE,
469 base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option)); 469 base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option));
470 } 470 }
471 471
472 } // namespace content 472 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/leveldb_wrapper_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698