summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 22:49:27 +0000
committerjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 22:49:27 +0000
commit29be92554d590f4199fcc19037427fc171025441 (patch)
tree6b6ba8625ecb544300275c11b4e7939941200b3b /chrome
parenta31e79ede77e871153e74aac437c75f9c95603cb (diff)
downloadchromium_src-29be92554d590f4199fcc19037427fc171025441.zip
chromium_src-29be92554d590f4199fcc19037427fc171025441.tar.gz
chromium_src-29be92554d590f4199fcc19037427fc171025441.tar.bz2
Save memory prefs to disks more often
The goal is to reduce the window where it is possible that a crash of Chrome will cause double counting of prior crashes. This change records all the (hopefully consistent) memory-resident state of the metrics service to disk as soon as we get an ack from UMA that a log was received. Without this, there is a possible gap between when the stats are copied to a log, and sent, vs. when the (now) zeroed crash count is written to disk. bug=1314946 r=evanm,petersont git-svn-id: svn://svn.chromium.org/chrome/trunk/src@543 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/metrics_service.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/chrome/browser/metrics_service.cc b/chrome/browser/metrics_service.cc
index 5779063..268e57d 100644
--- a/chrome/browser/metrics_service.cc
+++ b/chrome/browser/metrics_service.cc
@@ -1043,11 +1043,16 @@ void MetricsService::OnURLFetchComplete(const URLFetcher* source,
}
DLOG(INFO) << "METRICS RESPONSE DATA: " << data;
DiscardPendingLog();
+ // Since we sent a log, make sure our in-memory state is recorded to disk.
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
+ if (local_state)
+ local_state->ScheduleSavePersistentPrefs(
+ g_browser_process->file_thread());
GetSettingsFromResponseData(data);
-
// Override server specified interlog delay if there are unsent logs to
- // transmit
+ // transmit.
if (unsent_logs()) {
DCHECK(state_ < SENDING_CURRENT_LOGS);
interlog_duration_ = TimeDelta::FromSeconds(kUnsentLogDelay);
@@ -1090,7 +1095,7 @@ void MetricsService::GetSettingsFromResponseData(const std::string& data) {
DLOG(INFO) << data;
int data_size = static_cast<int>(data.size());
if (data_size < 0) {
- DLOG(INFO) << "METRICS: server response data bad size " <<
+ DLOG(INFO) << "METRICS: server response data bad size " <<
" aborting extraction of settings";
return;
}
@@ -1120,7 +1125,6 @@ void MetricsService::GetSettingsFromConfigNode(xmlNodePtr config_node) {
for (xmlNodePtr current_node = config_node->children;
current_node;
current_node = current_node->next) {
-
// If the node is collectors list, we iterate through the children
// to get the types of collectors.
if (xmlStrEqual(current_node->name, BAD_CAST "collectors")) {
@@ -1146,7 +1150,7 @@ void MetricsService::GetSettingsFromConfigNode(xmlNodePtr config_node) {
if (xmlStrEqual(current_node->name, BAD_CAST "upload")) {
xmlChar* upload_interval_val = xmlGetProp(current_node,
BAD_CAST "interval");
- int upload_interval_sec =
+ int upload_interval_sec =
atoi(reinterpret_cast<char*>(upload_interval_val));
interlog_duration_ = TimeDelta::FromSeconds(upload_interval_sec);
continue;