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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "components/leveldb/public/cpp/util.h" | 10 #include "components/leveldb/public/cpp/util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 key.reserve(arraysize(kMetaPrefix) + serialized_origin.size()); | 63 key.reserve(arraysize(kMetaPrefix) + serialized_origin.size()); |
| 64 key.insert(key.end(), kMetaPrefix, kMetaPrefix + arraysize(kMetaPrefix)); | 64 key.insert(key.end(), kMetaPrefix, kMetaPrefix + arraysize(kMetaPrefix)); |
| 65 key.insert(key.end(), serialized_origin.begin(), serialized_origin.end()); | 65 key.insert(key.end(), serialized_origin.begin(), serialized_origin.end()); |
| 66 return key; | 66 return key; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void NoOpSuccess(bool success) {} | 69 void NoOpSuccess(bool success) {} |
| 70 | 70 |
| 71 std::vector<uint8_t> String16ToUint8Vector(const base::string16& input) { | 71 std::vector<uint8_t> String16ToUint8Vector(const base::string16& input) { |
| 72 const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data()); | 72 const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data()); |
| 73 return std::vector<uint8_t>(data, data + input.size() * sizeof(base::char16)); | 73 std::vector<uint8_t> result; |
| 74 result.reserve(input.size() * sizeof(base::char16) + 1); | |
| 75 result.push_back(0); | |
|
michaeln
2017/03/22 23:49:51
The magic "0" value here is pretty magical, it mig
Marijn Kruisselbrink
2017/03/31 23:06:14
Yeah, I agree that this isn't very nice. I changed
| |
| 76 result.insert(result.end(), data, data + input.size() * sizeof(base::char16)); | |
| 77 return result; | |
| 74 } | 78 } |
| 75 | 79 |
| 76 void MigrateStorageHelper( | 80 void MigrateStorageHelper( |
| 77 base::FilePath db_path, | 81 base::FilePath db_path, |
| 78 const scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner, | 82 const scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner, |
| 79 base::Callback<void(std::unique_ptr<LevelDBWrapperImpl::ValueMap>)> | 83 base::Callback<void(std::unique_ptr<LevelDBWrapperImpl::ValueMap>)> |
| 80 callback) { | 84 callback) { |
| 81 DOMStorageDatabase db(db_path); | 85 DOMStorageDatabase db(db_path); |
| 82 DOMStorageValuesMap map; | 86 DOMStorageValuesMap map; |
| 83 db.ReadAllValues(&map); | 87 db.ReadAllValues(&map); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 for (const auto& info : usage) { | 593 for (const auto& info : usage) { |
| 590 url::Origin origin_candidate(info.origin); | 594 url::Origin origin_candidate(info.origin); |
| 591 if (!origin_candidate.IsSameOriginWith(origin) && | 595 if (!origin_candidate.IsSameOriginWith(origin) && |
| 592 origin_candidate.IsSamePhysicalOriginWith(origin)) | 596 origin_candidate.IsSamePhysicalOriginWith(origin)) |
| 593 DeleteStorage(origin_candidate); | 597 DeleteStorage(origin_candidate); |
| 594 } | 598 } |
| 595 DeleteStorage(origin); | 599 DeleteStorage(origin); |
| 596 } | 600 } |
| 597 | 601 |
| 598 } // namespace content | 602 } // namespace content |
| OLD | NEW |