summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 01:54:52 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 01:54:52 +0000
commitbdc10063ed1ae1d8941f7dcb43bc5e4b6fbf6d60 (patch)
tree4de087f7a9576e7be0e42079cea9f57d9f8a92fe /chrome/browser
parent646228a9066b7a3ad0c3a1b346f0e634e137fe71 (diff)
downloadchromium_src-bdc10063ed1ae1d8941f7dcb43bc5e4b6fbf6d60.zip
chromium_src-bdc10063ed1ae1d8941f7dcb43bc5e4b6fbf6d60.tar.gz
chromium_src-bdc10063ed1ae1d8941f7dcb43bc5e4b6fbf6d60.tar.bz2
contacts: Add histograms.
Adds UMA histograms to report stats for GDataContactsService and ContactDatabase. BUG=128805 TEST=none Review URL: https://chromiumcodereview.appspot.com/10868021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/contacts/contact_database.cc51
-rw-r--r--chrome/browser/chromeos/gdata/gdata_contacts_service.cc94
2 files changed, 137 insertions, 8 deletions
diff --git a/chrome/browser/chromeos/contacts/contact_database.cc b/chrome/browser/chromeos/contacts/contact_database.cc
index efe3a3d..4452f14 100644
--- a/chrome/browser/chromeos/contacts/contact_database.cc
+++ b/chrome/browser/chromeos/contacts/contact_database.cc
@@ -7,6 +7,7 @@
#include <set>
#include "base/file_util.h"
+#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/chromeos/contacts/contact.pb.h"
@@ -24,6 +25,30 @@ namespace contacts {
namespace {
+// Initialization results reported via the "Contacts.DatabaseInitResult"
+// histogram.
+enum HistogramInitResult {
+ HISTOGRAM_INIT_RESULT_SUCCESS = 0,
+ HISTOGRAM_INIT_RESULT_FAILURE = 1,
+ HISTOGRAM_INIT_RESULT_DELETED_CORRUPTED = 2,
+ HISTOGRAM_INIT_RESULT_MAX_VALUE = 3,
+};
+
+// Save results reported via the "Contacts.DatabaseSaveResult" histogram.
+enum HistogramSaveResult {
+ HISTOGRAM_SAVE_RESULT_SUCCESS = 0,
+ HISTOGRAM_SAVE_RESULT_FAILURE = 1,
+ HISTOGRAM_SAVE_RESULT_MAX_VALUE = 2,
+};
+
+// Load results reported via the "Contacts.DatabaseLoadResult" histogram.
+enum HistogramLoadResult {
+ HISTOGRAM_LOAD_RESULT_SUCCESS = 0,
+ HISTOGRAM_LOAD_RESULT_METADATA_PARSE_FAILURE = 1,
+ HISTOGRAM_LOAD_RESULT_CONTACT_PARSE_FAILURE = 2,
+ HISTOGRAM_LOAD_RESULT_MAX_VALUE = 3,
+};
+
// LevelDB key used for storing UpdateMetadata messages.
const char kUpdateMetadataKey[] = "__chrome_update_metadata__";
@@ -145,9 +170,12 @@ void ContactDatabase::InitFromTaskRunner(const FilePath& database_dir,
bool* success) {
DCHECK(IsRunByTaskRunner());
DCHECK(success);
- VLOG(1) << "Opening " << database_dir.value();
+ VLOG(1) << "Opening " << database_dir.value();
+ UMA_HISTOGRAM_MEMORY_KB("Contacts.DatabaseSizeBytes",
+ file_util::ComputeDirectorySize(database_dir));
*success = false;
+ HistogramInitResult histogram_result = HISTOGRAM_INIT_RESULT_SUCCESS;
leveldb::Options options;
options.create_if_missing = true;
@@ -172,10 +200,16 @@ void ContactDatabase::InitFromTaskRunner(const FilePath& database_dir,
LOG(WARNING) << "Deleting possibly-corrupt database";
file_util::Delete(database_dir, true);
delete_and_retry_on_corruption = false;
+ histogram_result = HISTOGRAM_INIT_RESULT_DELETED_CORRUPTED;
} else {
+ histogram_result = HISTOGRAM_INIT_RESULT_FAILURE;
break;
}
}
+
+ UMA_HISTOGRAM_ENUMERATION("Contacts.DatabaseInitResult",
+ histogram_result,
+ HISTOGRAM_INIT_RESULT_MAX_VALUE);
}
void ContactDatabase::SaveContactsFromTaskRunner(
@@ -240,6 +274,12 @@ void ContactDatabase::SaveContactsFromTaskRunner(
*success = true;
else
LOG(WARNING) << "Failed writing contacts: " << status.ToString();
+
+ UMA_HISTOGRAM_ENUMERATION("Contacts.DatabaseSaveResult",
+ *success ?
+ HISTOGRAM_SAVE_RESULT_SUCCESS :
+ HISTOGRAM_SAVE_RESULT_FAILURE,
+ HISTOGRAM_SAVE_RESULT_MAX_VALUE);
}
void ContactDatabase::LoadContactsFromTaskRunner(
@@ -264,6 +304,9 @@ void ContactDatabase::LoadContactsFromTaskRunner(
if (db_iterator->key().ToString() == kUpdateMetadataKey) {
if (!metadata->ParseFromArray(value_slice.data(), value_slice.size())) {
LOG(WARNING) << "Unable to parse metadata";
+ UMA_HISTOGRAM_ENUMERATION("Contacts.DatabaseLoadResult",
+ HISTOGRAM_LOAD_RESULT_METADATA_PARSE_FAILURE,
+ HISTOGRAM_LOAD_RESULT_MAX_VALUE);
return;
}
} else {
@@ -271,6 +314,9 @@ void ContactDatabase::LoadContactsFromTaskRunner(
if (!contact->ParseFromArray(value_slice.data(), value_slice.size())) {
LOG(WARNING) << "Unable to parse contact "
<< db_iterator->key().ToString();
+ UMA_HISTOGRAM_ENUMERATION("Contacts.DatabaseLoadResult",
+ HISTOGRAM_LOAD_RESULT_CONTACT_PARSE_FAILURE,
+ HISTOGRAM_LOAD_RESULT_MAX_VALUE);
return;
}
contacts->push_back(contact.release());
@@ -279,6 +325,9 @@ void ContactDatabase::LoadContactsFromTaskRunner(
}
*success = true;
+ UMA_HISTOGRAM_ENUMERATION("Contacts.DatabaseLoadResult",
+ HISTOGRAM_LOAD_RESULT_SUCCESS,
+ HISTOGRAM_LOAD_RESULT_MAX_VALUE);
}
} // namespace contacts
diff --git a/chrome/browser/chromeos/gdata/gdata_contacts_service.cc b/chrome/browser/chromeos/gdata/gdata_contacts_service.cc
index b1bca73..b8ef3f4 100644
--- a/chrome/browser/chromeos/gdata/gdata_contacts_service.cc
+++ b/chrome/browser/chromeos/gdata/gdata_contacts_service.cc
@@ -13,6 +13,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/string_util.h"
#include "base/time.h"
@@ -31,6 +32,19 @@ namespace gdata {
namespace {
+// Download outcomes reported via the "Contacts.FullUpdateResult" and
+// "Contacts.IncrementalUpdateResult" histograms.
+enum HistogramResult {
+ HISTOGRAM_RESULT_SUCCESS = 0,
+ HISTOGRAM_RESULT_GROUPS_DOWNLOAD_FAILURE = 1,
+ HISTOGRAM_RESULT_GROUPS_PARSE_FAILURE = 2,
+ HISTOGRAM_RESULT_MY_CONTACTS_GROUP_NOT_FOUND = 3,
+ HISTOGRAM_RESULT_CONTACTS_DOWNLOAD_FAILURE = 4,
+ HISTOGRAM_RESULT_CONTACTS_PARSE_FAILURE = 5,
+ HISTOGRAM_RESULT_PHOTO_DOWNLOAD_FAILURE = 6,
+ HISTOGRAM_RESULT_MAX_VALUE = 7,
+};
+
// Maximum number of profile photos that we'll download per second.
// At values above 10, Google starts returning 503 errors.
const int kMaxPhotoDownloadsPerSecond = 10;
@@ -431,6 +445,8 @@ class GDataContactsService::DownloadContactsRequest {
my_contacts_group_id_(service->cached_my_contacts_group_id_),
num_in_progress_photo_downloads_(0),
photo_download_failed_(false),
+ num_photo_download_404_errors_(0),
+ total_photo_bytes_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(service_);
@@ -452,6 +468,7 @@ class GDataContactsService::DownloadContactsRequest {
// Otherwise, the contact groups download is started.
void Run() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ download_start_time_ = base::TimeTicks::Now();
if (!my_contacts_group_id_.empty()) {
StartContactsDownload();
} else {
@@ -471,12 +488,63 @@ class GDataContactsService::DownloadContactsRequest {
private:
// Invokes the failure callback and notifies GDataContactsService that the
// request is done.
- void ReportFailure() {
+ void ReportFailure(HistogramResult histogram_result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ SendHistograms(histogram_result);
failure_callback_.Run();
service_->OnRequestComplete(this);
}
+ // Reports UMA stats after the request has completed.
+ void SendHistograms(HistogramResult result) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_GE(result, 0);
+ DCHECK_LT(result, HISTOGRAM_RESULT_MAX_VALUE);
+
+ bool success = (result == HISTOGRAM_RESULT_SUCCESS);
+ base::TimeDelta elapsed_time =
+ base::TimeTicks::Now() - download_start_time_;
+ int photo_error_percent = static_cast<int>(
+ 100.0 * transient_photo_download_errors_per_contact_.size() /
+ contact_photo_urls_.size() + 0.5);
+
+ if (min_update_time_.is_null()) {
+ UMA_HISTOGRAM_ENUMERATION("Contacts.FullUpdateResult",
+ result, HISTOGRAM_RESULT_MAX_VALUE);
+ if (success) {
+ UMA_HISTOGRAM_MEDIUM_TIMES("Contacts.FullUpdateDuration",
+ elapsed_time);
+ UMA_HISTOGRAM_COUNTS_10000("Contacts.FullUpdateContacts",
+ contacts_->size());
+ UMA_HISTOGRAM_COUNTS_10000("Contacts.FullUpdatePhotos",
+ contact_photo_urls_.size());
+ UMA_HISTOGRAM_MEMORY_KB("Contacts.FullUpdatePhotoBytes",
+ total_photo_bytes_);
+ UMA_HISTOGRAM_COUNTS_10000("Contacts.FullUpdatePhoto404Errors",
+ num_photo_download_404_errors_);
+ UMA_HISTOGRAM_PERCENTAGE("Contacts.FullUpdatePhotoErrorPercent",
+ photo_error_percent);
+ }
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("Contacts.IncrementalUpdateResult",
+ result, HISTOGRAM_RESULT_MAX_VALUE);
+ if (success) {
+ UMA_HISTOGRAM_MEDIUM_TIMES("Contacts.IncrementalUpdateDuration",
+ elapsed_time);
+ UMA_HISTOGRAM_COUNTS_10000("Contacts.IncrementalUpdateContacts",
+ contacts_->size());
+ UMA_HISTOGRAM_COUNTS_10000("Contacts.IncrementalUpdatePhotos",
+ contact_photo_urls_.size());
+ UMA_HISTOGRAM_MEMORY_KB("Contacts.IncrementalUpdatePhotoBytes",
+ total_photo_bytes_);
+ UMA_HISTOGRAM_COUNTS_10000("Contacts.IncrementalUpdatePhoto404Errors",
+ num_photo_download_404_errors_);
+ UMA_HISTOGRAM_PERCENTAGE("Contacts.IncrementalUpdatePhotoErrorPercent",
+ photo_error_percent);
+ }
+ }
+ }
+
// Callback for GetContactGroupsOperation calls. Starts downloading the
// actual contacts after finding the "My Contacts" group ID.
void HandleGroupsFeedData(GDataErrorCode error,
@@ -484,7 +552,7 @@ class GDataContactsService::DownloadContactsRequest {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (error != HTTP_SUCCESS) {
LOG(WARNING) << "Got error " << error << " while downloading groups";
- ReportFailure();
+ ReportFailure(HISTOGRAM_RESULT_GROUPS_DOWNLOAD_FAILURE);
return;
}
@@ -494,7 +562,7 @@ class GDataContactsService::DownloadContactsRequest {
base::JSONValueConverter<ContactGroups> converter;
if (!converter.Convert(*feed_data, &groups)) {
LOG(WARNING) << "Unable to parse groups feed";
- ReportFailure();
+ ReportFailure(HISTOGRAM_RESULT_GROUPS_PARSE_FAILURE);
return;
}
@@ -504,7 +572,7 @@ class GDataContactsService::DownloadContactsRequest {
StartContactsDownload();
} else {
LOG(WARNING) << "Unable to find ID for \"My Contacts\" group";
- ReportFailure();
+ ReportFailure(HISTOGRAM_RESULT_MY_CONTACTS_GROUP_NOT_FOUND);
}
}
@@ -531,7 +599,7 @@ class GDataContactsService::DownloadContactsRequest {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (error != HTTP_SUCCESS) {
LOG(WARNING) << "Got error " << error << " while downloading contacts";
- ReportFailure();
+ ReportFailure(HISTOGRAM_RESULT_CONTACTS_DOWNLOAD_FAILURE);
return;
}
@@ -539,7 +607,7 @@ class GDataContactsService::DownloadContactsRequest {
<< PrettyPrintValue(*(feed_data.get()));
if (!ProcessContactsFeedData(*feed_data.get())) {
LOG(WARNING) << "Unable to process contacts feed data";
- ReportFailure();
+ ReportFailure(HISTOGRAM_RESULT_CONTACTS_PARSE_FAILURE);
return;
}
@@ -643,8 +711,9 @@ class GDataContactsService::DownloadContactsRequest {
VLOG(1) << "Done downloading photos; invoking callback";
photo_download_timer_.Stop();
if (photo_download_failed_) {
- ReportFailure();
+ ReportFailure(HISTOGRAM_RESULT_PHOTO_DOWNLOAD_FAILURE );
} else {
+ SendHistograms(HISTOGRAM_RESULT_SUCCESS);
success_callback_.Run(contacts_.Pass());
service_->OnRequestComplete(this);
}
@@ -701,6 +770,7 @@ class GDataContactsService::DownloadContactsRequest {
if (error == HTTP_NOT_FOUND) {
LOG(WARNING) << "Got error " << error << " while downloading photo "
<< "for " << contact->contact_id() << "; skipping";
+ num_photo_download_404_errors_++;
CheckCompletion();
return;
}
@@ -715,6 +785,7 @@ class GDataContactsService::DownloadContactsRequest {
return;
}
+ total_photo_bytes_ += download_data->size();
contact->set_raw_untrusted_photo(*download_data);
CheckCompletion();
}
@@ -757,6 +828,15 @@ class GDataContactsService::DownloadContactsRequest {
// Did we encounter a fatal error while downloading a photo?
bool photo_download_failed_;
+ // How many photos did we skip due to 404 errors?
+ int num_photo_download_404_errors_;
+
+ // Total size of all photos that were downloaded.
+ size_t total_photo_bytes_;
+
+ // Time at which Run() was called.
+ base::TimeTicks download_start_time_;
+
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<DownloadContactsRequest> weak_ptr_factory_;