| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/test/test_simple_task_runner.h" | 13 #include "base/test/test_simple_task_runner.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "content/browser/indexed_db/indexed_db_connection.h" | 16 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 16 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 17 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 17 #include "content/browser/indexed_db/indexed_db_factory_impl.h" | 18 #include "content/browser/indexed_db/indexed_db_factory_impl.h" |
| 18 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" | 19 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" |
| 19 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" | 20 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" |
| 20 #include "content/browser/quota/mock_quota_manager_proxy.h" | 21 #include "content/browser/quota/mock_quota_manager_proxy.h" |
| 21 #include "content/public/browser/storage_partition.h" | 22 #include "content/public/browser/storage_partition.h" |
| 22 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 23 #include "content/public/test/mock_special_storage_policy.h" | 24 #include "content/public/test/mock_special_storage_policy.h" |
| 24 #include "content/public/test/test_browser_context.h" | 25 #include "content/public/test/test_browser_context.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 123 |
| 123 // No data was cleared because of SetForceKeepSessionState. | 124 // No data was cleared because of SetForceKeepSessionState. |
| 124 EXPECT_TRUE(base::DirectoryExists(normal_path)); | 125 EXPECT_TRUE(base::DirectoryExists(normal_path)); |
| 125 EXPECT_TRUE(base::DirectoryExists(session_only_path)); | 126 EXPECT_TRUE(base::DirectoryExists(session_only_path)); |
| 126 } | 127 } |
| 127 | 128 |
| 128 class ForceCloseDBCallbacks : public IndexedDBCallbacks { | 129 class ForceCloseDBCallbacks : public IndexedDBCallbacks { |
| 129 public: | 130 public: |
| 130 ForceCloseDBCallbacks(scoped_refptr<IndexedDBContextImpl> idb_context, | 131 ForceCloseDBCallbacks(scoped_refptr<IndexedDBContextImpl> idb_context, |
| 131 const Origin& origin) | 132 const Origin& origin) |
| 132 : IndexedDBCallbacks(nullptr, origin, nullptr), | 133 : IndexedDBCallbacks(nullptr, |
| 134 origin, |
| 135 nullptr, |
| 136 base::ThreadTaskRunnerHandle::Get()), |
| 133 idb_context_(idb_context), | 137 idb_context_(idb_context), |
| 134 origin_(origin) {} | 138 origin_(origin) {} |
| 135 | 139 |
| 136 void OnSuccess() override {} | 140 void OnSuccess() override {} |
| 137 void OnSuccess(const std::vector<base::string16>&) override {} | 141 void OnSuccess(const std::vector<base::string16>&) override {} |
| 138 void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, | 142 void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, |
| 139 const IndexedDBDatabaseMetadata& metadata) override { | 143 const IndexedDBDatabaseMetadata& metadata) override { |
| 140 connection_ = std::move(connection); | 144 connection_ = std::move(connection); |
| 141 idb_context_->ConnectionOpened(origin_, connection_.get()); | 145 idb_context_->ConnectionOpened(origin_, connection_.get()); |
| 142 } | 146 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 284 |
| 281 // Simulate the write failure. | 285 // Simulate the write failure. |
| 282 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); | 286 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); |
| 283 context->GetIDBFactory()->HandleBackingStoreFailure(kTestOrigin); | 287 context->GetIDBFactory()->HandleBackingStoreFailure(kTestOrigin); |
| 284 | 288 |
| 285 EXPECT_TRUE(db_callbacks->forced_close_called()); | 289 EXPECT_TRUE(db_callbacks->forced_close_called()); |
| 286 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 290 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
| 287 } | 291 } |
| 288 | 292 |
| 289 } // namespace content | 293 } // namespace content |
| OLD | NEW |