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/local_storage_context_mojo.cc

Issue 2597983003: Add tests for how LocalStorageContextMojo interacts with file/leveldb services. (Closed)
Patch Set: reapply change that got lost during rebase Created 3 years, 11 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
« no previous file with comments | « no previous file | content/browser/dom_storage/local_storage_context_mojo_unittest.cc » ('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 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/browser/dom_storage/local_storage_context_mojo.h" 5 #include "content/browser/dom_storage/local_storage_context_mojo.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "components/leveldb/public/cpp/util.h" 9 #include "components/leveldb/public/cpp/util.h"
10 #include "content/browser/leveldb_wrapper_impl.h" 10 #include "content/browser/leveldb_wrapper_impl.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // We failed to open the directory; continue with startup so that we create 134 // We failed to open the directory; continue with startup so that we create
135 // the |level_db_wrappers_|. 135 // the |level_db_wrappers_|.
136 OnDatabaseOpened(leveldb::mojom::DatabaseError::IO_ERROR); 136 OnDatabaseOpened(leveldb::mojom::DatabaseError::IO_ERROR);
137 return; 137 return;
138 } 138 }
139 139
140 // Now that we have a directory, connect to the LevelDB service and get our 140 // Now that we have a directory, connect to the LevelDB service and get our
141 // database. 141 // database.
142 file_service_connection_->GetInterface(&leveldb_service_); 142 file_service_connection_->GetInterface(&leveldb_service_);
143 143
144 leveldb_service_->Open(std::move(directory_), "leveldb", 144 auto options = leveldb::mojom::OpenOptions::New();
145 MakeRequest(&database_), 145 options->create_if_missing = true;
146 base::Bind(&LocalStorageContextMojo::OnDatabaseOpened, 146 leveldb_service_->OpenWithOptions(
147 weak_ptr_factory_.GetWeakPtr())); 147 std::move(options), std::move(directory_), "leveldb",
148 MakeRequest(&database_),
149 base::Bind(&LocalStorageContextMojo::OnDatabaseOpened,
150 weak_ptr_factory_.GetWeakPtr()));
148 } 151 }
149 152
150 void LocalStorageContextMojo::OnDatabaseOpened( 153 void LocalStorageContextMojo::OnDatabaseOpened(
151 leveldb::mojom::DatabaseError status) { 154 leveldb::mojom::DatabaseError status) {
152 if (status != leveldb::mojom::DatabaseError::OK) { 155 if (status != leveldb::mojom::DatabaseError::OK) {
153 // If we failed to open the database, reset the service object so we pass 156 // If we failed to open the database, reset the service object so we pass
154 // null pointers to our wrappers. 157 // null pointers to our wrappers.
155 database_.reset(); 158 database_.reset();
156 leveldb_service_.reset(); 159 leveldb_service_.reset();
157 } 160 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 base::Unretained(this), origin), 233 base::Unretained(this), origin),
231 base::Bind(&LocalStorageContextMojo::OnLevelDBWrapperPrepareToCommit, 234 base::Bind(&LocalStorageContextMojo::OnLevelDBWrapperPrepareToCommit,
232 base::Unretained(this))); 235 base::Unretained(this)));
233 found = level_db_wrappers_.find(origin); 236 found = level_db_wrappers_.find(origin);
234 } 237 }
235 238
236 found->second->Bind(std::move(request)); 239 found->second->Bind(std::move(request));
237 } 240 }
238 241
239 } // namespace content 242 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/dom_storage/local_storage_context_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698