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

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

Issue 2101943004: content: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase/update Created 4 years, 5 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 area = dom_namespace->OpenStorageArea(kOrigin); 263 area = dom_namespace->OpenStorageArea(kOrigin);
264 read_value = area->GetItem(kKey); 264 read_value = area->GetItem(kKey);
265 EXPECT_TRUE(read_value.is_null()); 265 EXPECT_TRUE(read_value.is_null());
266 dom_namespace->CloseStorageArea(area); 266 dom_namespace->CloseStorageArea(area);
267 context_->Shutdown(); 267 context_->Shutdown();
268 context_ = NULL; 268 context_ = NULL;
269 base::RunLoop().RunUntilIdle(); 269 base::RunLoop().RunUntilIdle();
270 } 270 }
271 271
272 TEST_F(DOMStorageContextImplTest, PurgeMemory) { 272 TEST_F(DOMStorageContextImplTest, PurgeMemory) {
273 auto dom_namespace = context_->GetStorageNamespace(kLocalStorageNamespaceId); 273 auto* dom_namespace = context_->GetStorageNamespace(kLocalStorageNamespaceId);
274 auto area1 = dom_namespace->OpenStorageArea(kOrigin); 274 auto* area1 = dom_namespace->OpenStorageArea(kOrigin);
275 area1->InitialImportIfNeeded(); 275 area1->InitialImportIfNeeded();
276 276
277 // PURGE_UNOPENED does not delete the open area. 277 // PURGE_UNOPENED does not delete the open area.
278 context_->PurgeMemory(DOMStorageContextImpl::PURGE_UNOPENED); 278 context_->PurgeMemory(DOMStorageContextImpl::PURGE_UNOPENED);
279 EXPECT_EQ(1u, dom_namespace->GetUsageStatistics().total_area_count); 279 EXPECT_EQ(1u, dom_namespace->GetUsageStatistics().total_area_count);
280 EXPECT_EQ(0u, dom_namespace->GetUsageStatistics().inactive_area_count); 280 EXPECT_EQ(0u, dom_namespace->GetUsageStatistics().inactive_area_count);
281 281
282 // PURGE_UNOPENED deletes the unopened area. 282 // PURGE_UNOPENED deletes the unopened area.
283 dom_namespace->CloseStorageArea(area1); 283 dom_namespace->CloseStorageArea(area1);
284 EXPECT_EQ(1u, dom_namespace->GetUsageStatistics().inactive_area_count); 284 EXPECT_EQ(1u, dom_namespace->GetUsageStatistics().inactive_area_count);
285 context_->PurgeMemory(DOMStorageContextImpl::PURGE_UNOPENED); 285 context_->PurgeMemory(DOMStorageContextImpl::PURGE_UNOPENED);
286 EXPECT_EQ(0u, dom_namespace->GetUsageStatistics().total_area_count); 286 EXPECT_EQ(0u, dom_namespace->GetUsageStatistics().total_area_count);
287 287
288 // Add an item to the database and commit changes, and keep it open. So, cache 288 // Add an item to the database and commit changes, and keep it open. So, cache
289 // is kept alive. 289 // is kept alive.
290 auto area2 = dom_namespace->OpenStorageArea(kOrigin); 290 auto* area2 = dom_namespace->OpenStorageArea(kOrigin);
291 base::NullableString16 old_value; 291 base::NullableString16 old_value;
292 area2->SetItem(kKey, kValue, &old_value); 292 area2->SetItem(kKey, kValue, &old_value);
293 // Call commit directly instead of posting task. 293 // Call commit directly instead of posting task.
294 area2->CommitChanges(area2->commit_batch_.get()); 294 area2->CommitChanges(area2->commit_batch_.get());
295 area2->commit_batch_ = nullptr; 295 area2->commit_batch_ = nullptr;
296 296
297 // PURGE_AGGRESSIVE clears the cache in the open area. 297 // PURGE_AGGRESSIVE clears the cache in the open area.
298 EXPECT_NE(0u, dom_namespace->GetUsageStatistics().total_cache_size); 298 EXPECT_NE(0u, dom_namespace->GetUsageStatistics().total_cache_size);
299 context_->PurgeMemory(DOMStorageContextImpl::PURGE_AGGRESSIVE); 299 context_->PurgeMemory(DOMStorageContextImpl::PURGE_AGGRESSIVE);
300 EXPECT_EQ(0u, dom_namespace->GetUsageStatistics().total_cache_size); 300 EXPECT_EQ(0u, dom_namespace->GetUsageStatistics().total_cache_size);
301 } 301 }
302 302
303 } // namespace content 303 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_impl.cc ('k') | content/browser/dom_storage/session_storage_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698