| OLD | NEW |
| 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 Loading... |
| 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->assign(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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 479 |
| 480 if (!db_->Write(*write_batch_)) | 480 if (!db_->Write(*write_batch_)) |
| 481 return false; | 481 return false; |
| 482 | 482 |
| 483 finished_ = true; | 483 finished_ = true; |
| 484 write_batch_->Clear(); | 484 write_batch_->Clear(); |
| 485 return true; | 485 return true; |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace content | 488 } // namespace content |
| OLD | NEW |