| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
| 6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
| 7 // | 7 // |
| 8 // OVERVIEW | 8 // OVERVIEW |
| 9 // | 9 // |
| 10 // A MetricsService instance is typically created at application startup. It is | 10 // A MetricsService instance is typically created at application startup. It is |
| (...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 const base::string16& child_name = data.name; | 1881 const base::string16& child_name = data.name; |
| 1882 if (!ContainsKey(child_process_stats_buffer_, child_name)) { | 1882 if (!ContainsKey(child_process_stats_buffer_, child_name)) { |
| 1883 child_process_stats_buffer_[child_name] = | 1883 child_process_stats_buffer_[child_name] = |
| 1884 ChildProcessStats(data.process_type); | 1884 ChildProcessStats(data.process_type); |
| 1885 } | 1885 } |
| 1886 return child_process_stats_buffer_[child_name]; | 1886 return child_process_stats_buffer_[child_name]; |
| 1887 } | 1887 } |
| 1888 | 1888 |
| 1889 void MetricsService::RecordPluginChanges(PrefService* pref) { | 1889 void MetricsService::RecordPluginChanges(PrefService* pref) { |
| 1890 ListPrefUpdate update(pref, prefs::kStabilityPluginStats); | 1890 ListPrefUpdate update(pref, prefs::kStabilityPluginStats); |
| 1891 ListValue* plugins = update.Get(); | 1891 base::ListValue* plugins = update.Get(); |
| 1892 DCHECK(plugins); | 1892 DCHECK(plugins); |
| 1893 | 1893 |
| 1894 for (ListValue::iterator value_iter = plugins->begin(); | 1894 for (base::ListValue::iterator value_iter = plugins->begin(); |
| 1895 value_iter != plugins->end(); ++value_iter) { | 1895 value_iter != plugins->end(); ++value_iter) { |
| 1896 if (!(*value_iter)->IsType(Value::TYPE_DICTIONARY)) { | 1896 if (!(*value_iter)->IsType(base::Value::TYPE_DICTIONARY)) { |
| 1897 NOTREACHED(); | 1897 NOTREACHED(); |
| 1898 continue; | 1898 continue; |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); | 1901 base::DictionaryValue* plugin_dict = |
| 1902 static_cast<base::DictionaryValue*>(*value_iter); |
| 1902 std::string plugin_name; | 1903 std::string plugin_name; |
| 1903 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); | 1904 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); |
| 1904 if (plugin_name.empty()) { | 1905 if (plugin_name.empty()) { |
| 1905 NOTREACHED(); | 1906 NOTREACHED(); |
| 1906 continue; | 1907 continue; |
| 1907 } | 1908 } |
| 1908 | 1909 |
| 1909 // TODO(viettrungluu): remove conversions | 1910 // TODO(viettrungluu): remove conversions |
| 1910 base::string16 name16 = UTF8ToUTF16(plugin_name); | 1911 base::string16 name16 = UTF8ToUTF16(plugin_name); |
| 1911 if (child_process_stats_buffer_.find(name16) == | 1912 if (child_process_stats_buffer_.find(name16) == |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { | 1952 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { |
| 1952 ChildProcessStats stats = cache_iter->second; | 1953 ChildProcessStats stats = cache_iter->second; |
| 1953 | 1954 |
| 1954 // Insert only plugins information into the plugins list. | 1955 // Insert only plugins information into the plugins list. |
| 1955 if (!IsPluginProcess(stats.process_type)) | 1956 if (!IsPluginProcess(stats.process_type)) |
| 1956 continue; | 1957 continue; |
| 1957 | 1958 |
| 1958 // TODO(viettrungluu): remove conversion | 1959 // TODO(viettrungluu): remove conversion |
| 1959 std::string plugin_name = UTF16ToUTF8(cache_iter->first); | 1960 std::string plugin_name = UTF16ToUTF8(cache_iter->first); |
| 1960 | 1961 |
| 1961 DictionaryValue* plugin_dict = new DictionaryValue; | 1962 base::DictionaryValue* plugin_dict = new base::DictionaryValue; |
| 1962 | 1963 |
| 1963 plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); | 1964 plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); |
| 1964 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, | 1965 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, |
| 1965 stats.process_launches); | 1966 stats.process_launches); |
| 1966 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, | 1967 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, |
| 1967 stats.process_crashes); | 1968 stats.process_crashes); |
| 1968 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, | 1969 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, |
| 1969 stats.instances); | 1970 stats.instances); |
| 1970 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, | 1971 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, |
| 1971 stats.loading_errors); | 1972 stats.loading_errors); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 if (local_state) { | 2019 if (local_state) { |
| 2019 const PrefService::Preference* uma_pref = | 2020 const PrefService::Preference* uma_pref = |
| 2020 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 2021 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 2021 if (uma_pref) { | 2022 if (uma_pref) { |
| 2022 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 2023 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 2023 DCHECK(success); | 2024 DCHECK(success); |
| 2024 } | 2025 } |
| 2025 } | 2026 } |
| 2026 return result; | 2027 return result; |
| 2027 } | 2028 } |
| OLD | NEW |