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

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

Issue 2815963002: [memory-infra] Trigger first periodic dump after initial period (Closed)
Patch Set: Just fix peridic dumps. 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
« no previous file with comments | « no previous file | no next file » | 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 DCHECK_EQ(0u, light_dump_period_ms % min_period_ms); 67 DCHECK_EQ(0u, light_dump_period_ms % min_period_ms);
68 DCHECK_EQ(0u, heavy_dump_period_ms % min_period_ms); 68 DCHECK_EQ(0u, heavy_dump_period_ms % min_period_ms);
69 DCHECK(!config.callback.is_null()); 69 DCHECK(!config.callback.is_null());
70 callback_ = config.callback; 70 callback_ = config.callback;
71 period_ms_ = min_period_ms; 71 period_ms_ = min_period_ms;
72 tick_count_ = 0; 72 tick_count_ = 0;
73 light_dump_rate_ = light_dump_period_ms / min_period_ms; 73 light_dump_rate_ = light_dump_period_ms / min_period_ms;
74 heavy_dump_rate_ = heavy_dump_period_ms / min_period_ms; 74 heavy_dump_rate_ = heavy_dump_period_ms / min_period_ms;
75 SequencedTaskRunnerHandle::Get()->PostTask( 75
76 // Trigger the first dump after |period_ms_| and not as soon as timer starts.
77 SequencedTaskRunnerHandle::Get()->PostDelayedTask(
76 FROM_HERE, 78 FROM_HERE,
77 BindOnce(&MemoryDumpScheduler::Tick, Unretained(this), ++generation_)); 79 BindOnce(&MemoryDumpScheduler::Tick, Unretained(this), ++generation_),
80 TimeDelta::FromMilliseconds(period_ms_));
78 } 81 }
79 82
80 void MemoryDumpScheduler::StopInternal() { 83 void MemoryDumpScheduler::StopInternal() {
81 period_ms_ = 0; 84 period_ms_ = 0;
82 generation_++; 85 generation_++;
83 callback_.Reset(); 86 callback_.Reset();
84 } 87 }
85 88
86 void MemoryDumpScheduler::Tick(uint32_t expected_generation) { 89 void MemoryDumpScheduler::Tick(uint32_t expected_generation) {
87 if (period_ms_ == 0 || generation_ != expected_generation) 90 if (period_ms_ == 0 || generation_ != expected_generation)
(...skipping 15 matching lines...) Expand all
103 callback_.Run(level_of_detail); 106 callback_.Run(level_of_detail);
104 } 107 }
105 108
106 MemoryDumpScheduler::Config::Config() {} 109 MemoryDumpScheduler::Config::Config() {}
107 MemoryDumpScheduler::Config::~Config() {} 110 MemoryDumpScheduler::Config::~Config() {}
108 MemoryDumpScheduler::Config::Config(const MemoryDumpScheduler::Config&) = 111 MemoryDumpScheduler::Config::Config(const MemoryDumpScheduler::Config&) =
109 default; 112 default;
110 113
111 } // namespace trace_event 114 } // namespace trace_event
112 } // namespace base 115 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698