Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 const std::vector<uint8_t>& value) { | 57 const std::vector<uint8_t>& value) { |
| 58 *success_out = success; | 58 *success_out = success; |
| 59 *value_out = value; | 59 *value_out = value; |
| 60 callback.Run(); | 60 callback.Run(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void NoOpGet(bool success, const std::vector<uint8_t>& value) {} | 63 void NoOpGet(bool success, const std::vector<uint8_t>& value) {} |
| 64 | 64 |
| 65 std::vector<uint8_t> String16ToUint8Vector(const base::string16& input) { | 65 std::vector<uint8_t> String16ToUint8Vector(const base::string16& input) { |
| 66 const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data()); | 66 const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data()); |
| 67 return std::vector<uint8_t>(data, data + input.size() * sizeof(base::char16)); | 67 std::vector<uint8_t> result; |
| 68 result.reserve(input.size() * sizeof(base::char16) + 1); | |
| 69 result.push_back(0); | |
| 70 result.insert(result.end(), data, data + input.size() * sizeof(base::char16)); | |
|
michaeln
2017/03/22 23:49:51
ditto comment about sharing 'format' enum or encod
Marijn Kruisselbrink
2017/03/31 23:06:14
And I changed it so at least the test here shares
| |
| 71 return result; | |
| 68 } | 72 } |
| 69 | 73 |
| 70 class TestLevelDBObserver : public mojom::LevelDBObserver { | 74 class TestLevelDBObserver : public mojom::LevelDBObserver { |
| 71 public: | 75 public: |
| 72 struct Observation { | 76 struct Observation { |
| 73 enum { kAdd, kChange, kDelete, kDeleteAll } type; | 77 enum { kAdd, kChange, kDelete, kDeleteAll } type; |
| 74 std::string key; | 78 std::string key; |
| 75 std::string old_value; | 79 std::string old_value; |
| 76 std::string new_value; | 80 std::string new_value; |
| 77 std::string source; | 81 std::string source; |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 842 base::RunLoop().RunUntilIdle(); | 846 base::RunLoop().RunUntilIdle(); |
| 843 | 847 |
| 844 // Data should have been preserved now. | 848 // Data should have been preserved now. |
| 845 context = base::MakeUnique<LocalStorageContextMojo>( | 849 context = base::MakeUnique<LocalStorageContextMojo>( |
| 846 connector(), nullptr, base::FilePath(), test_path); | 850 connector(), nullptr, base::FilePath(), test_path); |
| 847 EXPECT_TRUE(DoTestGet(context.get(), key, &result)); | 851 EXPECT_TRUE(DoTestGet(context.get(), key, &result)); |
| 848 EXPECT_EQ(value, result); | 852 EXPECT_EQ(value, result); |
| 849 } | 853 } |
| 850 | 854 |
| 851 } // namespace content | 855 } // namespace content |
| OLD | NEW |