OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 } | 729 } |
730 } | 730 } |
731 | 731 |
732 void MetricsService::StopRecording(MetricsLog** log) { | 732 void MetricsService::StopRecording(MetricsLog** log) { |
733 if (!current_log_) | 733 if (!current_log_) |
734 return; | 734 return; |
735 | 735 |
736 // TODO(jar): Integrate bounds on log recording more consistently, so that we | 736 // TODO(jar): Integrate bounds on log recording more consistently, so that we |
737 // can stop recording logs that are too big much sooner. | 737 // can stop recording logs that are too big much sooner. |
738 if (current_log_->num_events() > log_event_limit_) { | 738 if (current_log_->num_events() > log_event_limit_) { |
739 UMA_HISTOGRAM_COUNTS(L"UMA.Discarded Log Events", | 739 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events", |
740 current_log_->num_events()); | 740 current_log_->num_events()); |
741 current_log_->CloseLog(); | 741 current_log_->CloseLog(); |
742 delete current_log_; | 742 delete current_log_; |
743 current_log_ = NULL; | 743 current_log_ = NULL; |
744 StartRecording(); // Start trivial log to hold our histograms. | 744 StartRecording(); // Start trivial log to hold our histograms. |
745 } | 745 } |
746 | 746 |
747 // Put incremental data (histogram deltas, and realtime stats deltas) at the | 747 // Put incremental data (histogram deltas, and realtime stats deltas) at the |
748 // end of all log transmissions (initial log handles this separately). | 748 // end of all log transmissions (initial log handles this separately). |
749 // Don't bother if we're going to discard current_log_. | 749 // Don't bother if we're going to discard current_log_. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 } | 826 } |
827 | 827 |
828 void MetricsService::PushPendingLogTextToUnsentOngoingLogs() { | 828 void MetricsService::PushPendingLogTextToUnsentOngoingLogs() { |
829 // If UMA response told us not to upload, there's no need to save the pending | 829 // If UMA response told us not to upload, there's no need to save the pending |
830 // log. It wasn't supposed to be uploaded anyway. | 830 // log. It wasn't supposed to be uploaded anyway. |
831 if (!server_permits_upload_) | 831 if (!server_permits_upload_) |
832 return; | 832 return; |
833 | 833 |
834 if (pending_log_text_.length() > | 834 if (pending_log_text_.length() > |
835 static_cast<size_t>(kUploadLogAvoidRetransmitSize)) { | 835 static_cast<size_t>(kUploadLogAvoidRetransmitSize)) { |
836 UMA_HISTOGRAM_COUNTS(L"UMA.Large Accumulated Log Not Persisted", | 836 UMA_HISTOGRAM_COUNTS("UMA.Large Accumulated Log Not Persisted", |
837 static_cast<int>(pending_log_text_.length())); | 837 static_cast<int>(pending_log_text_.length())); |
838 return; | 838 return; |
839 } | 839 } |
840 unsent_ongoing_logs_.push_back(pending_log_text_); | 840 unsent_ongoing_logs_.push_back(pending_log_text_); |
841 } | 841 } |
842 | 842 |
843 //------------------------------------------------------------------------------ | 843 //------------------------------------------------------------------------------ |
844 // Transmission of logs methods | 844 // Transmission of logs methods |
845 | 845 |
846 void MetricsService::StartLogTransmissionTimer() { | 846 void MetricsService::StartLogTransmissionTimer() { |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 // Confirm send so that we can move on. | 1219 // Confirm send so that we can move on. |
1220 LOG(INFO) << "METRICS RESPONSE CODE: " << response_code << " status=" << | 1220 LOG(INFO) << "METRICS RESPONSE CODE: " << response_code << " status=" << |
1221 StatusToString(status); | 1221 StatusToString(status); |
1222 | 1222 |
1223 // Provide boolean for error recovery (allow us to ignore response_code). | 1223 // Provide boolean for error recovery (allow us to ignore response_code). |
1224 bool discard_log = false; | 1224 bool discard_log = false; |
1225 | 1225 |
1226 if (response_code != 200 && | 1226 if (response_code != 200 && |
1227 pending_log_text_.length() > | 1227 pending_log_text_.length() > |
1228 static_cast<size_t>(kUploadLogAvoidRetransmitSize)) { | 1228 static_cast<size_t>(kUploadLogAvoidRetransmitSize)) { |
1229 UMA_HISTOGRAM_COUNTS(L"UMA.Large Rejected Log was Discarded", | 1229 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded", |
1230 static_cast<int>(pending_log_text_.length())); | 1230 static_cast<int>(pending_log_text_.length())); |
1231 discard_log = true; | 1231 discard_log = true; |
1232 } else if (response_code == 400) { | 1232 } else if (response_code == 400) { |
1233 // Bad syntax. Retransmission won't work. | 1233 // Bad syntax. Retransmission won't work. |
1234 UMA_HISTOGRAM_COUNTS(L"UMA.Unacceptable_Log_Discarded", state_); | 1234 UMA_HISTOGRAM_COUNTS("UMA.Unacceptable_Log_Discarded", state_); |
1235 discard_log = true; | 1235 discard_log = true; |
1236 } | 1236 } |
1237 | 1237 |
1238 if (response_code != 200 && !discard_log) { | 1238 if (response_code != 200 && !discard_log) { |
1239 LOG(INFO) << "METRICS: transmission attempt returned a failure code: " | 1239 LOG(INFO) << "METRICS: transmission attempt returned a failure code: " |
1240 << response_code << ". Verify network connectivity"; | 1240 << response_code << ". Verify network connectivity"; |
1241 HandleBadResponseCode(); | 1241 HandleBadResponseCode(); |
1242 } else { // Successful receipt (or we are discarding log). | 1242 } else { // Successful receipt (or we are discarding log). |
1243 LOG(INFO) << "METRICS RESPONSE DATA: " << data; | 1243 LOG(INFO) << "METRICS RESPONSE DATA: " << data; |
1244 switch (state_) { | 1244 switch (state_) { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 } | 1535 } |
1536 | 1536 |
1537 void MetricsService::LogLoadComplete(NotificationType type, | 1537 void MetricsService::LogLoadComplete(NotificationType type, |
1538 const NotificationSource& source, | 1538 const NotificationSource& source, |
1539 const NotificationDetails& details) { | 1539 const NotificationDetails& details) { |
1540 if (details == NotificationService::NoDetails()) | 1540 if (details == NotificationService::NoDetails()) |
1541 return; | 1541 return; |
1542 | 1542 |
1543 // TODO(jar): There is a bug causing this to be called too many times, and | 1543 // TODO(jar): There is a bug causing this to be called too many times, and |
1544 // the log overflows. For now, we won't record these events. | 1544 // the log overflows. For now, we won't record these events. |
1545 UMA_HISTOGRAM_COUNTS(L"UMA.LogLoadComplete called", 1); | 1545 UMA_HISTOGRAM_COUNTS("UMA.LogLoadComplete called", 1); |
1546 return; | 1546 return; |
1547 | 1547 |
1548 const Details<LoadNotificationDetails> load_details(details); | 1548 const Details<LoadNotificationDetails> load_details(details); |
1549 int controller_id = window_map_[details.map_key()]; | 1549 int controller_id = window_map_[details.map_key()]; |
1550 current_log_->RecordLoadEvent(controller_id, | 1550 current_log_->RecordLoadEvent(controller_id, |
1551 load_details->url(), | 1551 load_details->url(), |
1552 load_details->origin(), | 1552 load_details->origin(), |
1553 load_details->session_index(), | 1553 load_details->session_index(), |
1554 load_details->load_time()); | 1554 load_details->load_time()); |
1555 } | 1555 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 L"." + key; | 1824 L"." + key; |
1825 prof_prefs->SetInteger(pref_key.c_str(), value); | 1825 prof_prefs->SetInteger(pref_key.c_str(), value); |
1826 } | 1826 } |
1827 | 1827 |
1828 static bool IsSingleThreaded() { | 1828 static bool IsSingleThreaded() { |
1829 static PlatformThreadId thread_id = 0; | 1829 static PlatformThreadId thread_id = 0; |
1830 if (!thread_id) | 1830 if (!thread_id) |
1831 thread_id = PlatformThread::CurrentId(); | 1831 thread_id = PlatformThread::CurrentId(); |
1832 return PlatformThread::CurrentId() == thread_id; | 1832 return PlatformThread::CurrentId() == thread_id; |
1833 } | 1833 } |
OLD | NEW |