| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |