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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_transaction.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_transaction.h" 5 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/indexed_db/leveldb/leveldb_database.h" 8 #include "content/browser/indexed_db/leveldb/leveldb_database.h"
9 #include "content/browser/indexed_db/leveldb/leveldb_slice.h" 9 #include "content/browser/indexed_db/leveldb/leveldb_slice.h"
10 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" 10 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 void LevelDBTransaction::Put(const LevelDBSlice& key, 71 void LevelDBTransaction::Put(const LevelDBSlice& key,
72 const std::vector<char>& value) { 72 const std::vector<char>& value) {
73 Set(key, value, false); 73 Set(key, value, false);
74 } 74 }
75 75
76 void LevelDBTransaction::Remove(const LevelDBSlice& key) { 76 void LevelDBTransaction::Remove(const LevelDBSlice& key) {
77 Set(key, std::vector<char>(), true); 77 Set(key, std::vector<char>(), true);
78 } 78 }
79 79
80 bool LevelDBTransaction::Get(const LevelDBSlice& key, 80 bool LevelDBTransaction::Get(const LevelDBSlice& key,
81 std::vector<char>& value, 81 std::string* value,
82 bool& found) { 82 bool& found) {
83 found = false; 83 found = false;
84 DCHECK(!finished_); 84 DCHECK(!finished_);
85 AVLTreeNode* node = tree_.search(key); 85 AVLTreeNode* node = tree_.search(key);
86 86
87 if (node) { 87 if (node) {
88 if (node->deleted) 88 if (node->deleted)
89 return true; 89 return true;
90 90
91 value = node->value; 91 *value = std::string(node->value.begin(), node->value.end());
92 found = true; 92 found = true;
93 return true; 93 return true;
94 } 94 }
95 95
96 bool ok = db_->Get(key, value, found, &snapshot_); 96 bool ok = db_->Get(key, value, found, &snapshot_);
97 if (!ok) { 97 if (!ok) {
98 DCHECK(!found); 98 DCHECK(!found);
99 return false; 99 return false;
100 } 100 }
101 return true; 101 return true;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 key_ = (*iterator_)->key; 163 key_ = (*iterator_)->key;
164 } 164 }
165 165
166 void LevelDBTransaction::TreeIterator::Next() { 166 void LevelDBTransaction::TreeIterator::Next() {
167 DCHECK(IsValid()); 167 DCHECK(IsValid());
168 ++iterator_; 168 ++iterator_;
169 if (IsValid()) { 169 if (IsValid()) {
170 DCHECK(transaction_->comparator_->Compare(LevelDBSlice((*iterator_)->key), 170 DCHECK(transaction_->comparator_->Compare(LevelDBSlice((*iterator_)->key),
171 LevelDBSlice(key_)) > 171 LevelDBSlice(key_)) >
172 0); 172 0);
173 (void) transaction_; 173 (void)transaction_;
174 key_ = (*iterator_)->key; 174 key_ = (*iterator_)->key;
175 } 175 }
176 } 176 }
177 177
178 void LevelDBTransaction::TreeIterator::Prev() { 178 void LevelDBTransaction::TreeIterator::Prev() {
179 DCHECK(IsValid()); 179 DCHECK(IsValid());
180 --iterator_; 180 --iterator_;
181 if (IsValid()) { 181 if (IsValid()) {
182 DCHECK(tree_->abstractor().comparator_->Compare( 182 DCHECK(tree_->abstractor().comparator_->Compare(
183 LevelDBSlice((*iterator_)->key), LevelDBSlice(key_)) < 183 LevelDBSlice((*iterator_)->key), LevelDBSlice(key_)) <
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 if (!db_->Write(*write_batch_)) 482 if (!db_->Write(*write_batch_))
483 return false; 483 return false;
484 484
485 finished_ = true; 485 finished_ = true;
486 write_batch_->Clear(); 486 write_batch_->Clear();
487 return true; 487 return true;
488 } 488 }
489 489
490 } // namespace content 490 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698