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

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

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase without dcheck_in_ref_count 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 const scoped_refptr<RefCountedString>& json, 97 const scoped_refptr<RefCountedString>& json,
98 bool has_more_events) { 98 bool has_more_events) {
99 buffer->AddFragment(json->data()); 99 buffer->AddFragment(json->data());
100 if (!has_more_events) 100 if (!has_more_events)
101 quit_closure.Run(); 101 quit_closure.Run();
102 } 102 }
103 103
104 // Posts |task| to |task_runner| and blocks until it is executed. 104 // Posts |task| to |task_runner| and blocks until it is executed.
105 void PostTaskAndWait(const tracked_objects::Location& from_here, 105 void PostTaskAndWait(const tracked_objects::Location& from_here,
106 SequencedTaskRunner* task_runner, 106 SequencedTaskRunner* task_runner,
107 base::Closure task) { 107 base::OnceClosure task) {
108 base::WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, 108 base::WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL,
109 WaitableEvent::InitialState::NOT_SIGNALED); 109 WaitableEvent::InitialState::NOT_SIGNALED);
110 task_runner->PostTask(from_here, std::move(task)); 110 task_runner->PostTask(from_here, std::move(task));
111 task_runner->PostTask( 111 task_runner->PostTask(
112 FROM_HERE, base::Bind(&WaitableEvent::Signal, base::Unretained(&event))); 112 FROM_HERE, base::Bind(&WaitableEvent::Signal, base::Unretained(&event)));
113 // The SequencedTaskRunner guarantees that |event| will only be signaled after 113 // The SequencedTaskRunner guarantees that |event| will only be signaled after
114 // |task| is executed. 114 // |task| is executed.
115 event.Wait(); 115 event.Wait();
116 } 116 }
117 117
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 public: 176 public:
177 TestSequencedTaskRunner() 177 TestSequencedTaskRunner()
178 : worker_pool_(2 /* max_threads */, "Test Task Runner"), 178 : worker_pool_(2 /* max_threads */, "Test Task Runner"),
179 enabled_(true), 179 enabled_(true),
180 num_of_post_tasks_(0) {} 180 num_of_post_tasks_(0) {}
181 181
182 void set_enabled(bool value) { enabled_ = value; } 182 void set_enabled(bool value) { enabled_ = value; }
183 unsigned no_of_post_tasks() const { return num_of_post_tasks_; } 183 unsigned no_of_post_tasks() const { return num_of_post_tasks_; }
184 184
185 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 185 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
186 Closure task, 186 OnceClosure task,
187 TimeDelta delay) override { 187 TimeDelta delay) override {
188 NOTREACHED(); 188 NOTREACHED();
189 return false; 189 return false;
190 } 190 }
191 191
192 bool PostDelayedTask(const tracked_objects::Location& from_here, 192 bool PostDelayedTask(const tracked_objects::Location& from_here,
193 Closure task, 193 OnceClosure task,
194 TimeDelta delay) override { 194 TimeDelta delay) override {
195 num_of_post_tasks_++; 195 num_of_post_tasks_++;
196 if (enabled_) { 196 if (enabled_) {
197 return worker_pool_.pool()->PostSequencedWorkerTask(token_, from_here, 197 return worker_pool_.pool()->PostSequencedWorkerTask(token_, from_here,
198 std::move(task)); 198 std::move(task));
199 } 199 }
200 return false; 200 return false;
201 } 201 }
202 202
203 bool RunsTasksOnCurrentThread() const override { 203 bool RunsTasksOnCurrentThread() const override {
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 thread.Start(); 1289 thread.Start();
1290 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, 1290 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions,
1291 "BlacklistTestDumpProvider"); 1291 "BlacklistTestDumpProvider");
1292 // Unregistering on wrong thread should not crash. 1292 // Unregistering on wrong thread should not crash.
1293 mdm_->UnregisterDumpProvider(&mdp1); 1293 mdm_->UnregisterDumpProvider(&mdp1);
1294 thread.Stop(); 1294 thread.Stop();
1295 } 1295 }
1296 1296
1297 } // namespace trace_event 1297 } // namespace trace_event
1298 } // namespace base 1298 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698