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_registrar.h" | 23 #include "chrome/common/notification_registrar.h" |
24 #include "webkit/glue/webplugin.h" | 24 #include "webkit/glue/webplugin.h" |
| 25 #include "testing/gtest/include/gtest/gtest_prod.h" |
25 | 26 |
26 class BookmarkModel; | 27 class BookmarkModel; |
27 class BookmarkNode; | 28 class BookmarkNode; |
28 class HistogramSynchronizer; | 29 class HistogramSynchronizer; |
29 class PrefService; | 30 class PrefService; |
30 class Profile; | 31 class Profile; |
31 class TemplateURLModel; | 32 class TemplateURLModel; |
32 | 33 |
33 // This is used to quickly log stats from child process related notifications in | 34 // This is used to quickly log stats from child process related notifications in |
34 // MetricsService::child_stats_buffer_. The buffer's contents are transferred | 35 // MetricsService::child_stats_buffer_. The buffer's contents are transferred |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // idle_since_last_transmission to false and starts the timer (provided | 154 // idle_since_last_transmission to false and starts the timer (provided |
154 // starting the timer is permitted). | 155 // starting the timer is permitted). |
155 void HandleIdleSinceLastTransmission(bool in_idle); | 156 void HandleIdleSinceLastTransmission(bool in_idle); |
156 | 157 |
157 // Set up client ID, session ID, etc. | 158 // Set up client ID, session ID, etc. |
158 void InitializeMetricsState(); | 159 void InitializeMetricsState(); |
159 | 160 |
160 // Generates a new client ID to use to identify self to metrics server. | 161 // Generates a new client ID to use to identify self to metrics server. |
161 static std::string GenerateClientID(); | 162 static std::string GenerateClientID(); |
162 | 163 |
| 164 #if defined(OS_POSIX) |
| 165 // Generates a new client ID to use to identify self to metrics server, |
| 166 // given 128 bits of randomness. |
| 167 static std::string RandomBytesToGUIDString(const uint64 bytes[2]); |
| 168 #endif |
| 169 |
163 // Schedule the next save of LocalState information. This is called | 170 // Schedule the next save of LocalState information. This is called |
164 // automatically by the task that performs each save to schedule the next one. | 171 // automatically by the task that performs each save to schedule the next one. |
165 void ScheduleNextStateSave(); | 172 void ScheduleNextStateSave(); |
166 | 173 |
167 // Save the LocalState information immediately. This should not be called by | 174 // Save the LocalState information immediately. This should not be called by |
168 // anybody other than the scheduler to avoid doing too many writes. When you | 175 // anybody other than the scheduler to avoid doing too many writes. When you |
169 // make a change, call ScheduleNextStateSave() instead. | 176 // make a change, call ScheduleNextStateSave() instead. |
170 void SaveLocalState(); | 177 void SaveLocalState(); |
171 | 178 |
172 // Called to start recording user experience metrics. | 179 // Called to start recording user experience metrics. |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // The types of data that are to be included in the logs and histograms | 475 // The types of data that are to be included in the logs and histograms |
469 // according to the UMA response data. | 476 // according to the UMA response data. |
470 std::set<std::string> logs_to_upload_; | 477 std::set<std::string> logs_to_upload_; |
471 std::set<std::string> logs_to_omit_; | 478 std::set<std::string> logs_to_omit_; |
472 std::set<std::string> histograms_to_upload_; | 479 std::set<std::string> histograms_to_upload_; |
473 std::set<std::string> histograms_to_omit_; | 480 std::set<std::string> histograms_to_omit_; |
474 | 481 |
475 // Indicate that a timer for sending the next log has already been queued. | 482 // Indicate that a timer for sending the next log has already been queued. |
476 bool timer_pending_; | 483 bool timer_pending_; |
477 | 484 |
| 485 FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesAllZeroes); |
| 486 FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesCorrectly); |
| 487 FRIEND_TEST(MetricsServiceTest, ClientIdCorrectlyFormatted); |
478 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 488 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
479 }; | 489 }; |
480 | 490 |
481 #endif // CHROME_BROWSER_METRICS_SERVICE_H_ | 491 #endif // CHROME_BROWSER_METRICS_SERVICE_H_ |
OLD | NEW |