Chromium Code Reviews| Index: chrome/browser/language_usage_metrics.h |
| diff --git a/chrome/browser/language_usage_metrics.h b/chrome/browser/language_usage_metrics.h |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..bf1203eb67589cb84bc90b381c16ec05b2aef21e |
| --- /dev/null |
| +++ b/chrome/browser/language_usage_metrics.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_LANGUAGE_USAGE_METRICS_H_ |
| +#define CHROME_BROWSER_LANGUAGE_USAGE_METRICS_H_ |
| +#pragma once |
| + |
| +#include <set> |
| +#include <string> |
| + |
| +#include "base/gtest_prod_util.h" |
| +#include "third_party/cld/languages/public/languages.h" |
| + |
| +// Methods to record language usage as UMA histograms. |
| +// Language codes are defined in third_party/cld/languages/proto/languages.pb.h |
| +class LanguageUsageMetrics { |
| + |
|
Yusuke Sato
2011/07/13 06:52:06
nit: unnecessary vertical space?
Yuzo
2011/07/13 11:30:20
Done.
|
| + public: |
| + // Records accept languages as a UMA histogram. |accept_languages| is a |
| + // case-insensitive comma-separated list of languages/locales of either xx or |
| + // xx-YY format where xx is iso-639 language code and YY is iso-3166 country |
| + // code. Country code is ignored. That is, xx and Xx-YY are considered |
|
Yusuke Sato
2011/07/13 06:52:06
s/Xx/xx/ ?
Yusuke Sato
2011/07/13 06:52:06
Your implementation seems to handle xx_YY case as
Yuzo
2011/07/13 11:30:20
Done.
Yuzo
2011/07/13 11:30:20
It was intentional to express the case-insensitive
|
| + // identical and recorded once. |
| + static void RecordAcceptLanguages(const std::string& accept_languages); |
| + |
| + // Records the application language as a UMA histogram. |application_locale| |
| + // is a case-insensitive locale string of either xx or xx-YY format. Only the |
|
Yusuke Sato
2011/07/13 06:52:06
ditto.
Yuzo
2011/07/13 11:30:20
Done.
|
| + // language part (xx in the example) is considered. |
| + static void RecordApplicationLanguage(const std::string& application_locale); |
| + |
| + private: |
| + // This class must not be instantiated. |
| + LanguageUsageMetrics() {} |
|
Yusuke Sato
2011/07/13 06:52:06
I believe you can omit the implementation, '{}', i
Yuzo
2011/07/13 11:30:20
Done.
|
| + |
| + // Parses |accept_languages| and returns a set of language codes in |
| + // |languages|. |
| + static void ParseAcceptLanguages(const std::string& accept_languages, |
| + std::set<Language>* languages); |
| + |
| + // Parses |locale| and returns the language code. |
|
Yusuke Sato
2011/07/13 06:52:06
Please mention the error return.
Yuzo
2011/07/13 11:30:20
Done.
|
| + static Language ToLanguage(const std::string& locale); |
| + |
| + FRIEND_TEST_ALL_PREFIXES(LanguageUsageMetricsTest, ParseAcceptLanguages); |
| + FRIEND_TEST_ALL_PREFIXES(LanguageUsageMetricsTest, ToLanguage); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_LANGUAGE_USAGE_METRICS_H_ |