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

Side by Side Diff: services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl_unittest.cc

Issue 2820433005: memory-infra: Start disentangling tracing from memory-infra (Closed)
Patch Set: Created 3 years, 8 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 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/memory_dump_manager_de legate_impl.h" 5 #include "services/resource_coordinator/public/cpp/memory/memory_dump_manager_de legate_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"
11 #include "base/trace_event/memory_dump_request_args.h" 11 #include "base/trace_event/memory_dump_request_args.h"
12 #include "base/trace_event/memory_tracing_frontend.h"
12 #include "base/trace_event/trace_config.h" 13 #include "base/trace_event/trace_config.h"
13 #include "base/trace_event/trace_log.h" 14 #include "base/trace_event/trace_log.h"
14 #include "mojo/public/cpp/bindings/binding_set.h" 15 #include "mojo/public/cpp/bindings/binding_set.h"
15 #include "services/resource_coordinator/public/cpp/memory/coordinator.h" 16 #include "services/resource_coordinator/public/cpp/memory/coordinator.h"
16 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h" 17 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using base::trace_event::MemoryDumpLevelOfDetail; 20 using base::trace_event::MemoryDumpLevelOfDetail;
20 using base::trace_event::MemoryDumpManager; 21 using base::trace_event::MemoryDumpManager;
21 using base::trace_event::MemoryDumpType; 22 using base::trace_event::MemoryDumpType;
23 using base::trace_event::MemoryTracingFrontend;
22 24
23 namespace memory_instrumentation { 25 namespace memory_instrumentation {
24 26
25 class MockCoordinator : public Coordinator, public mojom::Coordinator { 27 class MockCoordinator : public Coordinator, public mojom::Coordinator {
26 public: 28 public:
27 void BindCoordinatorRequest(mojom::CoordinatorRequest request) override { 29 void BindCoordinatorRequest(mojom::CoordinatorRequest request) override {
28 bindings_.AddBinding(this, std::move(request)); 30 bindings_.AddBinding(this, std::move(request));
29 } 31 }
30 32
31 void RegisterProcessLocalDumpManager( 33 void RegisterProcessLocalDumpManager(
(...skipping 13 matching lines...) Expand all
45 public: 47 public:
46 void SetUp() override { 48 void SetUp() override {
47 message_loop_.reset(new base::MessageLoop()); 49 message_loop_.reset(new base::MessageLoop());
48 coordinator_.reset(new MockCoordinator()); 50 coordinator_.reset(new MockCoordinator());
49 mdm_.reset(new MemoryDumpManager()); 51 mdm_.reset(new MemoryDumpManager());
50 MemoryDumpManager::SetInstanceForTesting(mdm_.get()); 52 MemoryDumpManager::SetInstanceForTesting(mdm_.get());
51 MemoryDumpManagerDelegateImpl::Config config(coordinator_.get()); 53 MemoryDumpManagerDelegateImpl::Config config(coordinator_.get());
52 auto delegate = base::MakeUnique<MemoryDumpManagerDelegateImpl>(config); 54 auto delegate = base::MakeUnique<MemoryDumpManagerDelegateImpl>(config);
53 delegate->SetAsNonCoordinatorForTesting(); 55 delegate->SetAsNonCoordinatorForTesting();
54 mdm_->Initialize(std::move(delegate)); 56 mdm_->Initialize(std::move(delegate));
57 MemoryTracingFrontend::Initialize(mdm_.get());
55 58
56 // Enable tracing. 59 // Enable tracing.
57 std::string category_filter = "-*,"; 60 std::string category_filter = "-*,";
58 category_filter += MemoryDumpManager::kTraceCategory; 61 category_filter += MemoryDumpManager::kTraceCategory;
59 base::trace_event::TraceConfig trace_config(category_filter, ""); 62 base::trace_event::TraceConfig trace_config(category_filter, "");
60 base::trace_event::TraceLog::GetInstance()->SetEnabled( 63 base::trace_event::TraceLog::GetInstance()->SetEnabled(
61 trace_config, base::trace_event::TraceLog::RECORDING_MODE); 64 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
62 65
63 // Reset the counters. 66 // Reset the counters.
64 expected_callback_calls_ = 0; 67 expected_callback_calls_ = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 expected_callback_calls_ = 3; 129 expected_callback_calls_ = 3;
127 quit_closure_ = run_loop.QuitClosure(); 130 quit_closure_ = run_loop.QuitClosure();
128 SequentiallyRequestGlobalDumps(1); 131 SequentiallyRequestGlobalDumps(1);
129 SequentiallyRequestGlobalDumps(1); 132 SequentiallyRequestGlobalDumps(1);
130 SequentiallyRequestGlobalDumps(1); 133 SequentiallyRequestGlobalDumps(1);
131 run_loop.Run(); 134 run_loop.Run();
132 EXPECT_EQ(1, dump_requests_received_by_coordinator_); 135 EXPECT_EQ(1, dump_requests_received_by_coordinator_);
133 } 136 }
134 137
135 } // namespace memory_instrumentation 138 } // namespace memory_instrumentation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698