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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_database.cc

Issue 16256014: IndexedDB: Convert decoding functions to pass StringPieces vs. pointers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/indexed_db/leveldb/leveldb_database.h" 5 #include "content/browser/indexed_db/leveldb/leveldb_database.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 const leveldb::Status s = db_->Delete(write_options, MakeSlice(key)); 235 const leveldb::Status s = db_->Delete(write_options, MakeSlice(key));
236 if (s.ok()) 236 if (s.ok())
237 return true; 237 return true;
238 if (s.IsNotFound()) 238 if (s.IsNotFound())
239 return false; 239 return false;
240 LOG(ERROR) << "LevelDB remove failed: " << s.ToString(); 240 LOG(ERROR) << "LevelDB remove failed: " << s.ToString();
241 return false; 241 return false;
242 } 242 }
243 243
244 bool LevelDBDatabase::Get(const LevelDBSlice& key, 244 bool LevelDBDatabase::Get(const LevelDBSlice& key,
245 std::vector<char>& value, 245 std::string* value,
246 bool& found, 246 bool& found,
247 const LevelDBSnapshot* snapshot) { 247 const LevelDBSnapshot* snapshot) {
248 found = false; 248 found = false;
249 std::string result;
250 leveldb::ReadOptions read_options; 249 leveldb::ReadOptions read_options;
251 read_options.verify_checksums = true; // TODO(jsbell): Disable this if the 250 read_options.verify_checksums = true; // TODO(jsbell): Disable this if the
252 // performance impact is too great. 251 // performance impact is too great.
253 read_options.snapshot = snapshot ? snapshot->snapshot_ : 0; 252 read_options.snapshot = snapshot ? snapshot->snapshot_ : 0;
254 253
255 const leveldb::Status s = db_->Get(read_options, MakeSlice(key), &result); 254 const leveldb::Status s = db_->Get(read_options, MakeSlice(key), value);
256 if (s.ok()) { 255 if (s.ok()) {
257 found = true; 256 found = true;
258 value.clear();
259 value.insert(value.end(), result.begin(), result.end());
260 return true; 257 return true;
261 } 258 }
262 if (s.IsNotFound()) 259 if (s.IsNotFound())
263 return true; 260 return true;
264 LOG(ERROR) << "LevelDB get failed: " << s.ToString(); 261 LOG(ERROR) << "LevelDB get failed: " << s.ToString();
265 return false; 262 return false;
266 } 263 }
267 264
268 bool LevelDBDatabase::Write(LevelDBWriteBatch& write_batch) { 265 bool LevelDBDatabase::Write(LevelDBWriteBatch& write_batch) {
269 leveldb::WriteOptions write_options; 266 leveldb::WriteOptions write_options;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (!i) // TODO(jsbell): Double check if we actually need to check this. 350 if (!i) // TODO(jsbell): Double check if we actually need to check this.
354 return scoped_ptr<LevelDBIterator>(); 351 return scoped_ptr<LevelDBIterator>();
355 return scoped_ptr<LevelDBIterator>(new IteratorImpl(i.Pass())); 352 return scoped_ptr<LevelDBIterator>(new IteratorImpl(i.Pass()));
356 } 353 }
357 354
358 const LevelDBComparator* LevelDBDatabase::Comparator() const { 355 const LevelDBComparator* LevelDBDatabase::Comparator() const {
359 return comparator_; 356 return comparator_;
360 } 357 }
361 358
362 } // namespace content 359 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698