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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 194099: Size the buffer used for the metrics log text properly.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « no previous file | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 6
7 //------------------------------------------------------------------------------ 7 //------------------------------------------------------------------------------
8 // Description of the life cycle of a instance of MetricsService. 8 // Description of the life cycle of a instance of MetricsService.
9 // 9 //
10 // OVERVIEW 10 // OVERVIEW
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 unsent_ongoing_logs->Clear(); 398 unsent_ongoing_logs->Clear();
399 } 399 }
400 400
401 MetricsService::MetricsService() 401 MetricsService::MetricsService()
402 : recording_active_(false), 402 : recording_active_(false),
403 reporting_active_(false), 403 reporting_active_(false),
404 user_permits_upload_(false), 404 user_permits_upload_(false),
405 server_permits_upload_(true), 405 server_permits_upload_(true),
406 state_(INITIALIZED), 406 state_(INITIALIZED),
407 pending_log_(NULL), 407 pending_log_(NULL),
408 pending_log_text_(""), 408 pending_log_text_(),
409 current_fetch_(NULL), 409 current_fetch_(NULL),
410 current_log_(NULL), 410 current_log_(NULL),
411 idle_since_last_transmission_(false), 411 idle_since_last_transmission_(false),
412 next_window_id_(0), 412 next_window_id_(0),
413 ALLOW_THIS_IN_INITIALIZER_LIST(log_sender_factory_(this)), 413 ALLOW_THIS_IN_INITIALIZER_LIST(log_sender_factory_(this)),
414 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)), 414 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)),
415 logged_samples_(), 415 logged_samples_(),
416 interlog_duration_(TimeDelta::FromSeconds(kInitialInterlogDuration)), 416 interlog_duration_(TimeDelta::FromSeconds(kInitialInterlogDuration)),
417 log_event_limit_(kInitialEventLimit), 417 log_event_limit_(kInitialEventLimit),
418 timer_pending_(false) { 418 timer_pending_(false) {
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 start = unsent_ongoing_logs_.size() - kMaxOngoingLogsPersisted; 1198 start = unsent_ongoing_logs_.size() - kMaxOngoingLogsPersisted;
1199 for (size_t i = start; i < unsent_ongoing_logs_.size(); ++i) 1199 for (size_t i = start; i < unsent_ongoing_logs_.size(); ++i)
1200 unsent_ongoing_logs->Append( 1200 unsent_ongoing_logs->Append(
1201 Value::CreateStringValue(unsent_ongoing_logs_[i])); 1201 Value::CreateStringValue(unsent_ongoing_logs_[i]));
1202 } 1202 }
1203 1203
1204 void MetricsService::PreparePendingLogText() { 1204 void MetricsService::PreparePendingLogText() {
1205 DCHECK(pending_log()); 1205 DCHECK(pending_log());
1206 if (!pending_log_text_.empty()) 1206 if (!pending_log_text_.empty())
1207 return; 1207 return;
1208 int original_size = pending_log_->GetEncodedLogSize(); 1208 int text_size = pending_log_->GetEncodedLogSize();
1209 pending_log_->GetEncodedLog(WriteInto(&pending_log_text_, original_size), 1209
1210 original_size); 1210 // Leave room for the NUL terminator.
1211 pending_log_->GetEncodedLog(WriteInto(&pending_log_text_, text_size + 1),
1212 text_size);
1211 } 1213 }
1212 1214
1213 void MetricsService::PrepareFetchWithPendingLog() { 1215 void MetricsService::PrepareFetchWithPendingLog() {
1214 DCHECK(pending_log()); 1216 DCHECK(pending_log());
1215 DCHECK(!current_fetch_.get()); 1217 DCHECK(!current_fetch_.get());
1216 PreparePendingLogText(); 1218 PreparePendingLogText();
1217 DCHECK(!pending_log_text_.empty()); 1219 DCHECK(!pending_log_text_.empty());
1218 1220
1219 // Allow security conscious users to see all metrics logs that we send. 1221 // Allow security conscious users to see all metrics logs that we send.
1220 LOG(INFO) << "METRICS LOG: " << pending_log_text_; 1222 LOG(INFO) << "METRICS LOG: " << pending_log_text_;
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 L"." + key; 1934 L"." + key;
1933 prof_prefs->SetInteger(pref_key.c_str(), value); 1935 prof_prefs->SetInteger(pref_key.c_str(), value);
1934 } 1936 }
1935 1937
1936 static bool IsSingleThreaded() { 1938 static bool IsSingleThreaded() {
1937 static PlatformThreadId thread_id = 0; 1939 static PlatformThreadId thread_id = 0;
1938 if (!thread_id) 1940 if (!thread_id)
1939 thread_id = PlatformThread::CurrentId(); 1941 thread_id = PlatformThread::CurrentId();
1940 return PlatformThread::CurrentId() == thread_id; 1942 return PlatformThread::CurrentId() == thread_id;
1941 } 1943 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698