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

Side by Side Diff: base/trace_event/memory_dump_scheduler.cc

Issue 2768933002: Reland of Add process uptime metadata event in tracing (Closed)
Patch Set: Fix if condition. Created 3 years, 9 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
« no previous file with comments | « base/process/process_info_unittest.cc ('k') | base/trace_event/trace_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/trace_event/memory_dump_scheduler.h" 5 #include "base/trace_event/memory_dump_scheduler.h"
6 6
7 #include "base/process/process_metrics.h" 7 #include "base/process/process_metrics.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "base/trace_event/memory_dump_manager.h" 10 #include "base/trace_event/memory_dump_manager.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 polling_state_.current_state = PollingTriggerState::ENABLED; 89 polling_state_.current_state = PollingTriggerState::ENABLED;
90 polling_state_.ResetTotals(); 90 polling_state_.ResetTotals();
91 91
92 polling_state_.polling_task_runner->PostTask( 92 polling_state_.polling_task_runner->PostTask(
93 FROM_HERE, 93 FROM_HERE,
94 Bind(&MemoryDumpScheduler::PollMemoryOnPollingThread, Unretained(this))); 94 Bind(&MemoryDumpScheduler::PollMemoryOnPollingThread, Unretained(this)));
95 } 95 }
96 96
97 void MemoryDumpScheduler::NotifyDumpTriggered() { 97 void MemoryDumpScheduler::NotifyDumpTriggered() {
98 if (polling_state_.polling_task_runner && 98 if (polling_state_.polling_task_runner &&
99 polling_state_.polling_task_runner->RunsTasksOnCurrentThread()) { 99 !polling_state_.polling_task_runner->RunsTasksOnCurrentThread()) {
100 polling_state_.polling_task_runner->PostTask( 100 polling_state_.polling_task_runner->PostTask(
101 FROM_HERE, 101 FROM_HERE,
102 Bind(&MemoryDumpScheduler::NotifyDumpTriggered, Unretained(this))); 102 Bind(&MemoryDumpScheduler::NotifyDumpTriggered, Unretained(this)));
103 return; 103 return;
104 } 104 }
105 if (polling_state_.current_state != PollingTriggerState::ENABLED) 105 if (polling_state_.current_state != PollingTriggerState::ENABLED)
106 return; 106 return;
107 107
108 polling_state_.ResetTotals(); 108 polling_state_.ResetTotals();
109 } 109 }
110 110
111 void MemoryDumpScheduler::DisableAllTriggers() { 111 void MemoryDumpScheduler::DisableAllTriggers() {
112 if (periodic_state_.timer.IsRunning()) 112 if (periodic_state_.timer.IsRunning())
113 periodic_state_.timer.Stop(); 113 periodic_state_.timer.Stop();
114 DisablePolling(); 114 DisablePolling();
115 } 115 }
116 116
117 void MemoryDumpScheduler::DisablePolling() { 117 void MemoryDumpScheduler::DisablePolling() {
118 if (polling_state_.polling_task_runner->RunsTasksOnCurrentThread()) { 118 if (!polling_state_.polling_task_runner->RunsTasksOnCurrentThread()) {
119 if (polling_state_.polling_task_runner->PostTask( 119 if (polling_state_.polling_task_runner->PostTask(
120 FROM_HERE, 120 FROM_HERE,
121 Bind(&MemoryDumpScheduler::DisablePolling, Unretained(this)))) 121 Bind(&MemoryDumpScheduler::DisablePolling, Unretained(this))))
122 return; 122 return;
123 } 123 }
124 polling_state_.current_state = PollingTriggerState::DISABLED; 124 polling_state_.current_state = PollingTriggerState::DISABLED;
125 polling_state_.polling_task_runner = nullptr; 125 polling_state_.polling_task_runner = nullptr;
126 } 126 }
127 127
128 // static 128 // static
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 last_memory_totals_kb[last_memory_totals_kb_index] * 1024; 295 last_memory_totals_kb[last_memory_totals_kb_index] * 1024;
296 } 296 }
297 num_polls_from_last_dump = 0; 297 num_polls_from_last_dump = 0;
298 for (uint32_t i = 0; i < kMaxNumMemorySamples; ++i) 298 for (uint32_t i = 0; i < kMaxNumMemorySamples; ++i)
299 last_memory_totals_kb[i] = 0; 299 last_memory_totals_kb[i] = 0;
300 last_memory_totals_kb_index = 0; 300 last_memory_totals_kb_index = 0;
301 } 301 }
302 302
303 } // namespace trace_event 303 } // namespace trace_event
304 } // namespace base 304 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_info_unittest.cc ('k') | base/trace_event/trace_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698