| Index: base/trace_event/memory_dump_manager_unittest.cc
|
| diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc
|
| index e8c33af3e06b935a80911bf049ff3d6e8c3c4b01..b50c048a8f28a7562172edc2b9c88c2bf4cd158d 100644
|
| --- a/base/trace_event/memory_dump_manager_unittest.cc
|
| +++ b/base/trace_event/memory_dump_manager_unittest.cc
|
| @@ -118,7 +118,8 @@ void PostTaskAndWait(const tracked_objects::Location& from_here,
|
| // requests locally to the MemoryDumpManager instead of performing IPC dances.
|
| class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate {
|
| public:
|
| - MemoryDumpManagerDelegateForTesting() {
|
| + MemoryDumpManagerDelegateForTesting(bool is_coordinator)
|
| + : is_coordinator_(is_coordinator) {
|
| ON_CALL(*this, RequestGlobalMemoryDump(_, _))
|
| .WillByDefault(Invoke(
|
| this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump));
|
| @@ -133,8 +134,16 @@ class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate {
|
| return MemoryDumpManager::kInvalidTracingProcessId;
|
| }
|
|
|
| + bool IsCoordinator() const override { return is_coordinator_; }
|
| + void SetIsCoordinator(bool is_coordinator) {
|
| + is_coordinator_ = is_coordinator;
|
| + }
|
| +
|
| // Promote the CreateProcessDump to public so it can be used by test fixtures.
|
| using MemoryDumpManagerDelegate::CreateProcessDump;
|
| +
|
| + private:
|
| + bool is_coordinator_;
|
| };
|
|
|
| class MockMemoryDumpProvider : public MemoryDumpProvider {
|
| @@ -219,13 +228,15 @@ class MemoryDumpManagerTest : public testing::Test {
|
| mdm_.reset(new MemoryDumpManager());
|
| MemoryDumpManager::SetInstanceForTesting(mdm_.get());
|
| ASSERT_EQ(mdm_.get(), MemoryDumpManager::GetInstance());
|
| - delegate_.reset(new MemoryDumpManagerDelegateForTesting);
|
| + delegate_for_mdm_.reset(new MemoryDumpManagerDelegateForTesting(false));
|
| + delegate_ = delegate_for_mdm_.get();
|
| }
|
|
|
| void TearDown() override {
|
| MemoryDumpManager::SetInstanceForTesting(nullptr);
|
| + delegate_for_mdm_.reset();
|
| + delegate_ = nullptr;
|
| mdm_.reset();
|
| - delegate_.reset();
|
| message_loop_.reset();
|
| TraceLog::DeleteForTesting();
|
| }
|
| @@ -247,7 +258,8 @@ class MemoryDumpManagerTest : public testing::Test {
|
| protected:
|
| void InitializeMemoryDumpManager(bool is_coordinator) {
|
| mdm_->set_dumper_registrations_ignored_for_testing(true);
|
| - mdm_->Initialize(delegate_.get(), is_coordinator);
|
| + delegate_for_mdm_->SetIsCoordinator(is_coordinator);
|
| + mdm_->Initialize(std::move(delegate_for_mdm_));
|
| }
|
|
|
| void RequestGlobalDumpAndWait(MemoryDumpType dump_type,
|
| @@ -286,7 +298,10 @@ class MemoryDumpManagerTest : public testing::Test {
|
|
|
| const MemoryDumpProvider::Options kDefaultOptions;
|
| std::unique_ptr<MemoryDumpManager> mdm_;
|
| - std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_;
|
| + // The delegate that is going to be passed to MDM.
|
| + std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_for_mdm_;
|
| + // A pointer to the delegate that is owned by MDM, after MD initialization.
|
| + MemoryDumpManagerDelegateForTesting* delegate_;
|
| bool last_callback_success_;
|
|
|
| private:
|
|
|