| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" | 8 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" |
| 9 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 9 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
| 10 #include "content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h
" | 10 #include "content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h
" |
| 11 #include "third_party/leveldatabase/env_chromium.h" |
| 11 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 12 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 class FunctionTracer { | 16 class FunctionTracer { |
| 16 public: | 17 public: |
| 17 FunctionTracer(const std::string& class_name, | 18 FunctionTracer(const std::string& class_name, |
| 18 const std::string& method_name, | 19 const std::string& method_name, |
| 19 int instance_num) | 20 int instance_num) |
| 20 : class_name_(class_name), | 21 : class_name_(class_name), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 bool* found) override { | 58 bool* found) override { |
| 58 if (fail_method_ != FAIL_METHOD_GET || | 59 if (fail_method_ != FAIL_METHOD_GET || |
| 59 ++current_call_num_ != fail_on_call_num_) | 60 ++current_call_num_ != fail_on_call_num_) |
| 60 return LevelDBTransaction::Get(key, value, found); | 61 return LevelDBTransaction::Get(key, value, found); |
| 61 | 62 |
| 62 *found = false; | 63 *found = false; |
| 63 return leveldb::Status::Corruption("Corrupted for the test"); | 64 return leveldb::Status::Corruption("Corrupted for the test"); |
| 64 } | 65 } |
| 65 | 66 |
| 66 leveldb::Status Commit() override { | 67 leveldb::Status Commit() override { |
| 67 if (fail_method_ != FAIL_METHOD_COMMIT || | 68 if ((fail_method_ != FAIL_METHOD_COMMIT && |
| 69 fail_method_ != FAIL_METHOD_COMMIT_DISK_FULL) || |
| 68 ++current_call_num_ != fail_on_call_num_) | 70 ++current_call_num_ != fail_on_call_num_) |
| 69 return LevelDBTransaction::Commit(); | 71 return LevelDBTransaction::Commit(); |
| 70 | 72 |
| 73 // TODO(jsbell): Consider parameterizing the failure mode. |
| 74 if (fail_method_ == FAIL_METHOD_COMMIT_DISK_FULL) { |
| 75 return leveldb_env::MakeIOError("dummy filename", "Disk Full", |
| 76 leveldb_env::kWritableFileAppend, |
| 77 base::File::FILE_ERROR_NO_SPACE); |
| 78 } |
| 79 |
| 71 return leveldb::Status::Corruption("Corrupted for the test"); | 80 return leveldb::Status::Corruption("Corrupted for the test"); |
| 72 } | 81 } |
| 73 | 82 |
| 74 private: | 83 private: |
| 75 ~LevelDBTestTransaction() override {} | 84 ~LevelDBTestTransaction() override {} |
| 76 | 85 |
| 77 FailMethod fail_method_; | 86 FailMethod fail_method_; |
| 78 int fail_on_call_num_; | 87 int fail_on_call_num_; |
| 79 int current_call_num_; | 88 int current_call_num_; |
| 80 }; | 89 }; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 270 |
| 262 void MockBrowserTestIndexedDBClassFactory::Reset() { | 271 void MockBrowserTestIndexedDBClassFactory::Reset() { |
| 263 failure_class_ = FAIL_CLASS_NOTHING; | 272 failure_class_ = FAIL_CLASS_NOTHING; |
| 264 failure_method_ = FAIL_METHOD_NOTHING; | 273 failure_method_ = FAIL_METHOD_NOTHING; |
| 265 instance_count_.clear(); | 274 instance_count_.clear(); |
| 266 fail_on_instance_num_.clear(); | 275 fail_on_instance_num_.clear(); |
| 267 fail_on_call_num_.clear(); | 276 fail_on_call_num_.clear(); |
| 268 } | 277 } |
| 269 | 278 |
| 270 } // namespace content | 279 } // namespace content |
| OLD | NEW |