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

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

Issue 2589663003: mojo:: Rename mojo::GetProxy() to mojo::MakeRequest() (Closed)
Patch Set: Rebase 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
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 weak_ptr_factory_.GetWeakPtr())); 164 weak_ptr_factory_.GetWeakPtr()));
165 file_service_connection_->SetConnectionLostClosure( 165 file_service_connection_->SetConnectionLostClosure(
166 base::Bind(&MojoState::OnUserServiceConnectionError, 166 base::Bind(&MojoState::OnUserServiceConnectionError,
167 weak_ptr_factory_.GetWeakPtr())); 167 weak_ptr_factory_.GetWeakPtr()));
168 168
169 if (!subdirectory_.empty()) { 169 if (!subdirectory_.empty()) {
170 // We were given a subdirectory to write to. Get it and use a disk backed 170 // We were given a subdirectory to write to. Get it and use a disk backed
171 // database. 171 // database.
172 file_service_connection_->GetInterface(&file_system_); 172 file_service_connection_->GetInterface(&file_system_);
173 file_system_->GetSubDirectory(subdirectory_.AsUTF8Unsafe(), 173 file_system_->GetSubDirectory(subdirectory_.AsUTF8Unsafe(),
174 GetProxy(&directory_), 174 MakeRequest(&directory_),
175 base::Bind(&MojoState::OnDirectoryOpened, 175 base::Bind(&MojoState::OnDirectoryOpened,
176 weak_ptr_factory_.GetWeakPtr())); 176 weak_ptr_factory_.GetWeakPtr()));
177 } else { 177 } else {
178 // We were not given a subdirectory. Use a memory backed database. 178 // We were not given a subdirectory. Use a memory backed database.
179 file_service_connection_->GetInterface(&leveldb_service_); 179 file_service_connection_->GetInterface(&leveldb_service_);
180 leveldb_service_->OpenInMemory( 180 leveldb_service_->OpenInMemory(
181 GetProxy(&database_), 181 MakeRequest(&database_), base::Bind(&MojoState::OnDatabaseOpened,
182 base::Bind(&MojoState::OnDatabaseOpened, 182 weak_ptr_factory_.GetWeakPtr()));
183 weak_ptr_factory_.GetWeakPtr()));
184 } 183 }
185 } 184 }
186 185
187 if (connection_state_ == CONNECTION_IN_PROGRESS) { 186 if (connection_state_ == CONNECTION_IN_PROGRESS) {
188 // Queue this OpenLocalStorage call for when we have a level db pointer. 187 // Queue this OpenLocalStorage call for when we have a level db pointer.
189 on_database_opened_callbacks_.push_back( 188 on_database_opened_callbacks_.push_back(
190 base::Bind(&MojoState::BindLocalStorage, weak_ptr_factory_.GetWeakPtr(), 189 base::Bind(&MojoState::BindLocalStorage, weak_ptr_factory_.GetWeakPtr(),
191 origin, base::Passed(&observer), base::Passed(&request))); 190 origin, base::Passed(&observer), base::Passed(&request)));
192 return; 191 return;
193 } 192 }
194 193
195 BindLocalStorage(origin, std::move(observer), std::move(request)); 194 BindLocalStorage(origin, std::move(observer), std::move(request));
196 } 195 }
197 196
198 void DOMStorageContextWrapper::MojoState::OnDirectoryOpened( 197 void DOMStorageContextWrapper::MojoState::OnDirectoryOpened(
199 filesystem::mojom::FileError err) { 198 filesystem::mojom::FileError err) {
200 if (err != filesystem::mojom::FileError::OK) { 199 if (err != filesystem::mojom::FileError::OK) {
201 // We failed to open the directory; continue with startup so that we create 200 // We failed to open the directory; continue with startup so that we create
202 // the |level_db_wrappers_|. 201 // the |level_db_wrappers_|.
203 OnDatabaseOpened(leveldb::mojom::DatabaseError::IO_ERROR); 202 OnDatabaseOpened(leveldb::mojom::DatabaseError::IO_ERROR);
204 return; 203 return;
205 } 204 }
206 205
207 // Now that we have a directory, connect to the LevelDB service and get our 206 // Now that we have a directory, connect to the LevelDB service and get our
208 // database. 207 // database.
209 file_service_connection_->GetInterface(&leveldb_service_); 208 file_service_connection_->GetInterface(&leveldb_service_);
210 209
211 leveldb_service_->Open( 210 leveldb_service_->Open(
212 std::move(directory_), "leveldb", GetProxy(&database_), 211 std::move(directory_), "leveldb", MakeRequest(&database_),
213 base::Bind(&MojoState::OnDatabaseOpened, weak_ptr_factory_.GetWeakPtr())); 212 base::Bind(&MojoState::OnDatabaseOpened, weak_ptr_factory_.GetWeakPtr()));
214 } 213 }
215 214
216 void DOMStorageContextWrapper::MojoState::OnDatabaseOpened( 215 void DOMStorageContextWrapper::MojoState::OnDatabaseOpened(
217 leveldb::mojom::DatabaseError status) { 216 leveldb::mojom::DatabaseError status) {
218 if (status != leveldb::mojom::DatabaseError::OK) { 217 if (status != leveldb::mojom::DatabaseError::OK) {
219 // If we failed to open the database, reset the service object so we pass 218 // If we failed to open the database, reset the service object so we pass
220 // null pointers to our wrappers. 219 // null pointers to our wrappers.
221 database_.reset(); 220 database_.reset();
222 leveldb_service_.reset(); 221 leveldb_service_.reset();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 461 }
463 462
464 void DOMStorageContextWrapper::PurgeMemory(DOMStorageContextImpl::PurgeOption 463 void DOMStorageContextWrapper::PurgeMemory(DOMStorageContextImpl::PurgeOption
465 purge_option) { 464 purge_option) {
466 context_->task_runner()->PostTask( 465 context_->task_runner()->PostTask(
467 FROM_HERE, 466 FROM_HERE,
468 base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option)); 467 base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option));
469 } 468 }
470 469
471 } // namespace content 470 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_context.cc ('k') | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698