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 "chromecast/base/metrics/grouped_histogram.h" | 5 #include "chromecast/base/metrics/grouped_histogram.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kAppNameErrorNoApp[] = "ERROR_NO_APP_REGISTERED"; | 24 const char kAppNameErrorNoApp[] = "ERROR_NO_APP_REGISTERED"; |
25 | 25 |
26 // Current app name guarded by lock. | 26 // Current app name guarded by lock. |
27 struct CurrentAppNameWithLock { | 27 struct CurrentAppNameWithLock { |
28 base::Lock lock; | 28 base::Lock lock; |
29 std::string app_name; | 29 std::string app_name; |
30 }; | 30 }; |
31 | 31 |
32 base::LazyInstance<CurrentAppNameWithLock> g_current_app = | 32 base::LazyInstance<CurrentAppNameWithLock>::DestructorAtExit g_current_app = |
33 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
34 | 34 |
35 std::string GetAppName() { | 35 std::string GetAppName() { |
36 base::AutoLock lock(g_current_app.Get().lock); | 36 base::AutoLock lock(g_current_app.Get().lock); |
37 const std::string& app_name = g_current_app.Get().app_name; | 37 const std::string& app_name = g_current_app.Get().app_name; |
38 return app_name.empty() ? kAppNameErrorNoApp : app_name; | 38 return app_name.empty() ? kAppNameErrorNoApp : app_name; |
39 } | 39 } |
40 | 40 |
41 struct HistogramArgs { | 41 struct HistogramArgs { |
42 const char* name; | 42 const char* name; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 void TagAppStartForGroupedHistograms(const std::string& app_name) { | 178 void TagAppStartForGroupedHistograms(const std::string& app_name) { |
179 base::AutoLock lock(g_current_app.Get().lock); | 179 base::AutoLock lock(g_current_app.Get().lock); |
180 g_current_app.Get().app_name = app_name; | 180 g_current_app.Get().app_name = app_name; |
181 } | 181 } |
182 | 182 |
183 } // namespace metrics | 183 } // namespace metrics |
184 } // namespace chromecast | 184 } // namespace chromecast |
OLD | NEW |