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

Unified Diff: net/disk_cache/backend_unittest.cc

Issue 2661333002: Track SimpleCache memory usage in net/ MemoryDumpProvider (Closed)
Patch Set: address comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/backend_unittest.cc
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index 2f401c8cfcbdea79b56826fce07108a5d9ea1f12..20fa69ae349087155c05bf5ecd6cf51aaab52710 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -18,6 +18,7 @@
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "base/trace_event/memory_usage_estimator.h"
#include "net/base/cache_type.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
@@ -323,6 +324,9 @@ void DiskCacheBackendTest::BackendBasics() {
ASSERT_TRUE(NULL != entry1);
entry1->Close();
entry1 = NULL;
+ // base::trace_event::EstimateMemoryUsage(cache_) is added to make sure
+ // tracking memory doesn't introduce crashes.
+ EXPECT_LT(0u, base::trace_event::EstimateMemoryUsage(cache_));
ASSERT_THAT(OpenEntry("the first key", &entry1), IsOk());
ASSERT_TRUE(NULL != entry1);
@@ -336,18 +340,20 @@ void DiskCacheBackendTest::BackendBasics() {
ASSERT_TRUE(NULL != entry1);
ASSERT_TRUE(NULL != entry2);
EXPECT_EQ(2, cache_->GetEntryCount());
+ EXPECT_LT(0u, base::trace_event::EstimateMemoryUsage(cache_));
disk_cache::Entry* entry3 = NULL;
ASSERT_THAT(OpenEntry("some other key", &entry3), IsOk());
ASSERT_TRUE(NULL != entry3);
EXPECT_TRUE(entry2 == entry3);
- EXPECT_EQ(2, cache_->GetEntryCount());
+ EXPECT_LT(0u, base::trace_event::EstimateMemoryUsage(cache_));
EXPECT_THAT(DoomEntry("some other key"), IsOk());
EXPECT_EQ(1, cache_->GetEntryCount());
entry1->Close();
entry2->Close();
entry3->Close();
+ EXPECT_LT(0u, base::trace_event::EstimateMemoryUsage(cache_));
EXPECT_THAT(DoomEntry("the first key"), IsOk());
EXPECT_EQ(0, cache_->GetEntryCount());
@@ -359,6 +365,7 @@ void DiskCacheBackendTest::BackendBasics() {
EXPECT_THAT(DoomEntry("some other key"), IsOk());
EXPECT_EQ(0, cache_->GetEntryCount());
entry2->Close();
+ EXPECT_LT(0u, base::trace_event::EstimateMemoryUsage(cache_));
}
TEST_F(DiskCacheBackendTest, Basics) {

Powered by Google App Engine
This is Rietveld 408576698