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

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

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Key is of the form "map-<mapid>-key". 177 // Key is of the form "map-<mapid>-key".
178 std::string map_id_str = key.substr(map_prefix.length(), 178 std::string map_id_str = key.substr(map_prefix.length(),
179 second_dash - map_prefix.length()); 179 second_dash - map_prefix.length());
180 bool conversion_ok = base::StringToInt64(map_id_str, map_id); 180 bool conversion_ok = base::StringToInt64(map_id_str, map_id);
181 EXPECT_TRUE(conversion_ok); 181 EXPECT_TRUE(conversion_ok);
182 return true; 182 return true;
183 } 183 }
184 184
185 void SessionStorageDatabaseTest::ReadData(DataMap* data) const { 185 void SessionStorageDatabaseTest::ReadData(DataMap* data) const {
186 leveldb::DB* leveldb = db_->db_.get(); 186 leveldb::DB* leveldb = db_->db_.get();
187 scoped_ptr<leveldb::Iterator> it( 187 std::unique_ptr<leveldb::Iterator> it(
188 leveldb->NewIterator(leveldb::ReadOptions())); 188 leveldb->NewIterator(leveldb::ReadOptions()));
189 for (it->SeekToFirst(); it->Valid(); it->Next()) { 189 for (it->SeekToFirst(); it->Valid(); it->Next()) {
190 (*data)[it->key().ToString()] = it->value().ToString(); 190 (*data)[it->key().ToString()] = it->value().ToString();
191 } 191 }
192 } 192 }
193 193
194 void SessionStorageDatabaseTest::CheckDatabaseConsistency() const { 194 void SessionStorageDatabaseTest::CheckDatabaseConsistency() const {
195 DataMap data; 195 DataMap data;
196 ReadData(&data); 196 ReadData(&data);
197 // Empty db is ok. 197 // Empty db is ok.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 size_t valid_keys = 0; 291 size_t valid_keys = 0;
292 if (data.find(SessionStorageDatabase::NamespacePrefix()) != data.end()) 292 if (data.find(SessionStorageDatabase::NamespacePrefix()) != data.end())
293 ++valid_keys; 293 ++valid_keys;
294 if (data.find(SessionStorageDatabase::NextMapIdKey()) != data.end()) 294 if (data.find(SessionStorageDatabase::NextMapIdKey()) != data.end())
295 ++valid_keys; 295 ++valid_keys;
296 EXPECT_EQ(valid_keys, data.size()); 296 EXPECT_EQ(valid_keys, data.size());
297 } 297 }
298 298
299 void SessionStorageDatabaseTest::DumpData() const { 299 void SessionStorageDatabaseTest::DumpData() const {
300 LOG(WARNING) << "---- Session storage contents"; 300 LOG(WARNING) << "---- Session storage contents";
301 scoped_ptr<leveldb::Iterator> it( 301 std::unique_ptr<leveldb::Iterator> it(
302 db_->db_->NewIterator(leveldb::ReadOptions())); 302 db_->db_->NewIterator(leveldb::ReadOptions()));
303 for (it->SeekToFirst(); it->Valid(); it->Next()) { 303 for (it->SeekToFirst(); it->Valid(); it->Next()) {
304 int64_t dummy_map_id; 304 int64_t dummy_map_id;
305 if (IsMapValueKey(it->key().ToString(), &dummy_map_id)) { 305 if (IsMapValueKey(it->key().ToString(), &dummy_map_id)) {
306 // Convert the value back to base::string16. 306 // Convert the value back to base::string16.
307 base::string16 value; 307 base::string16 value;
308 size_t len = it->value().size() / sizeof(base::char16); 308 size_t len = it->value().size() / sizeof(base::char16);
309 value.resize(len); 309 value.resize(len);
310 value.assign( 310 value.assign(
311 reinterpret_cast<const base::char16*>(it->value().data()), len); 311 reinterpret_cast<const base::char16*>(it->value().data()), len);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 ASSERT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin2, false, data2)); 792 ASSERT_TRUE(db_->CommitAreaChanges(kNamespace1, kOrigin2, false, data2));
793 793
794 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin1)); 794 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin1));
795 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin2)); 795 EXPECT_TRUE(db_->DeleteArea(kNamespace1, kOrigin2));
796 // Check that also the namespace start key was deleted. 796 // Check that also the namespace start key was deleted.
797 CheckDatabaseConsistency(); 797 CheckDatabaseConsistency();
798 } 798 }
799 799
800 800
801 } // namespace content 801 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/session_storage_database.cc ('k') | content/browser/file_descriptor_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698