| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 } // namespace | 241 } // namespace |
| 242 | 242 |
| 243 class MemoryDumpManagerTest : public testing::Test { | 243 class MemoryDumpManagerTest : public testing::Test { |
| 244 public: | 244 public: |
| 245 MemoryDumpManagerTest() : testing::Test(), kDefaultOptions() {} | 245 MemoryDumpManagerTest() : testing::Test(), kDefaultOptions() {} |
| 246 | 246 |
| 247 void SetUp() override { | 247 void SetUp() override { |
| 248 last_callback_success_ = false; | 248 last_callback_success_ = false; |
| 249 message_loop_.reset(new MessageLoop()); | 249 message_loop_.reset(new MessageLoop()); |
| 250 mdm_.reset(new MemoryDumpManager()); | 250 mdm_ = MemoryDumpManager::CreateInstanceForTesting(); |
| 251 ASSERT_EQ(mdm_.get(), MemoryDumpManager::GetInstance()); |
| 251 results_.clear(); | 252 results_.clear(); |
| 252 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); | |
| 253 ASSERT_EQ(mdm_.get(), MemoryDumpManager::GetInstance()); | |
| 254 } | 253 } |
| 255 | 254 |
| 256 void TearDown() override { | 255 void TearDown() override { |
| 257 MemoryDumpManager::SetInstanceForTesting(nullptr); | |
| 258 mdm_.reset(); | 256 mdm_.reset(); |
| 259 message_loop_.reset(); | 257 message_loop_.reset(); |
| 260 TraceLog::DeleteForTesting(); | 258 TraceLog::DeleteForTesting(); |
| 261 } | 259 } |
| 262 | 260 |
| 263 // Turns a Closure into a GlobalMemoryDumpCallback, keeping track of the | 261 // Turns a Closure into a GlobalMemoryDumpCallback, keeping track of the |
| 264 // callback result and taking care of posting the closure on the correct task | 262 // callback result and taking care of posting the closure on the correct task |
| 265 // runner. | 263 // runner. |
| 266 void GlobalDumpCallbackAdapter( | 264 void GlobalDumpCallbackAdapter( |
| 267 scoped_refptr<SingleThreadTaskRunner> task_runner, | 265 scoped_refptr<SingleThreadTaskRunner> task_runner, |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 EXPECT_EQ(3u, result.chrome_dump.v8_total_kb); | 1402 EXPECT_EQ(3u, result.chrome_dump.v8_total_kb); |
| 1405 // partition_alloc has partition_alloc/allocated_objects/* which is a subset | 1403 // partition_alloc has partition_alloc/allocated_objects/* which is a subset |
| 1406 // of partition_alloc/partitions/* so we only count the latter. | 1404 // of partition_alloc/partitions/* so we only count the latter. |
| 1407 EXPECT_EQ(4u, result.chrome_dump.partition_alloc_total_kb); | 1405 EXPECT_EQ(4u, result.chrome_dump.partition_alloc_total_kb); |
| 1408 // resident_set_kb should read from process_totals. | 1406 // resident_set_kb should read from process_totals. |
| 1409 EXPECT_EQ(5u, result.os_dump.resident_set_kb); | 1407 EXPECT_EQ(5u, result.os_dump.resident_set_kb); |
| 1410 }; | 1408 }; |
| 1411 | 1409 |
| 1412 } // namespace trace_event | 1410 } // namespace trace_event |
| 1413 } // namespace base | 1411 } // namespace base |
| OLD | NEW |