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

Side by Side Diff: components/language_usage_metrics/language_usage_metrics.cc

Issue 131203002: Move LanguageUsageMetrics and TranslateBrowserMetrics to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/language_usage_metrics.h" 5 #include "components/language_usage_metrics/language_usage_metrics.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 12
13 namespace { 13 namespace {
14 void RecordAcceptLanguage(int language_code) { 14 void RecordAcceptLanguage(int language_code) {
15 UMA_HISTOGRAM_SPARSE_SLOWLY("LanguageUsage.AcceptLanguage", 15 UMA_HISTOGRAM_SPARSE_SLOWLY("LanguageUsage.AcceptLanguage",
16 language_code); 16 language_code);
17 } 17 }
18 } // namespace 18 } // namespace
19 19
20 namespace language_usage_metrics {
21
20 // static 22 // static
21 void LanguageUsageMetrics::RecordAcceptLanguages( 23 void LanguageUsageMetrics::RecordAcceptLanguages(
22 const std::string& accept_languages) { 24 const std::string& accept_languages) {
23 std::set<int> languages; 25 std::set<int> languages;
24 ParseAcceptLanguages(accept_languages, &languages); 26 ParseAcceptLanguages(accept_languages, &languages);
25 std::for_each(languages.begin(), languages.end(), RecordAcceptLanguage); 27 std::for_each(languages.begin(), languages.end(), RecordAcceptLanguage);
26 } 28 }
27 29
28 // static 30 // static
29 void LanguageUsageMetrics::RecordApplicationLanguage( 31 void LanguageUsageMetrics::RecordApplicationLanguage(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const std::string& accept_languages, 64 const std::string& accept_languages,
63 std::set<int>* languages) { 65 std::set<int>* languages) {
64 languages->clear(); 66 languages->clear();
65 base::StringTokenizer locales(accept_languages, ","); 67 base::StringTokenizer locales(accept_languages, ",");
66 while (locales.GetNext()) { 68 while (locales.GetNext()) {
67 const int language_code = ToLanguageCode(locales.token()); 69 const int language_code = ToLanguageCode(locales.token());
68 if (language_code != 0) 70 if (language_code != 0)
69 languages->insert(language_code); 71 languages->insert(language_code);
70 } 72 }
71 } 73 }
74
75 } // namespace language_usage_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698