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

Side by Side Diff: chrome/browser/metrics/metrics_log.cc

Issue 10151017: Remove the hash fields from FieldTrials. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: header order Created 8 years, 7 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 | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.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 (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 #include "chrome/browser/metrics/metrics_log.h" 5 #include "chrome/browser/metrics/metrics_log.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 10 matching lines...) Expand all
21 #include "base/tracked_objects.h" 21 #include "base/tracked_objects.h"
22 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
23 #include "chrome/browser/autocomplete/autocomplete.h" 23 #include "chrome/browser/autocomplete/autocomplete.h"
24 #include "chrome/browser/autocomplete/autocomplete_match.h" 24 #include "chrome/browser/autocomplete/autocomplete_match.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/plugin_prefs.h" 26 #include "chrome/browser/plugin_prefs.h"
27 #include "chrome/browser/prefs/pref_service.h" 27 #include "chrome/browser/prefs/pref_service.h"
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/common/chrome_version_info.h" 29 #include "chrome/common/chrome_version_info.h"
30 #include "chrome/common/logging_chrome.h" 30 #include "chrome/common/logging_chrome.h"
31 #include "chrome/common/metrics/experiments_helper.h"
31 #include "chrome/common/metrics/proto/omnibox_event.pb.h" 32 #include "chrome/common/metrics/proto/omnibox_event.pb.h"
32 #include "chrome/common/metrics/proto/profiler_event.pb.h" 33 #include "chrome/common/metrics/proto/profiler_event.pb.h"
33 #include "chrome/common/metrics/proto/system_profile.pb.h" 34 #include "chrome/common/metrics/proto/system_profile.pb.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
35 #include "content/public/browser/content_browser_client.h" 36 #include "content/public/browser/content_browser_client.h"
36 #include "content/public/browser/gpu_data_manager.h" 37 #include "content/public/browser/gpu_data_manager.h"
37 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
38 #include "content/public/common/gpu_info.h" 39 #include "content/public/common/gpu_info.h"
39 #include "googleurl/src/gurl.h" 40 #include "googleurl/src/gurl.h"
40 #include "ui/gfx/screen.h" 41 #include "ui/gfx/screen.h"
41 #include "webkit/plugins/webplugininfo.h" 42 #include "webkit/plugins/webplugininfo.h"
42 43
43 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) 44 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
44 45
45 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 46 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
46 #if defined(OS_WIN) 47 #if defined(OS_WIN)
47 extern "C" IMAGE_DOS_HEADER __ImageBase; 48 extern "C" IMAGE_DOS_HEADER __ImageBase;
48 #endif 49 #endif
49 50
50 using content::GpuDataManager; 51 using content::GpuDataManager;
51 using metrics::OmniboxEventProto; 52 using metrics::OmniboxEventProto;
52 using metrics::ProfilerEventProto; 53 using metrics::ProfilerEventProto;
53 using metrics::SystemProfileProto; 54 using metrics::SystemProfileProto;
54 using tracked_objects::ProcessDataSnapshot; 55 using tracked_objects::ProcessDataSnapshot;
55 typedef base::FieldTrial::NameGroupId NameGroupId; 56 typedef experiments_helper::SelectedGroupId SelectedGroupId;
56 57
57 namespace { 58 namespace {
58 59
59 // Returns the date at which the current metrics client ID was created as 60 // Returns the date at which the current metrics client ID was created as
60 // a string containing milliseconds since the epoch, or "0" if none was found. 61 // a string containing milliseconds since the epoch, or "0" if none was found.
61 std::string GetInstallDate(PrefService* pref) { 62 std::string GetInstallDate(PrefService* pref) {
62 if (!pref) { 63 if (!pref) {
63 NOTREACHED(); 64 NOTREACHED();
64 return "0"; 65 return "0";
65 } 66 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void SetPluginInfo(const webkit::WebPluginInfo& plugin_info, 204 void SetPluginInfo(const webkit::WebPluginInfo& plugin_info,
204 const PluginPrefs* plugin_prefs, 205 const PluginPrefs* plugin_prefs,
205 SystemProfileProto::Plugin* plugin) { 206 SystemProfileProto::Plugin* plugin) {
206 plugin->set_name(UTF16ToUTF8(plugin_info.name)); 207 plugin->set_name(UTF16ToUTF8(plugin_info.name));
207 plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe()); 208 plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe());
208 plugin->set_version(UTF16ToUTF8(plugin_info.version)); 209 plugin->set_version(UTF16ToUTF8(plugin_info.version));
209 if (plugin_prefs) 210 if (plugin_prefs)
210 plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info)); 211 plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info));
211 } 212 }
212 213
213 void WriteFieldTrials(const std::vector<NameGroupId>& field_trial_ids, 214 void WriteFieldTrials(const std::vector<SelectedGroupId>& field_trial_ids,
214 SystemProfileProto* system_profile) { 215 SystemProfileProto* system_profile) {
215 for (std::vector<NameGroupId>::const_iterator it = field_trial_ids.begin(); 216 for (std::vector<SelectedGroupId>::const_iterator it =
216 it != field_trial_ids.end(); ++it) { 217 field_trial_ids.begin(); it != field_trial_ids.end(); ++it) {
217 SystemProfileProto::FieldTrial* field_trial = 218 SystemProfileProto::FieldTrial* field_trial =
218 system_profile->add_field_trial(); 219 system_profile->add_field_trial();
219 field_trial->set_name_id(it->name); 220 field_trial->set_name_id(it->name);
220 field_trial->set_group_id(it->group); 221 field_trial->set_group_id(it->group);
221 } 222 }
222 } 223 }
223 224
224 void WriteProfilerData(const ProcessDataSnapshot& profiler_data, 225 void WriteProfilerData(const ProcessDataSnapshot& profiler_data,
225 content::ProcessType process_type, 226 content::ProcessType process_type,
226 ProfilerEventProto* performance_profile) { 227 ProfilerEventProto* performance_profile) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 gfx::Size MetricsLog::GetScreenSize() const { 345 gfx::Size MetricsLog::GetScreenSize() const {
345 return gfx::Screen::GetPrimaryMonitor().size(); 346 return gfx::Screen::GetPrimaryMonitor().size();
346 } 347 }
347 348
348 int MetricsLog::GetScreenCount() const { 349 int MetricsLog::GetScreenCount() const {
349 return gfx::Screen::GetNumMonitors(); 350 return gfx::Screen::GetNumMonitors();
350 } 351 }
351 352
352 353
353 void MetricsLog::GetFieldTrialIds( 354 void MetricsLog::GetFieldTrialIds(
354 std::vector<NameGroupId>* field_trial_ids) const { 355 std::vector<SelectedGroupId>* field_trial_ids) const {
355 base::FieldTrialList::GetFieldTrialNameGroupIds(field_trial_ids); 356 experiments_helper::GetFieldTrialSelectedGroupIds(field_trial_ids);
356 } 357 }
357 358
358 void MetricsLog::WriteStabilityElement( 359 void MetricsLog::WriteStabilityElement(
359 const std::vector<webkit::WebPluginInfo>& plugin_list, 360 const std::vector<webkit::WebPluginInfo>& plugin_list,
360 PrefService* pref) { 361 PrefService* pref) {
361 DCHECK(!locked()); 362 DCHECK(!locked());
362 363
363 // Get stability attributes out of Local State, zeroing out stored values. 364 // Get stability attributes out of Local State, zeroing out stored values.
364 // NOTE: This could lead to some data loss if this report isn't successfully 365 // NOTE: This could lead to some data loss if this report isn't successfully
365 // sent, but that's true for all the metrics. 366 // sent, but that's true for all the metrics.
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 gpu_performance->set_overall_score(gpu_info.performance_stats.overall); 771 gpu_performance->set_overall_score(gpu_info.performance_stats.overall);
771 772
772 const gfx::Size display_size = GetScreenSize(); 773 const gfx::Size display_size = GetScreenSize();
773 hardware->set_primary_screen_width(display_size.width()); 774 hardware->set_primary_screen_width(display_size.width());
774 hardware->set_primary_screen_height(display_size.height()); 775 hardware->set_primary_screen_height(display_size.height());
775 hardware->set_screen_count(GetScreenCount()); 776 hardware->set_screen_count(GetScreenCount());
776 777
777 bool write_as_xml = false; 778 bool write_as_xml = false;
778 WritePluginList(plugin_list, write_as_xml); 779 WritePluginList(plugin_list, write_as_xml);
779 780
780 std::vector<NameGroupId> field_trial_ids; 781 std::vector<SelectedGroupId> field_trial_ids;
781 GetFieldTrialIds(&field_trial_ids); 782 GetFieldTrialIds(&field_trial_ids);
782 WriteFieldTrials(field_trial_ids, system_profile); 783 WriteFieldTrials(field_trial_ids, system_profile);
783 } 784 }
784 785
785 void MetricsLog::RecordProfilerData( 786 void MetricsLog::RecordProfilerData(
786 const tracked_objects::ProcessDataSnapshot& process_data, 787 const tracked_objects::ProcessDataSnapshot& process_data,
787 content::ProcessType process_type) { 788 content::ProcessType process_type) {
788 DCHECK(!locked()); 789 DCHECK(!locked());
789 790
790 if (tracked_objects::GetAlternateTimeSource()) { 791 if (tracked_objects::GetAlternateTimeSource()) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 i != log.result.end(); ++i) { 942 i != log.result.end(); ++i) {
942 OmniboxEventProto::Suggestion* suggestion = omnibox_event->add_suggestion(); 943 OmniboxEventProto::Suggestion* suggestion = omnibox_event->add_suggestion();
943 suggestion->set_provider(AsOmniboxEventProviderType(i->provider)); 944 suggestion->set_provider(AsOmniboxEventProviderType(i->provider));
944 suggestion->set_result_type(AsOmniboxEventResultType(i->type)); 945 suggestion->set_result_type(AsOmniboxEventResultType(i->type));
945 suggestion->set_relevance(i->relevance); 946 suggestion->set_relevance(i->relevance);
946 suggestion->set_is_starred(i->starred); 947 suggestion->set_is_starred(i->starred);
947 } 948 }
948 949
949 ++num_events_; 950 ++num_events_;
950 } 951 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698