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

Unified Diff: base/trace_event/memory_dump_manager_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 side-by-side diff with in-line comments
Download patch
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 8146b04178a3f4d2a359a26d917ce4c6912147d5..6ddf1162d576bb37464eb519510d0e7305ad3647 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -29,6 +29,7 @@
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_scheduler.h"
#include "base/trace_event/memory_infra_background_whitelist.h"
+#include "base/trace_event/memory_tracing_frontend.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_buffer.h"
#include "base/trace_event/trace_config_memory_test_util.h"
@@ -229,6 +230,7 @@ class MemoryDumpManagerTest : public testing::Test {
void TearDown() override {
MemoryDumpManager::SetInstanceForTesting(nullptr);
delegate_ = nullptr;
+ tracing_frontend_ = nullptr;
mdm_.reset();
message_loop_.reset();
TraceLog::DeleteForTesting();
@@ -249,6 +251,8 @@ class MemoryDumpManagerTest : public testing::Test {
mdm_->set_dumper_registrations_ignored_for_testing(true);
delegate_ = new MemoryDumpManagerDelegateForTesting(is_coordinator);
mdm_->Initialize(base::WrapUnique(delegate_));
+ auto* trace_log = TraceLog::GetInstance();
+ tracing_frontend_ = new MemoryTracingFrontend(trace_log, mdm_.get());
}
void RequestGlobalDumpAndWait(MemoryDumpType dump_type,
@@ -284,6 +288,7 @@ class MemoryDumpManagerTest : public testing::Test {
const MemoryDumpProvider::Options kDefaultOptions;
std::unique_ptr<MemoryDumpManager> mdm_;
MemoryDumpManagerDelegateForTesting* delegate_;
+ MemoryTracingFrontend* tracing_frontend_;
bool last_callback_success_;
private:
@@ -996,64 +1001,6 @@ TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) {
DisableTracing();
}
-// Tests against race conditions that might arise when disabling tracing in the
-// middle of a global memory dump.
-// Flaky on iOS, see crbug.com/706961
-#if defined(OS_IOS)
-#define MAYBE_DisableTracingWhileDumping DISABLED_DisableTracingWhileDumping
-#else
-#define MAYBE_DisableTracingWhileDumping DisableTracingWhileDumping
-#endif
-TEST_F(MemoryDumpManagerTest, MAYBE_DisableTracingWhileDumping) {
- base::WaitableEvent tracing_disabled_event(
- WaitableEvent::ResetPolicy::AUTOMATIC,
- WaitableEvent::InitialState::NOT_SIGNALED);
- InitializeMemoryDumpManager(false /* is_coordinator */);
-
- // Register a bound dump provider.
- std::unique_ptr<Thread> mdp_thread(new Thread("test thread"));
- mdp_thread->Start();
- MockMemoryDumpProvider mdp_with_affinity;
- RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(),
- kDefaultOptions);
-
- // Register also an unbound dump provider. Unbound dump providers are always
- // invoked after bound ones.
- MockMemoryDumpProvider unbound_mdp;
- RegisterDumpProvider(&unbound_mdp, nullptr, kDefaultOptions);
-
- EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
- EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
- EXPECT_CALL(mdp_with_affinity, OnMemoryDump(_, _))
- .Times(1)
- .WillOnce(
- Invoke([&tracing_disabled_event](const MemoryDumpArgs&,
- ProcessMemoryDump* pmd) -> bool {
- tracing_disabled_event.Wait();
-
- // At this point tracing has been disabled and the
- // MemoryDumpManager.dump_thread_ has been shut down.
- return true;
- }));
-
- // |unbound_mdp| should never be invoked because the thread for unbound dump
- // providers has been shutdown in the meanwhile.
- EXPECT_CALL(unbound_mdp, OnMemoryDump(_, _)).Times(0);
-
- last_callback_success_ = true;
- RunLoop run_loop;
- MemoryDumpCallback callback =
- Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
- ThreadTaskRunnerHandle::Get(), run_loop.QuitClosure());
- mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
- MemoryDumpLevelOfDetail::DETAILED, callback);
- DisableTracing();
- tracing_disabled_event.Signal();
- run_loop.Run();
-
- EXPECT_FALSE(last_callback_success_);
-}
-
// Tests against race conditions that can happen if tracing is disabled before
// the CreateProcessDump() call. Real-world regression: crbug.com/580295 .
TEST_F(MemoryDumpManagerTest, DisableTracingRightBeforeStartOfDump) {

Powered by Google App Engine
This is Rietveld 408576698