| 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 <cerrno> | 5 #include <cerrno> |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ON_CALL(mock_leveldb_factory, OpenLevelDB(_, _, _, _)).WillByDefault( | 95 ON_CALL(mock_leveldb_factory, OpenLevelDB(_, _, _, _)).WillByDefault( |
| 96 Invoke(&busted_factory, &BustedLevelDBFactory::OpenLevelDB)); | 96 Invoke(&busted_factory, &BustedLevelDBFactory::OpenLevelDB)); |
| 97 ON_CALL(mock_leveldb_factory, DestroyLevelDB(_)).WillByDefault( | 97 ON_CALL(mock_leveldb_factory, DestroyLevelDB(_)).WillByDefault( |
| 98 Invoke(&busted_factory, &BustedLevelDBFactory::DestroyLevelDB)); | 98 Invoke(&busted_factory, &BustedLevelDBFactory::DestroyLevelDB)); |
| 99 | 99 |
| 100 EXPECT_CALL(mock_leveldb_factory, OpenLevelDB(_, _, _, _)).Times(Exactly(1)); | 100 EXPECT_CALL(mock_leveldb_factory, OpenLevelDB(_, _, _, _)).Times(Exactly(1)); |
| 101 EXPECT_CALL(mock_leveldb_factory, DestroyLevelDB(_)).Times(Exactly(1)); | 101 EXPECT_CALL(mock_leveldb_factory, DestroyLevelDB(_)).Times(Exactly(1)); |
| 102 blink::WebIDBDataLoss data_loss = blink::WebIDBDataLossNone; | 102 blink::WebIDBDataLoss data_loss = blink::WebIDBDataLossNone; |
| 103 std::string data_loss_message; | 103 std::string data_loss_message; |
| 104 bool disk_full = false; | 104 bool disk_full = false; |
| 105 base::TaskRunner* task_runner = NULL; | 105 base::SequencedTaskRunner* task_runner = NULL; |
| 106 bool clean_journal = false; | 106 bool clean_journal = false; |
| 107 leveldb::Status s; | 107 leveldb::Status s; |
| 108 scoped_refptr<IndexedDBBackingStore> backing_store = | 108 scoped_refptr<IndexedDBBackingStore> backing_store = |
| 109 IndexedDBBackingStore::Open(factory, | 109 IndexedDBBackingStore::Open(factory, |
| 110 origin, | 110 origin, |
| 111 path, | 111 path, |
| 112 request_context, | 112 request_context, |
| 113 &data_loss, | 113 &data_loss, |
| 114 &data_loss_message, | 114 &data_loss_message, |
| 115 &disk_full, | 115 &disk_full, |
| 116 &mock_leveldb_factory, | 116 &mock_leveldb_factory, |
| 117 task_runner, | 117 task_runner, |
| 118 clean_journal, | 118 clean_journal, |
| 119 &s); | 119 &s); |
| 120 } | 120 } |
| 121 | 121 |
| 122 TEST(IndexedDBNonRecoverableIOErrorTest, NuancedCleanupTest) { | 122 TEST(IndexedDBNonRecoverableIOErrorTest, NuancedCleanupTest) { |
| 123 content::IndexedDBFactory* factory = NULL; | 123 content::IndexedDBFactory* factory = NULL; |
| 124 const GURL origin("http://localhost:81"); | 124 const GURL origin("http://localhost:81"); |
| 125 net::URLRequestContext* request_context = NULL; | 125 net::URLRequestContext* request_context = NULL; |
| 126 base::ScopedTempDir temp_directory; | 126 base::ScopedTempDir temp_directory; |
| 127 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 127 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
| 128 const base::FilePath path = temp_directory.path(); | 128 const base::FilePath path = temp_directory.path(); |
| 129 blink::WebIDBDataLoss data_loss = | 129 blink::WebIDBDataLoss data_loss = |
| 130 blink::WebIDBDataLossNone; | 130 blink::WebIDBDataLossNone; |
| 131 std::string data_loss_reason; | 131 std::string data_loss_reason; |
| 132 bool disk_full = false; | 132 bool disk_full = false; |
| 133 base::TaskRunner* task_runner = NULL; | 133 base::SequencedTaskRunner* task_runner = NULL; |
| 134 bool clean_journal = false; | 134 bool clean_journal = false; |
| 135 leveldb::Status s; | 135 leveldb::Status s; |
| 136 | 136 |
| 137 BustedLevelDBFactory busted_factory; | 137 BustedLevelDBFactory busted_factory; |
| 138 content::MockLevelDBFactory mock_leveldb_factory; | 138 content::MockLevelDBFactory mock_leveldb_factory; |
| 139 ON_CALL(mock_leveldb_factory, OpenLevelDB(_, _, _, _)).WillByDefault( | 139 ON_CALL(mock_leveldb_factory, OpenLevelDB(_, _, _, _)).WillByDefault( |
| 140 Invoke(&busted_factory, &BustedLevelDBFactory::OpenLevelDB)); | 140 Invoke(&busted_factory, &BustedLevelDBFactory::OpenLevelDB)); |
| 141 ON_CALL(mock_leveldb_factory, DestroyLevelDB(_)).WillByDefault( | 141 ON_CALL(mock_leveldb_factory, DestroyLevelDB(_)).WillByDefault( |
| 142 Invoke(&busted_factory, &BustedLevelDBFactory::DestroyLevelDB)); | 142 Invoke(&busted_factory, &BustedLevelDBFactory::DestroyLevelDB)); |
| 143 | 143 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 &data_loss_reason, | 207 &data_loss_reason, |
| 208 &disk_full, | 208 &disk_full, |
| 209 &mock_leveldb_factory, | 209 &mock_leveldb_factory, |
| 210 task_runner, | 210 task_runner, |
| 211 clean_journal, | 211 clean_journal, |
| 212 &s); | 212 &s); |
| 213 ASSERT_TRUE(s.IsIOError()); | 213 ASSERT_TRUE(s.IsIOError()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace | 216 } // namespace |
| OLD | NEW |