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

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

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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/metrics/statistics_recorder.h ('k') | base/process/process_linux.cc » ('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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 16
17 namespace base { 17 namespace base {
18 namespace { 18 namespace {
19 19
20 LazyInstance<std::vector<ActionCallback>> g_callbacks = 20 LazyInstance<std::vector<ActionCallback>>::DestructorAtExit g_callbacks =
21 LAZY_INSTANCE_INITIALIZER; 21 LAZY_INSTANCE_INITIALIZER;
22 LazyInstance<scoped_refptr<SingleThreadTaskRunner>> g_task_runner = 22 LazyInstance<scoped_refptr<SingleThreadTaskRunner>>::DestructorAtExit
23 LAZY_INSTANCE_INITIALIZER; 23 g_task_runner = LAZY_INSTANCE_INITIALIZER;
24 24
25 } // namespace 25 } // namespace
26 26
27 void RecordAction(const UserMetricsAction& action) { 27 void RecordAction(const UserMetricsAction& action) {
28 RecordComputedAction(action.str_); 28 RecordComputedAction(action.str_);
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());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/metrics/statistics_recorder.h ('k') | base/process/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698