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

Side by Side Diff: chrome_frame/metrics_service.cc

Issue 9232071: Upload UMA data using protocol buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/pref_names.cc ('k') | no next file » | 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 //------------------------------------------------------------------------------ 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 created at ChromeFrame startup in 10 // A MetricsService instance is created at ChromeFrame startup in
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 DCHECK(log_manager_.has_staged_log()); 413 DCHECK(log_manager_.has_staged_log());
414 } 414 }
415 415
416 bool MetricsService::TransmissionPermitted() const { 416 bool MetricsService::TransmissionPermitted() const {
417 // If the user forbids uploading that's their business, and we don't upload 417 // If the user forbids uploading that's their business, and we don't upload
418 // anything. 418 // anything.
419 return user_permits_upload_; 419 return user_permits_upload_;
420 } 420 }
421 421
422 // TODO(isherman): Update this to log to the protobuf server as well...
423 // http://crbug.com/109817
422 bool MetricsService::UploadData() { 424 bool MetricsService::UploadData() {
423 DCHECK_EQ(thread_, base::PlatformThread::CurrentId()); 425 DCHECK_EQ(thread_, base::PlatformThread::CurrentId());
424 426
425 if (!GetInstance()->TransmissionPermitted()) 427 if (!GetInstance()->TransmissionPermitted())
426 return false; 428 return false;
427 429
428 static long currently_uploading = 0; 430 static long currently_uploading = 0;
429 if (InterlockedCompareExchange(&currently_uploading, 1, 0)) { 431 if (InterlockedCompareExchange(&currently_uploading, 1, 0)) {
430 DVLOG(1) << "Contention for uploading metrics data. Backing off"; 432 DVLOG(1) << "Contention for uploading metrics data. Backing off";
431 return false; 433 return false;
432 } 434 }
433 435
434 MakePendingLog(); 436 MakePendingLog();
435 DCHECK(log_manager_.has_staged_log()); 437 DCHECK(log_manager_.has_staged_log());
436 438
437 bool ret = true; 439 bool ret = true;
438 440
439 if (log_manager_.staged_log_text().empty()) { 441 if (log_manager_.staged_log_text().empty()) {
440 NOTREACHED() << "Failed to compress log for transmission."; 442 NOTREACHED() << "Failed to compress log for transmission.";
441 ret = false; 443 ret = false;
442 } else { 444 } else {
443 HRESULT hr = ChromeFrameMetricsDataUploader::UploadDataHelper( 445 HRESULT hr = ChromeFrameMetricsDataUploader::UploadDataHelper(
444 log_manager_.staged_log_text()); 446 log_manager_.staged_log_text().xml);
445 DCHECK(SUCCEEDED(hr)); 447 DCHECK(SUCCEEDED(hr));
446 } 448 }
447 log_manager_.DiscardStagedLog(); 449 log_manager_.DiscardStagedLog();
448 450
449 currently_uploading = 0; 451 currently_uploading = 0;
450 return ret; 452 return ret;
451 } 453 }
452 454
453 // static 455 // static
454 std::string MetricsService::GetVersionString() { 456 std::string MetricsService::GetVersionString() {
455 chrome::VersionInfo version_info; 457 chrome::VersionInfo version_info;
456 if (version_info.is_valid()) { 458 if (version_info.is_valid()) {
457 std::string version = version_info.Version(); 459 std::string version = version_info.Version();
458 // Add the -F extensions to ensure that UMA data uploaded by ChromeFrame 460 // Add the -F extensions to ensure that UMA data uploaded by ChromeFrame
459 // lands in the ChromeFrame bucket. 461 // lands in the ChromeFrame bucket.
460 version += "-F"; 462 version += "-F";
461 if (!version_info.IsOfficialBuild()) 463 if (!version_info.IsOfficialBuild())
462 version.append("-devel"); 464 version.append("-devel");
463 return version; 465 return version;
464 } else { 466 } else {
465 NOTREACHED() << "Unable to retrieve version string."; 467 NOTREACHED() << "Unable to retrieve version string.";
466 } 468 }
467 469
468 return std::string(); 470 return std::string();
469 } 471 }
OLDNEW
« no previous file with comments | « chrome/common/pref_names.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698