Chromium Code Reviews| 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. | |
|
jsbell
2015/02/19 19:05:44
Maybe as a follow-up?
| |
| 74 if (fail_method_ == FAIL_METHOD_COMMIT_DISK_FULL) { | |
| 75 return leveldb_env::MakeIOError( | |
| 76 "dummy filename", | |
| 77 "Disk Full", | |
| 78 leveldb_env::kWritableFileAppend, | |
| 79 base::File::FILE_ERROR_NO_SPACE); | |
| 80 } | |
| 81 | |
| 71 return leveldb::Status::Corruption("Corrupted for the test"); | 82 return leveldb::Status::Corruption("Corrupted for the test"); |
| 72 } | 83 } |
| 73 | 84 |
| 74 private: | 85 private: |
| 75 ~LevelDBTestTransaction() override {} | 86 ~LevelDBTestTransaction() override {} |
| 76 | 87 |
| 77 FailMethod fail_method_; | 88 FailMethod fail_method_; |
| 78 int fail_on_call_num_; | 89 int fail_on_call_num_; |
| 79 int current_call_num_; | 90 int current_call_num_; |
| 80 }; | 91 }; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 | 272 |
| 262 void MockBrowserTestIndexedDBClassFactory::Reset() { | 273 void MockBrowserTestIndexedDBClassFactory::Reset() { |
| 263 failure_class_ = FAIL_CLASS_NOTHING; | 274 failure_class_ = FAIL_CLASS_NOTHING; |
| 264 failure_method_ = FAIL_METHOD_NOTHING; | 275 failure_method_ = FAIL_METHOD_NOTHING; |
| 265 instance_count_.clear(); | 276 instance_count_.clear(); |
| 266 fail_on_instance_num_.clear(); | 277 fail_on_instance_num_.clear(); |
| 267 fail_on_call_num_.clear(); | 278 fail_on_call_num_.clear(); |
| 268 } | 279 } |
| 269 | 280 |
| 270 } // namespace content | 281 } // namespace content |
| OLD | NEW |