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

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 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 | « base/threading/worker_pool_win.cc ('k') | cc/test/ordered_simple_task_runner.h » ('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 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const scoped_refptr<RefCountedString>& json, 98 const scoped_refptr<RefCountedString>& json,
99 bool has_more_events) { 99 bool has_more_events) {
100 buffer->AddFragment(json->data()); 100 buffer->AddFragment(json->data());
101 if (!has_more_events) 101 if (!has_more_events)
102 quit_closure.Run(); 102 quit_closure.Run();
103 } 103 }
104 104
105 // Posts |task| to |task_runner| and blocks until it is executed. 105 // Posts |task| to |task_runner| and blocks until it is executed.
106 void PostTaskAndWait(const tracked_objects::Location& from_here, 106 void PostTaskAndWait(const tracked_objects::Location& from_here,
107 SequencedTaskRunner* task_runner, 107 SequencedTaskRunner* task_runner,
108 base::Closure task) { 108 base::OnceClosure task) {
109 base::WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, 109 base::WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL,
110 WaitableEvent::InitialState::NOT_SIGNALED); 110 WaitableEvent::InitialState::NOT_SIGNALED);
111 task_runner->PostTask(from_here, std::move(task)); 111 task_runner->PostTask(from_here, std::move(task));
112 task_runner->PostTask( 112 task_runner->PostTask(
113 FROM_HERE, base::Bind(&WaitableEvent::Signal, base::Unretained(&event))); 113 FROM_HERE, base::Bind(&WaitableEvent::Signal, base::Unretained(&event)));
114 // The SequencedTaskRunner guarantees that |event| will only be signaled after 114 // The SequencedTaskRunner guarantees that |event| will only be signaled after
115 // |task| is executed. 115 // |task| is executed.
116 event.Wait(); 116 event.Wait();
117 } 117 }
118 118
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 public: 175 public:
176 TestSequencedTaskRunner() 176 TestSequencedTaskRunner()
177 : worker_pool_(2 /* max_threads */, "Test Task Runner"), 177 : worker_pool_(2 /* max_threads */, "Test Task Runner"),
178 enabled_(true), 178 enabled_(true),
179 num_of_post_tasks_(0) {} 179 num_of_post_tasks_(0) {}
180 180
181 void set_enabled(bool value) { enabled_ = value; } 181 void set_enabled(bool value) { enabled_ = value; }
182 unsigned no_of_post_tasks() const { return num_of_post_tasks_; } 182 unsigned no_of_post_tasks() const { return num_of_post_tasks_; }
183 183
184 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 184 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
185 Closure task, 185 OnceClosure task,
186 TimeDelta delay) override { 186 TimeDelta delay) override {
187 NOTREACHED(); 187 NOTREACHED();
188 return false; 188 return false;
189 } 189 }
190 190
191 bool PostDelayedTask(const tracked_objects::Location& from_here, 191 bool PostDelayedTask(const tracked_objects::Location& from_here,
192 Closure task, 192 OnceClosure task,
193 TimeDelta delay) override { 193 TimeDelta delay) override {
194 num_of_post_tasks_++; 194 num_of_post_tasks_++;
195 if (enabled_) { 195 if (enabled_) {
196 return worker_pool_.pool()->PostSequencedWorkerTask(token_, from_here, 196 return worker_pool_.pool()->PostSequencedWorkerTask(token_, from_here,
197 std::move(task)); 197 std::move(task));
198 } 198 }
199 return false; 199 return false;
200 } 200 }
201 201
202 bool RunsTasksOnCurrentThread() const override { 202 bool RunsTasksOnCurrentThread() const override {
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 thread.Start(); 1302 thread.Start();
1303 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, 1303 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions,
1304 "BlacklistTestDumpProvider"); 1304 "BlacklistTestDumpProvider");
1305 // Unregistering on wrong thread should not crash. 1305 // Unregistering on wrong thread should not crash.
1306 mdm_->UnregisterDumpProvider(&mdp1); 1306 mdm_->UnregisterDumpProvider(&mdp1);
1307 thread.Stop(); 1307 thread.Stop();
1308 } 1308 }
1309 1309
1310 } // namespace trace_event 1310 } // namespace trace_event
1311 } // namespace base 1311 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/worker_pool_win.cc ('k') | cc/test/ordered_simple_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698