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

Side by Side Diff: components/leveldb/leveldb_database_impl.cc

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jam's comments 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
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 "components/leveldb/leveldb_database_impl.h" 5 #include "components/leveldb/leveldb_database_impl.h"
6 6
7 #include "base/rand_util.h" 7 #include "base/rand_util.h"
8 #include "components/leveldb/env_mojo.h" 8 #include "components/leveldb/env_mojo.h"
9 #include "components/leveldb/util.h" 9 #include "components/leveldb/util.h"
10 #include "mojo/common/common_type_converters.h" 10 #include "mojo/common/common_type_converters.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 } // namespace 28 } // namespace
29 29
30 LevelDBDatabaseImpl::LevelDBDatabaseImpl( 30 LevelDBDatabaseImpl::LevelDBDatabaseImpl(
31 mojo::InterfaceRequest<LevelDBDatabase> request, 31 mojo::InterfaceRequest<LevelDBDatabase> request,
32 scoped_ptr<MojoEnv> environment, 32 scoped_ptr<MojoEnv> environment,
33 scoped_ptr<leveldb::DB> db) 33 scoped_ptr<leveldb::DB> db)
34 : binding_(this, std::move(request)), 34 : binding_(this, std::move(request)),
35 environment_(std::move(environment)), 35 environment_(std::move(environment)),
36 db_(std::move(db)) {} 36 db_(std::move(db)) {
37 }
37 38
38 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { 39 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() {
39 for (auto& p : iterator_map_) 40 for (auto& p : iterator_map_)
40 delete p.second; 41 delete p.second;
41 for (auto& p : snapshot_map_) 42 for (auto& p : snapshot_map_)
42 db_->ReleaseSnapshot(p.second); 43 db_->ReleaseSnapshot(p.second);
43 } 44 }
44 45
45 void LevelDBDatabaseImpl::Put(mojo::Array<uint8_t> key, 46 void LevelDBDatabaseImpl::Put(mojo::Array<uint8_t> key,
46 mojo::Array<uint8_t> value, 47 mojo::Array<uint8_t> value,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>()); 112 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>());
112 113
113 std::string value; 114 std::string value;
114 leveldb::ReadOptions options; 115 leveldb::ReadOptions options;
115 options.snapshot = it->second; 116 options.snapshot = it->second;
116 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value); 117 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value);
117 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value)); 118 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value));
118 } 119 }
119 120
120 } // namespace leveldb 121 } // namespace leveldb
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698