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 3 // found in the LICENSE file. 4 5 #include "base/trace_event/memory_dump_provider_info.h" 6 7 #include <tuple> 8 9 #include "base/sequenced_task_runner.h" 10 11 namespace base { 12 namespace trace_event { 13 14 MemoryDumpProviderInfo::MemoryDumpProviderInfo( 15 MemoryDumpProvider* dump_provider, 16 const char* name, 17 scoped_refptr<SequencedTaskRunner> task_runner, 18 const MemoryDumpProvider::Options& options, 19 bool whitelisted_for_background_mode) 20 : dump_provider(dump_provider), 21 options(options), 22 name(name), 23 task_runner(std::move(task_runner)), 24 whitelisted_for_background_mode(whitelisted_for_background_mode), 25 consecutive_failures(0), 26 disabled(false) {} 27 28 MemoryDumpProviderInfo::~MemoryDumpProviderInfo() {} 29 30 bool MemoryDumpProviderInfo::Comparator::operator()( 31 const scoped_refptr<MemoryDumpProviderInfo>& a, 32 const scoped_refptr<MemoryDumpProviderInfo>& b) const { 33 if (!a || !b) 34 return a.get() < b.get(); 35 // Ensure that unbound providers (task_runner == nullptr) always run last. 36 // Rationale: some unbound dump providers are known to be slow, keep them last 37 // to avoid skewing timings of the other dump providers. 38 return std::tie(a->task_runner, a->dump_provider) > 39 std::tie(b->task_runner, b->dump_provider); 40 } 41 42 } // namespace trace_event 43 } // namespace base 44