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

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

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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) 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/sys_info.h" 22 #include "base/sys_info.h"
23 #include "base/third_party/nspr/prtime.h" 23 #include "base/third_party/nspr/prtime.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "base/tracked_objects.h" 25 #include "base/tracked_objects.h"
26 #include "chrome/browser/autocomplete/autocomplete_input.h" 26 #include "chrome/browser/autocomplete/autocomplete_input.h"
27 #include "chrome/browser/autocomplete/autocomplete_match.h" 27 #include "chrome/browser/autocomplete/autocomplete_match.h"
28 #include "chrome/browser/autocomplete/autocomplete_provider.h" 28 #include "chrome/browser/autocomplete/autocomplete_provider.h"
29 #include "chrome/browser/autocomplete/autocomplete_result.h" 29 #include "chrome/browser/autocomplete/autocomplete_result.h"
30 #include "chrome/browser/browser_process.h" 30 #include "chrome/browser/browser_process.h"
31 #include "chrome/browser/google/google_util.h" 31 #include "chrome/browser/google/google_util.h"
32 #include "chrome/browser/metrics/rappord.h"
32 #include "chrome/browser/omnibox/omnibox_log.h" 33 #include "chrome/browser/omnibox/omnibox_log.h"
33 #include "chrome/browser/plugins/plugin_prefs.h" 34 #include "chrome/browser/plugins/plugin_prefs.h"
34 #include "chrome/browser/profiles/profile_manager.h" 35 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/common/chrome_version_info.h" 36 #include "chrome/common/chrome_version_info.h"
36 #include "chrome/common/logging_chrome.h" 37 #include "chrome/common/logging_chrome.h"
37 #include "chrome/common/metrics/proto/omnibox_event.pb.h" 38 #include "chrome/common/metrics/proto/omnibox_event.pb.h"
38 #include "chrome/common/metrics/proto/profiler_event.pb.h" 39 #include "chrome/common/metrics/proto/profiler_event.pb.h"
39 #include "chrome/common/metrics/proto/system_profile.pb.h" 40 #include "chrome/common/metrics/proto/system_profile.pb.h"
40 #include "chrome/common/metrics/variations/variations_util.h" 41 #include "chrome/common/metrics/variations/variations_util.h"
41 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 #endif 778 #endif
778 779
779 WriteGoogleUpdateProto(google_update_metrics); 780 WriteGoogleUpdateProto(google_update_metrics);
780 781
781 WritePluginList(plugin_list); 782 WritePluginList(plugin_list);
782 783
783 std::vector<ActiveGroupId> field_trial_ids; 784 std::vector<ActiveGroupId> field_trial_ids;
784 GetFieldTrialIds(&field_trial_ids); 785 GetFieldTrialIds(&field_trial_ids);
785 WriteFieldTrials(field_trial_ids, system_profile); 786 WriteFieldTrials(field_trial_ids, system_profile);
786 787
788 std::string bloom_filter_bits;
789 GetBloomFilterBits(&bloom_filter_bits);
790 WriteBloomFilterBits(bloom_filter_bits, system_profile);
791
787 #if defined(OS_CHROMEOS) 792 #if defined(OS_CHROMEOS)
788 PerfDataProto perf_data_proto; 793 PerfDataProto perf_data_proto;
789 if (perf_provider_.GetPerfData(&perf_data_proto)) 794 if (perf_provider_.GetPerfData(&perf_data_proto))
790 uma_proto()->add_perf_data()->Swap(&perf_data_proto); 795 uma_proto()->add_perf_data()->Swap(&perf_data_proto);
791 796
792 // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that 797 // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that
793 // changes this will fail at the DCHECK(). 798 // changes this will fail at the DCHECK().
794 device::BluetoothAdapterFactory::GetAdapter( 799 device::BluetoothAdapterFactory::GetAdapter(
795 base::Bind(&MetricsLog::SetBluetoothAdapter, 800 base::Bind(&MetricsLog::SetBluetoothAdapter,
796 base::Unretained(this))); 801 base::Unretained(this)));
797 DCHECK(adapter_.get()); 802 DCHECK(adapter_.get());
798 WriteBluetoothProto(hardware); 803 WriteBluetoothProto(hardware);
799 UpdateMultiProfileUserCount(); 804 UpdateMultiProfileUserCount();
800 #endif 805 #endif
801 } 806 }
802 807
808 void MetricsLog::GetBloomFilterBits(std::string* bloom_filter_bits) {
Steven Holte 2013/10/28 21:02:44 This should probably be split into 4 parts: A fun
Ilya Sherman 2013/10/29 00:32:31 If you're intending to provide something of a para
809 PrefService* pref_service = GetPrefService();
810
811 typedef RappordBloomFilter<128, 4, -4, 2, -4> rappord_t;
812 rappord_t rap(1, pref_service->GetString(prefs::kMetricsSecretClientID));
813
814 // std::string homepageurl = pref_service->GetString(prefs::kHomePage);
815 std::string homepageurl = "http://www.google.com/foo?bar";
816 std::vector<std::string> strs;
817 GURL gurl(homepageurl);
818
819 strs.push_back(homepageurl);
820 strs.push_back(gurl.spec());
821 strs.push_back(gurl.host());
822 // TODO(holte) break up host more
823 strs.push_back(gurl.query());
824 strs.push_back(gurl.path());
825 // strs.push_back(gurl.ref());
826
827 const rappord_t::bitmap_t bits = rap.get(strs);
828 *bloom_filter_bits = bits.to_string();
829 }
830
831 void MetricsLog::WriteBloomFilterBits(
832 const std::string& bloom_filter_bits,
833 SystemProfileProto* system_profile) {
834 system_profile->set_bloom_filter_bits(bloom_filter_bits);
835 }
836
803 void MetricsLog::RecordProfilerData( 837 void MetricsLog::RecordProfilerData(
804 const tracked_objects::ProcessDataSnapshot& process_data, 838 const tracked_objects::ProcessDataSnapshot& process_data,
805 int process_type) { 839 int process_type) {
806 DCHECK(!locked()); 840 DCHECK(!locked());
807 841
808 if (tracked_objects::GetTimeSourceType() != 842 if (tracked_objects::GetTimeSourceType() !=
809 tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) { 843 tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) {
810 // We currently only support the default time source, wall clock time. 844 // We currently only support the default time source, wall clock time.
811 return; 845 return;
812 } 846 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 997
964 // We invalidate the user count if it changed while the log was open. 998 // We invalidate the user count if it changed while the log was open.
965 if (system_profile->has_multi_profile_user_count() && 999 if (system_profile->has_multi_profile_user_count() &&
966 user_count != system_profile->multi_profile_user_count()) 1000 user_count != system_profile->multi_profile_user_count())
967 user_count = 0; 1001 user_count = 0;
968 1002
969 system_profile->set_multi_profile_user_count(user_count); 1003 system_profile->set_multi_profile_user_count(user_count);
970 } 1004 }
971 } 1005 }
972 #endif 1006 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698