| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/resource_coordinator/public/cpp/memory/process_local_dump_man
ager_impl.h" | 5 #include "services/resource_coordinator/public/cpp/memory/process_local_dump_man
ager_impl.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/trace_event/memory_dump_manager.h" | 10 #include "base/trace_event/memory_dump_manager.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 mojom::CoordinatorRequest request) override { | 29 mojom::CoordinatorRequest request) override { |
| 30 bindings_.AddBinding(this, std::move(request)); | 30 bindings_.AddBinding(this, std::move(request)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void RegisterProcessLocalDumpManager( | 33 void RegisterProcessLocalDumpManager( |
| 34 mojom::ProcessLocalDumpManagerPtr process_manager) override {} | 34 mojom::ProcessLocalDumpManagerPtr process_manager) override {} |
| 35 | 35 |
| 36 void RequestGlobalMemoryDump( | 36 void RequestGlobalMemoryDump( |
| 37 const base::trace_event::MemoryDumpRequestArgs& args, | 37 const base::trace_event::MemoryDumpRequestArgs& args, |
| 38 const RequestGlobalMemoryDumpCallback& callback) override { | 38 const RequestGlobalMemoryDumpCallback& callback) override { |
| 39 callback.Run(args.dump_guid, true); | 39 callback.Run(args.dump_guid, true, mojom::GlobalMemoryDumpPtr()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 mojo::BindingSet<mojom::Coordinator> bindings_; | 43 mojo::BindingSet<mojom::Coordinator> bindings_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class ProcessLocalDumpManagerImplTest : public testing::Test { | 46 class ProcessLocalDumpManagerImplTest : public testing::Test { |
| 47 public: | 47 public: |
| 48 void SetUp() override { | 48 void SetUp() override { |
| 49 message_loop_.reset(new base::MessageLoop()); | 49 message_loop_.reset(new base::MessageLoop()); |
| 50 coordinator_.reset(new MockCoordinator()); | 50 coordinator_.reset(new MockCoordinator()); |
| 51 mdm_.reset(new MemoryDumpManager()); | 51 mdm_.reset(new MemoryDumpManager()); |
| 52 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); | 52 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); |
| 53 ProcessLocalDumpManagerImpl::Config config(coordinator_.get()); | 53 auto process_type = mojom::ProcessType::OTHER; |
| 54 ProcessLocalDumpManagerImpl::Config config(coordinator_.get(), |
| 55 process_type); |
| 54 local_manager_impl_.reset(new ProcessLocalDumpManagerImpl(config)); | 56 local_manager_impl_.reset(new ProcessLocalDumpManagerImpl(config)); |
| 55 local_manager_impl_->SetAsNonCoordinatorForTesting(); | 57 local_manager_impl_->SetAsNonCoordinatorForTesting(); |
| 56 | 58 |
| 57 // Enable tracing. | 59 // Enable tracing. |
| 58 std::string category_filter = "-*,"; | 60 std::string category_filter = "-*,"; |
| 59 category_filter += MemoryDumpManager::kTraceCategory; | 61 category_filter += MemoryDumpManager::kTraceCategory; |
| 60 base::trace_event::TraceConfig trace_config(category_filter, ""); | 62 base::trace_event::TraceConfig trace_config(category_filter, ""); |
| 61 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 63 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 62 trace_config, base::trace_event::TraceLog::RECORDING_MODE); | 64 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
| 63 | 65 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 expected_callback_calls_ = 3; | 131 expected_callback_calls_ = 3; |
| 130 quit_closure_ = run_loop.QuitClosure(); | 132 quit_closure_ = run_loop.QuitClosure(); |
| 131 SequentiallyRequestGlobalDumps(1); | 133 SequentiallyRequestGlobalDumps(1); |
| 132 SequentiallyRequestGlobalDumps(1); | 134 SequentiallyRequestGlobalDumps(1); |
| 133 SequentiallyRequestGlobalDumps(1); | 135 SequentiallyRequestGlobalDumps(1); |
| 134 run_loop.Run(); | 136 run_loop.Run(); |
| 135 EXPECT_EQ(1, dump_requests_received_by_coordinator_); | 137 EXPECT_EQ(1, dump_requests_received_by_coordinator_); |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace memory_instrumentation | 140 } // namespace memory_instrumentation |
| OLD | NEW |