| 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 // This file defines a service that collects information about the user | 5 // This file defines a service that collects information about the user |
| 6 // experience in order to help improve future versions of the app. | 6 // experience in order to help improve future versions of the app. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_METRICS_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_METRICS_SERVICE_H_ |
| 9 #define CHROME_BROWSER_METRICS_SERVICE_H_ | 9 #define CHROME_BROWSER_METRICS_SERVICE_H_ |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/histogram.h" | 18 #include "base/histogram.h" |
| 19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/metrics/metrics_log.h" | 21 #include "chrome/browser/metrics/metrics_log.h" |
| 22 #include "chrome/browser/net/url_fetcher.h" | 22 #include "chrome/browser/net/url_fetcher.h" |
| 23 #include "chrome/common/notification_observer.h" | 23 #include "chrome/common/notification_observer.h" |
| 24 #include "webkit/glue/webplugin.h" | 24 #include "webkit/glue/webplugin.h" |
| 25 | 25 |
| 26 class BookmarkModel; | 26 class BookmarkModel; |
| 27 class BookmarkNode; | 27 class BookmarkNode; |
| 28 class HistogramSynchronizer; |
| 28 class PrefService; | 29 class PrefService; |
| 29 class Profile; | 30 class Profile; |
| 30 class TemplateURLModel; | 31 class TemplateURLModel; |
| 31 | 32 |
| 32 // This is used to quickly log stats from child process related notifications in | 33 // This is used to quickly log stats from child process related notifications in |
| 33 // MetricsService::child_stats_buffer_. The buffer's contents are transferred | 34 // MetricsService::child_stats_buffer_. The buffer's contents are transferred |
| 34 // out when Local State is periodically saved. The information is then | 35 // out when Local State is periodically saved. The information is then |
| 35 // reported to the UMA server on next launch. | 36 // reported to the UMA server on next launch. |
| 36 struct ChildProcessStats { | 37 struct ChildProcessStats { |
| 37 public: | 38 public: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // Deletes pending_log_ and current_log_, and pushes their text into the | 189 // Deletes pending_log_ and current_log_, and pushes their text into the |
| 189 // appropriate unsent_log vectors. Called when Chrome shuts down. | 190 // appropriate unsent_log vectors. Called when Chrome shuts down. |
| 190 void PushPendingLogsToUnsentLists(); | 191 void PushPendingLogsToUnsentLists(); |
| 191 | 192 |
| 192 // Save the pending_log_text_ persistently in a pref for transmission when we | 193 // Save the pending_log_text_ persistently in a pref for transmission when we |
| 193 // next run. Note that IF this text is "too large," we just dicard it. | 194 // next run. Note that IF this text is "too large," we just dicard it. |
| 194 void PushPendingLogTextToUnsentOngoingLogs(); | 195 void PushPendingLogTextToUnsentOngoingLogs(); |
| 195 | 196 |
| 196 // Start timer for next log transmission. | 197 // Start timer for next log transmission. |
| 197 void StartLogTransmissionTimer(); | 198 void StartLogTransmissionTimer(); |
| 198 // Do not call TryToStartTransmission() directly. | 199 |
| 200 // Internal function to collect process memory information. |
| 201 void LogTransmissionTimerDone(); |
| 202 |
| 203 // Do not call OnMemoryDetailCollectionDone() or |
| 204 // OnHistogramSynchronizationDone() directly. |
| 199 // Use StartLogTransmissionTimer() to schedule a call. | 205 // Use StartLogTransmissionTimer() to schedule a call. |
| 200 void TryToStartTransmission(); | 206 void OnMemoryDetailCollectionDone(); |
| 207 void OnHistogramSynchronizationDone(); |
| 201 | 208 |
| 202 // Takes whatever log should be uploaded next (according to the state_) | 209 // Takes whatever log should be uploaded next (according to the state_) |
| 203 // and makes it the pending log. If pending_log_ is not NULL, | 210 // and makes it the pending log. If pending_log_ is not NULL, |
| 204 // MakePendingLog does nothing and returns. | 211 // MakePendingLog does nothing and returns. |
| 205 void MakePendingLog(); | 212 void MakePendingLog(); |
| 206 | 213 |
| 207 // Determines from state_ and permissions set out by the server and by | 214 // Determines from state_ and permissions set out by the server and by |
| 208 // the user whether the pending_log_ should be sent or discarded. Called by | 215 // the user whether the pending_log_ should be sent or discarded. Called by |
| 209 // TryToStartTransmission. | 216 // TryToStartTransmission. |
| 210 bool TransmissionPermitted() const; | 217 bool TransmissionPermitted() const; |
| 211 | 218 |
| 212 // Internal function to collect process memory information. | |
| 213 void CollectMemoryDetails(); | |
| 214 | |
| 215 // Check to see if there is a log that needs to be, or is being, transmitted. | 219 // Check to see if there is a log that needs to be, or is being, transmitted. |
| 216 bool pending_log() const { | 220 bool pending_log() const { |
| 217 return pending_log_ || !pending_log_text_.empty(); | 221 return pending_log_ || !pending_log_text_.empty(); |
| 218 } | 222 } |
| 219 // Check to see if there are any unsent logs from previous sessions. | 223 // Check to see if there are any unsent logs from previous sessions. |
| 220 bool unsent_logs() const { | 224 bool unsent_logs() const { |
| 221 return !unsent_initial_logs_.empty() || !unsent_ongoing_logs_.empty(); | 225 return !unsent_initial_logs_.empty() || !unsent_ongoing_logs_.empty(); |
| 222 } | 226 } |
| 223 // Record stats, client ID, Session ID, etc. in a special "first" log. | 227 // Record stats, client ID, Session ID, etc. in a special "first" log. |
| 224 void PrepareInitialLog(); | 228 void PrepareInitialLog(); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 std::set<std::string> histograms_to_upload_; | 478 std::set<std::string> histograms_to_upload_; |
| 475 std::set<std::string> histograms_to_omit_; | 479 std::set<std::string> histograms_to_omit_; |
| 476 | 480 |
| 477 // Indicate that a timer for sending the next log has already been queued. | 481 // Indicate that a timer for sending the next log has already been queued. |
| 478 bool timer_pending_; | 482 bool timer_pending_; |
| 479 | 483 |
| 480 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 484 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
| 481 }; | 485 }; |
| 482 | 486 |
| 483 #endif // CHROME_BROWSER_METRICS_SERVICE_H_ | 487 #endif // CHROME_BROWSER_METRICS_SERVICE_H_ |
| OLD | NEW |