| 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 | 10 // A MetricsService instance is typically created at application startup. It |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // the external server, and the user shuts down, then a copy of the log may be | 138 // the external server, and the user shuts down, then a copy of the log may be |
| 139 // saved for re-transmission. These duplicates could be filtered out server | 139 // saved for re-transmission. These duplicates could be filtered out server |
| 140 // side, but are not expected to be a significant problem. | 140 // side, but are not expected to be a significant problem. |
| 141 // | 141 // |
| 142 // | 142 // |
| 143 //------------------------------------------------------------------------------ | 143 //------------------------------------------------------------------------------ |
| 144 | 144 |
| 145 #include "chrome/browser/metrics/metrics_service.h" | 145 #include "chrome/browser/metrics/metrics_service.h" |
| 146 | 146 |
| 147 #include "base/bind.h" | 147 #include "base/bind.h" |
| 148 #include "base/guid.h" | |
| 149 #include "base/callback.h" | 148 #include "base/callback.h" |
| 150 #include "base/command_line.h" | 149 #include "base/command_line.h" |
| 150 #include "base/guid.h" |
| 151 #include "base/md5.h" | 151 #include "base/md5.h" |
| 152 #include "base/metrics/histogram.h" | 152 #include "base/metrics/histogram.h" |
| 153 #include "base/rand_util.h" | 153 #include "base/rand_util.h" |
| 154 #include "base/string_number_conversions.h" | 154 #include "base/string_number_conversions.h" |
| 155 #include "base/threading/platform_thread.h" | 155 #include "base/threading/platform_thread.h" |
| 156 #include "base/threading/thread.h" | 156 #include "base/threading/thread.h" |
| 157 #include "base/threading/thread_restrictions.h" | 157 #include "base/threading/thread_restrictions.h" |
| 158 #include "base/tracked_objects.h" | 158 #include "base/tracked_objects.h" |
| 159 #include "base/utf_string_conversions.h" | 159 #include "base/utf_string_conversions.h" |
| 160 #include "base/values.h" | 160 #include "base/values.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 181 #include "chrome/common/chrome_switches.h" | 181 #include "chrome/common/chrome_switches.h" |
| 182 #include "chrome/common/metrics/metrics_log_manager.h" | 182 #include "chrome/common/metrics/metrics_log_manager.h" |
| 183 #include "chrome/common/net/test_server_locations.h" | 183 #include "chrome/common/net/test_server_locations.h" |
| 184 #include "chrome/common/pref_names.h" | 184 #include "chrome/common/pref_names.h" |
| 185 #include "chrome/common/render_messages.h" | 185 #include "chrome/common/render_messages.h" |
| 186 #include "content/public/browser/child_process_data.h" | 186 #include "content/public/browser/child_process_data.h" |
| 187 #include "content/public/browser/load_notification_details.h" | 187 #include "content/public/browser/load_notification_details.h" |
| 188 #include "content/public/browser/notification_service.h" | 188 #include "content/public/browser/notification_service.h" |
| 189 #include "content/public/browser/plugin_service.h" | 189 #include "content/public/browser/plugin_service.h" |
| 190 #include "content/public/browser/render_process_host.h" | 190 #include "content/public/browser/render_process_host.h" |
| 191 #include "content/public/common/url_fetcher.h" | |
| 192 #include "net/base/load_flags.h" | 191 #include "net/base/load_flags.h" |
| 192 #include "net/url_request/url_fetcher.h" |
| 193 #include "webkit/plugins/webplugininfo.h" | 193 #include "webkit/plugins/webplugininfo.h" |
| 194 | 194 |
| 195 // TODO(port): port browser_distribution.h. | 195 // TODO(port): port browser_distribution.h. |
| 196 #if !defined(OS_POSIX) | 196 #if !defined(OS_POSIX) |
| 197 #include "chrome/installer/util/browser_distribution.h" | 197 #include "chrome/installer/util/browser_distribution.h" |
| 198 #endif | 198 #endif |
| 199 | 199 |
| 200 #if defined(OS_CHROMEOS) | 200 #if defined(OS_CHROMEOS) |
| 201 #include "chrome/browser/chromeos/cros/cros_library.h" | 201 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 202 #include "chrome/browser/chromeos/external_metrics.h" | 202 #include "chrome/browser/chromeos/external_metrics.h" |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 | 1214 |
| 1215 HandleIdleSinceLastTransmission(true); | 1215 HandleIdleSinceLastTransmission(true); |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 void MetricsService::PrepareFetchWithStagedLog() { | 1218 void MetricsService::PrepareFetchWithStagedLog() { |
| 1219 DCHECK(log_manager_.has_staged_log()); | 1219 DCHECK(log_manager_.has_staged_log()); |
| 1220 | 1220 |
| 1221 // Prepare the XML version. | 1221 // Prepare the XML version. |
| 1222 DCHECK(!current_fetch_xml_.get()); | 1222 DCHECK(!current_fetch_xml_.get()); |
| 1223 if (log_manager_.has_staged_log_xml()) { | 1223 if (log_manager_.has_staged_log_xml()) { |
| 1224 current_fetch_xml_.reset(content::URLFetcher::Create( | 1224 current_fetch_xml_.reset(net::URLFetcher::Create( |
| 1225 GURL(server_url_xml_), net::URLFetcher::POST, this)); | 1225 GURL(server_url_xml_), net::URLFetcher::POST, this)); |
| 1226 current_fetch_xml_->SetRequestContext( | 1226 current_fetch_xml_->SetRequestContext( |
| 1227 g_browser_process->system_request_context()); | 1227 g_browser_process->system_request_context()); |
| 1228 current_fetch_xml_->SetUploadData(kMimeTypeXml, | 1228 current_fetch_xml_->SetUploadData(kMimeTypeXml, |
| 1229 log_manager_.staged_log_text().xml); | 1229 log_manager_.staged_log_text().xml); |
| 1230 // We already drop cookies server-side, but we might as well strip them out | 1230 // We already drop cookies server-side, but we might as well strip them out |
| 1231 // client-side as well. | 1231 // client-side as well. |
| 1232 current_fetch_xml_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 1232 current_fetch_xml_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 1233 net::LOAD_DO_NOT_SEND_COOKIES); | 1233 net::LOAD_DO_NOT_SEND_COOKIES); |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 // Prepare the protobuf version. | 1236 // Prepare the protobuf version. |
| 1237 DCHECK(!current_fetch_proto_.get()); | 1237 DCHECK(!current_fetch_proto_.get()); |
| 1238 if (log_manager_.has_staged_log_proto()) { | 1238 if (log_manager_.has_staged_log_proto()) { |
| 1239 current_fetch_proto_.reset(content::URLFetcher::Create( | 1239 current_fetch_proto_.reset(net::URLFetcher::Create( |
| 1240 GURL(server_url_proto_), net::URLFetcher::POST, this)); | 1240 GURL(server_url_proto_), net::URLFetcher::POST, this)); |
| 1241 current_fetch_proto_->SetRequestContext( | 1241 current_fetch_proto_->SetRequestContext( |
| 1242 g_browser_process->system_request_context()); | 1242 g_browser_process->system_request_context()); |
| 1243 current_fetch_proto_->SetUploadData(kMimeTypeProto, | 1243 current_fetch_proto_->SetUploadData(kMimeTypeProto, |
| 1244 log_manager_.staged_log_text().proto); | 1244 log_manager_.staged_log_text().proto); |
| 1245 // We already drop cookies server-side, but we might as well strip them out | 1245 // We already drop cookies server-side, but we might as well strip them out |
| 1246 // client-side as well. | 1246 // client-side as well. |
| 1247 current_fetch_proto_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 1247 current_fetch_proto_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 1248 net::LOAD_DO_NOT_SEND_COOKIES); | 1248 net::LOAD_DO_NOT_SEND_COOKIES); |
| 1249 } | 1249 } |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 if (local_state) { | 1745 if (local_state) { |
| 1746 const PrefService::Preference* uma_pref = | 1746 const PrefService::Preference* uma_pref = |
| 1747 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1747 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 1748 if (uma_pref) { | 1748 if (uma_pref) { |
| 1749 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1749 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 1750 DCHECK(success); | 1750 DCHECK(success); |
| 1751 } | 1751 } |
| 1752 } | 1752 } |
| 1753 return result; | 1753 return result; |
| 1754 } | 1754 } |
| OLD | NEW |