OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
11 // is the central controller for the acquisition of log data, and the automatic | 11 // is the central controller for the acquisition of log data, and the automatic |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 PreparePendingLogText(); | 1325 PreparePendingLogText(); |
1326 DCHECK(!compressed_log_.empty()); | 1326 DCHECK(!compressed_log_.empty()); |
1327 | 1327 |
1328 current_fetch_.reset(new URLFetcher(GURL(WideToUTF16(server_url_)), | 1328 current_fetch_.reset(new URLFetcher(GURL(WideToUTF16(server_url_)), |
1329 URLFetcher::POST, | 1329 URLFetcher::POST, |
1330 this)); | 1330 this)); |
1331 current_fetch_->set_request_context(Profile::GetDefaultRequestContext()); | 1331 current_fetch_->set_request_context(Profile::GetDefaultRequestContext()); |
1332 current_fetch_->set_upload_data(kMetricsType, compressed_log_); | 1332 current_fetch_->set_upload_data(kMetricsType, compressed_log_); |
1333 } | 1333 } |
1334 | 1334 |
1335 static const char* StatusToString(const URLRequestStatus& status) { | 1335 static const char* StatusToString(const net::URLRequestStatus& status) { |
1336 switch (status.status()) { | 1336 switch (status.status()) { |
1337 case URLRequestStatus::SUCCESS: | 1337 case net::URLRequestStatus::SUCCESS: |
1338 return "SUCCESS"; | 1338 return "SUCCESS"; |
1339 | 1339 |
1340 case URLRequestStatus::IO_PENDING: | 1340 case net::URLRequestStatus::IO_PENDING: |
1341 return "IO_PENDING"; | 1341 return "IO_PENDING"; |
1342 | 1342 |
1343 case URLRequestStatus::HANDLED_EXTERNALLY: | 1343 case net::URLRequestStatus::HANDLED_EXTERNALLY: |
1344 return "HANDLED_EXTERNALLY"; | 1344 return "HANDLED_EXTERNALLY"; |
1345 | 1345 |
1346 case URLRequestStatus::CANCELED: | 1346 case net::URLRequestStatus::CANCELED: |
1347 return "CANCELED"; | 1347 return "CANCELED"; |
1348 | 1348 |
1349 case URLRequestStatus::FAILED: | 1349 case net::URLRequestStatus::FAILED: |
1350 return "FAILED"; | 1350 return "FAILED"; |
1351 | 1351 |
1352 default: | 1352 default: |
1353 NOTREACHED(); | 1353 NOTREACHED(); |
1354 return "Unknown"; | 1354 return "Unknown"; |
1355 } | 1355 } |
1356 } | 1356 } |
1357 | 1357 |
1358 void MetricsService::OnURLFetchComplete(const URLFetcher* source, | 1358 void MetricsService::OnURLFetchComplete(const URLFetcher* source, |
1359 const GURL& url, | 1359 const GURL& url, |
1360 const URLRequestStatus& status, | 1360 const net::URLRequestStatus& status, |
1361 int response_code, | 1361 int response_code, |
1362 const ResponseCookies& cookies, | 1362 const ResponseCookies& cookies, |
1363 const std::string& data) { | 1363 const std::string& data) { |
1364 DCHECK(timer_pending_); | 1364 DCHECK(timer_pending_); |
1365 timer_pending_ = false; | 1365 timer_pending_ = false; |
1366 DCHECK(current_fetch_.get()); | 1366 DCHECK(current_fetch_.get()); |
1367 current_fetch_.reset(NULL); // We're not allowed to re-use it. | 1367 current_fetch_.reset(NULL); // We're not allowed to re-use it. |
1368 | 1368 |
1369 // Confirm send so that we can move on. | 1369 // Confirm send so that we can move on. |
1370 VLOG(1) << "METRICS RESPONSE CODE: " << response_code | 1370 VLOG(1) << "METRICS RESPONSE CODE: " << response_code |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 thread_id = base::PlatformThread::CurrentId(); | 1908 thread_id = base::PlatformThread::CurrentId(); |
1909 return base::PlatformThread::CurrentId() == thread_id; | 1909 return base::PlatformThread::CurrentId() == thread_id; |
1910 } | 1910 } |
1911 | 1911 |
1912 #if defined(OS_CHROMEOS) | 1912 #if defined(OS_CHROMEOS) |
1913 void MetricsService::StartExternalMetrics() { | 1913 void MetricsService::StartExternalMetrics() { |
1914 external_metrics_ = new chromeos::ExternalMetrics; | 1914 external_metrics_ = new chromeos::ExternalMetrics; |
1915 external_metrics_->Start(); | 1915 external_metrics_->Start(); |
1916 } | 1916 } |
1917 #endif | 1917 #endif |
OLD | NEW |