| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/dom_storage/local_storage_context_mojo.h" | 5 #include "content/browser/dom_storage/local_storage_context_mojo.h" |
| 6 | 6 |
| 7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (context_) | 131 if (context_) |
| 132 ShutdownContext(); | 132 ShutdownContext(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 LocalStorageContextMojo* context() { | 135 LocalStorageContextMojo* context() { |
| 136 if (!context_) { | 136 if (!context_) { |
| 137 context_ = new LocalStorageContextMojo( | 137 context_ = new LocalStorageContextMojo( |
| 138 nullptr, task_runner_, temp_path_.GetPath(), | 138 nullptr, task_runner_, temp_path_.GetPath(), |
| 139 base::FilePath(FILE_PATH_LITERAL("leveldb")), | 139 base::FilePath(FILE_PATH_LITERAL("leveldb")), |
| 140 special_storage_policy()); | 140 special_storage_policy()); |
| 141 db_binding_.Bind(context_->DatabaseRequestForTesting()); | 141 leveldb::mojom::LevelDBDatabaseAssociatedPtr database_ptr; |
| 142 leveldb::mojom::LevelDBDatabaseAssociatedRequest request = |
| 143 MakeIsolatedRequest(&database_ptr); |
| 144 context_->SetDatabaseForTesting(std::move(database_ptr)); |
| 145 db_binding_.Bind(std::move(request)); |
| 142 } | 146 } |
| 143 return context_; | 147 return context_; |
| 144 } | 148 } |
| 145 | 149 |
| 146 void ShutdownContext() { | 150 void ShutdownContext() { |
| 147 context_->ShutdownAndDelete(); | 151 context_->ShutdownAndDelete(); |
| 148 context_ = nullptr; | 152 context_ = nullptr; |
| 149 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
| 150 } | 154 } |
| 151 | 155 |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 900 |
| 897 // Data should have been preserved now. | 901 // Data should have been preserved now. |
| 898 context = new LocalStorageContextMojo(connector(), nullptr, base::FilePath(), | 902 context = new LocalStorageContextMojo(connector(), nullptr, base::FilePath(), |
| 899 test_path, nullptr); | 903 test_path, nullptr); |
| 900 EXPECT_TRUE(DoTestGet(context, key, &result)); | 904 EXPECT_TRUE(DoTestGet(context, key, &result)); |
| 901 EXPECT_EQ(value, result); | 905 EXPECT_EQ(value, result); |
| 902 context->ShutdownAndDelete(); | 906 context->ShutdownAndDelete(); |
| 903 } | 907 } |
| 904 | 908 |
| 905 } // namespace content | 909 } // namespace content |
| OLD | NEW |