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

Side by Side Diff: base/metrics/user_metrics.cc

Issue 2791243002: Rewrite base::Bind into base::BindOnce on trivial cases in base (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/message_loop/message_pump_perftest.cc ('k') | base/observer_list_threadsafe.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/metrics/user_metrics.h" 5 #include "base/metrics/user_metrics.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 void RecordComputedAction(const std::string& action) { 31 void RecordComputedAction(const std::string& action) {
32 if (!g_task_runner.Get()) { 32 if (!g_task_runner.Get()) {
33 DCHECK(g_callbacks.Get().empty()); 33 DCHECK(g_callbacks.Get().empty());
34 return; 34 return;
35 } 35 }
36 36
37 if (!g_task_runner.Get()->BelongsToCurrentThread()) { 37 if (!g_task_runner.Get()->BelongsToCurrentThread()) {
38 g_task_runner.Get()->PostTask(FROM_HERE, 38 g_task_runner.Get()->PostTask(FROM_HERE,
39 Bind(&RecordComputedAction, action)); 39 BindOnce(&RecordComputedAction, action));
40 return; 40 return;
41 } 41 }
42 42
43 for (const ActionCallback& callback : g_callbacks.Get()) { 43 for (const ActionCallback& callback : g_callbacks.Get()) {
44 callback.Run(action); 44 callback.Run(action);
45 } 45 }
46 } 46 }
47 47
48 void AddActionCallback(const ActionCallback& callback) { 48 void AddActionCallback(const ActionCallback& callback) {
49 // Only allow adding a callback if the task runner is set. 49 // Only allow adding a callback if the task runner is set.
(...skipping 15 matching lines...) Expand all
65 } 65 }
66 66
67 void SetRecordActionTaskRunner( 67 void SetRecordActionTaskRunner(
68 scoped_refptr<SingleThreadTaskRunner> task_runner) { 68 scoped_refptr<SingleThreadTaskRunner> task_runner) {
69 DCHECK(task_runner->BelongsToCurrentThread()); 69 DCHECK(task_runner->BelongsToCurrentThread());
70 DCHECK(!g_task_runner.Get() || g_task_runner.Get()->BelongsToCurrentThread()); 70 DCHECK(!g_task_runner.Get() || g_task_runner.Get()->BelongsToCurrentThread());
71 g_task_runner.Get() = task_runner; 71 g_task_runner.Get() = task_runner;
72 } 72 }
73 73
74 } // namespace base 74 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_perftest.cc ('k') | base/observer_list_threadsafe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698