Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Side by Side Diff: content/browser/dom_storage/session_storage_database_unittest.cc

Issue 113403006: Update some uses of char16 to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 5
6 #include "content/browser/dom_storage/session_storage_database.h" 6 #include "content/browser/dom_storage/session_storage_database.h"
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 void SessionStorageDatabaseTest::DumpData() const { 297 void SessionStorageDatabaseTest::DumpData() const {
298 LOG(WARNING) << "---- Session storage contents"; 298 LOG(WARNING) << "---- Session storage contents";
299 scoped_ptr<leveldb::Iterator> it( 299 scoped_ptr<leveldb::Iterator> it(
300 db_->db_->NewIterator(leveldb::ReadOptions())); 300 db_->db_->NewIterator(leveldb::ReadOptions()));
301 for (it->SeekToFirst(); it->Valid(); it->Next()) { 301 for (it->SeekToFirst(); it->Valid(); it->Next()) {
302 int64 dummy_map_id; 302 int64 dummy_map_id;
303 if (IsMapValueKey(it->key().ToString(), &dummy_map_id)) { 303 if (IsMapValueKey(it->key().ToString(), &dummy_map_id)) {
304 // Convert the value back to base::string16. 304 // Convert the value back to base::string16.
305 base::string16 value; 305 base::string16 value;
306 size_t len = it->value().size() / sizeof(char16); 306 size_t len = it->value().size() / sizeof(base::char16);
307 value.resize(len); 307 value.resize(len);
308 value.assign(reinterpret_cast<const char16*>(it->value().data()), len); 308 value.assign(
309 reinterpret_cast<const base::char16*>(it->value().data()), len);
309 LOG(WARNING) << it->key().ToString() << ": " << value; 310 LOG(WARNING) << it->key().ToString() << ": " << value;
310 } else { 311 } else {
311 LOG(WARNING) << it->key().ToString() << ": " << it->value().ToString(); 312 LOG(WARNING) << it->key().ToString() << ": " << it->value().ToString();
312 } 313 }
313 } 314 }
314 LOG(WARNING) << "----"; 315 LOG(WARNING) << "----";
315 } 316 }
316 317
317 void SessionStorageDatabaseTest::CheckAreaData( 318 void SessionStorageDatabaseTest::CheckAreaData(
318 const std::string& namespace_id, const GURL& origin, 319 const std::string& namespace_id, const GURL& origin,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // But the copy persists. 693 // But the copy persists.
693 CheckAreaData(kNamespaceClone, kOrigin1, data1); 694 CheckAreaData(kNamespaceClone, kOrigin1, data1);
694 CheckAreaData(kNamespaceClone, kOrigin2, data2); 695 CheckAreaData(kNamespaceClone, kOrigin2, data2);
695 } 696 }
696 697
697 TEST_F(SessionStorageDatabaseTest, WriteRawBytes) { 698 TEST_F(SessionStorageDatabaseTest, WriteRawBytes) {
698 // Write data which is not valid utf8 and contains null bytes. 699 // Write data which is not valid utf8 and contains null bytes.
699 unsigned char raw_data[10] = {255, 0, 0, 0, 1, 2, 3, 4, 5, 0}; 700 unsigned char raw_data[10] = {255, 0, 0, 0, 1, 2, 3, 4, 5, 0};
700 DOMStorageValuesMap changes; 701 DOMStorageValuesMap changes;
701 base::string16 string_with_raw_data; 702 base::string16 string_with_raw_data;
702 string_with_raw_data.assign(reinterpret_cast<char16*>(raw_data), 5); 703 string_with_raw_data.assign(reinterpret_cast<base::char16*>(raw_data), 5);
703 changes[kKey1] = base::NullableString16(string_with_raw_data, false); 704 changes[kKey1] = base::NullableString16(string_with_raw_data, false);
704 EXPECT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin1, false, changes)); 705 EXPECT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin1, false, changes));
705 CheckDatabaseConsistency(); 706 CheckDatabaseConsistency();
706 DOMStorageValuesMap values; 707 DOMStorageValuesMap values;
707 db_->ReadAreaValues(kNamespace1, kOrigin1, &values); 708 db_->ReadAreaValues(kNamespace1, kOrigin1, &values);
708 const unsigned char* data = 709 const unsigned char* data =
709 reinterpret_cast<const unsigned char*>(values[kKey1].string().data()); 710 reinterpret_cast<const unsigned char*>(values[kKey1].string().data());
710 for (int i = 0; i < 10; ++i) 711 for (int i = 0; i < 10; ++i)
711 EXPECT_EQ(raw_data[i], data[i]); 712 EXPECT_EQ(raw_data[i], data[i]);
712 } 713 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 ASSERT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin2, false, data2)); 790 ASSERT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin2, false, data2));
790 791
791 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin1)); 792 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin1));
792 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin2)); 793 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin2));
793 // Check that also the namespace start key was deleted. 794 // Check that also the namespace start key was deleted.
794 CheckDatabaseConsistency(); 795 CheckDatabaseConsistency();
795 } 796 }
796 797
797 798
798 } // namespace content 799 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/session_storage_database.cc ('k') | content/browser/download/drag_download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698