| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/browser/dom_storage/session_storage_database.h" | 5 #include "content/browser/dom_storage/session_storage_database.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 break; | 571 break; |
| 572 } | 572 } |
| 573 // Key is of the form "map-<mapid>-<key>". | 573 // Key is of the form "map-<mapid>-<key>". |
| 574 base::string16 key16 = | 574 base::string16 key16 = |
| 575 base::UTF8ToUTF16(key.substr(map_start_key.length())); | 575 base::UTF8ToUTF16(key.substr(map_start_key.length())); |
| 576 if (only_keys) { | 576 if (only_keys) { |
| 577 (*result)[key16] = base::NullableString16(); | 577 (*result)[key16] = base::NullableString16(); |
| 578 } else { | 578 } else { |
| 579 // Convert the raw data stored in std::string (it->value()) to raw data | 579 // Convert the raw data stored in std::string (it->value()) to raw data |
| 580 // stored in base::string16. | 580 // stored in base::string16. |
| 581 size_t len = it->value().size() / sizeof(char16); | 581 size_t len = it->value().size() / sizeof(base::char16); |
| 582 const char16* data_ptr = | 582 const base::char16* data_ptr = |
| 583 reinterpret_cast<const char16*>(it->value().data()); | 583 reinterpret_cast<const base::char16*>(it->value().data()); |
| 584 (*result)[key16] = | 584 (*result)[key16] = |
| 585 base::NullableString16(base::string16(data_ptr, len), false); | 585 base::NullableString16(base::string16(data_ptr, len), false); |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 return true; | 588 return true; |
| 589 } | 589 } |
| 590 | 590 |
| 591 void SessionStorageDatabase::WriteValuesToMap(const std::string& map_id, | 591 void SessionStorageDatabase::WriteValuesToMap(const std::string& map_id, |
| 592 const DOMStorageValuesMap& values, | 592 const DOMStorageValuesMap& values, |
| 593 leveldb::WriteBatch* batch) { | 593 leveldb::WriteBatch* batch) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 std::string SessionStorageDatabase::MapKey(const std::string& map_id, | 720 std::string SessionStorageDatabase::MapKey(const std::string& map_id, |
| 721 const std::string& key) { | 721 const std::string& key) { |
| 722 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); | 722 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); |
| 723 } | 723 } |
| 724 | 724 |
| 725 const char* SessionStorageDatabase::NextMapIdKey() { | 725 const char* SessionStorageDatabase::NextMapIdKey() { |
| 726 return "next-map-id"; | 726 return "next-map-id"; |
| 727 } | 727 } |
| 728 | 728 |
| 729 } // namespace content | 729 } // namespace content |
| OLD | NEW |