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

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

Issue 1825413003: leveldb_service: Attempt to fix deadlock on shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style/lint 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 <map>
8 #include <string>
9
7 #include "base/rand_util.h" 10 #include "base/rand_util.h"
8 #include "components/leveldb/env_mojo.h" 11 #include "components/leveldb/env_mojo.h"
9 #include "components/leveldb/util.h" 12 #include "components/leveldb/util.h"
10 #include "mojo/common/common_type_converters.h" 13 #include "mojo/common/common_type_converters.h"
11 #include "third_party/leveldatabase/src/include/leveldb/db.h" 14 #include "third_party/leveldatabase/src/include/leveldb/db.h"
12 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 15 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
13 16
14 namespace leveldb { 17 namespace leveldb {
15 namespace { 18 namespace {
16 19
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 db_->ReleaseSnapshot(it->second); 103 db_->ReleaseSnapshot(it->second);
101 snapshot_map_.erase(it); 104 snapshot_map_.erase(it);
102 } 105 }
103 } 106 }
104 107
105 void LevelDBDatabaseImpl::GetFromSnapshot(uint64_t snapshot_id, 108 void LevelDBDatabaseImpl::GetFromSnapshot(uint64_t snapshot_id,
106 mojo::Array<uint8_t> key, 109 mojo::Array<uint8_t> key,
107 const GetCallback& callback) { 110 const GetCallback& callback) {
108 // If the snapshot id is invalid, send back invalid argument 111 // If the snapshot id is invalid, send back invalid argument
109 auto it = snapshot_map_.find(snapshot_id); 112 auto it = snapshot_map_.find(snapshot_id);
110 if (it == snapshot_map_.end()) 113 if (it == snapshot_map_.end()) {
111 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>()); 114 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>());
115 return;
Elliot Glaysher 2016/03/23 21:46:34 This was just wrong on my part.
116 }
112 117
113 std::string value; 118 std::string value;
114 leveldb::ReadOptions options; 119 leveldb::ReadOptions options;
115 options.snapshot = it->second; 120 options.snapshot = it->second;
116 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value); 121 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value);
117 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value)); 122 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value));
118 } 123 }
119 124
120 } // namespace leveldb 125 } // namespace leveldb
OLDNEW
« no previous file with comments | « no previous file | components/leveldb/leveldb_file_thread.h » ('j') | components/leveldb/leveldb_file_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698