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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERI MENTS_STATS_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERI MENTS_STATS_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERI MENTS_STATS_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERI MENTS_STATS_H_
7 7
8 #include <stdint.h>
9
8 #include <string> 10 #include <string>
9 11
10 #include "base/basictypes.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr ics.h" 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr ics.h"
17 18
18 namespace base { 19 namespace base {
19 class Time; 20 class Time;
20 } 21 }
21 22
22 namespace data_reduction_proxy { 23 namespace data_reduction_proxy {
23 24
24 class DataReductionProxyConfigRetrievalParams; 25 class DataReductionProxyConfigRetrievalParams;
25 26
26 typedef base::Callback<void(const std::string&, int64)> Int64ValueSetter; 27 typedef base::Callback<void(const std::string&, int64_t)> Int64ValueSetter;
27 28
28 // Collects statistics specific to experiments of which a client may be part. 29 // Collects statistics specific to experiments of which a client may be part.
29 // Any calls into this class should be as lightweight as possible such that if 30 // Any calls into this class should be as lightweight as possible such that if
30 // no experiments are being performed, there should be minimal code being 31 // no experiments are being performed, there should be minimal code being
31 // executed. 32 // executed.
32 // Currently supported experiments are: 33 // Currently supported experiments are:
33 // - Measuring potentially uncompressed bytes during simulated config retrieval. 34 // - Measuring potentially uncompressed bytes during simulated config retrieval.
34 class DataReductionProxyExperimentsStats { 35 class DataReductionProxyExperimentsStats {
35 public: 36 public:
36 DataReductionProxyExperimentsStats(const Int64ValueSetter& value_setter); 37 DataReductionProxyExperimentsStats(const Int64ValueSetter& value_setter);
37 virtual ~DataReductionProxyExperimentsStats(); 38 virtual ~DataReductionProxyExperimentsStats();
38 39
39 // Initializes |this| on the UI thread. If called, must be called prior to 40 // Initializes |this| on the UI thread. If called, must be called prior to
40 // InitializeOnIOThread. 41 // InitializeOnIOThread.
41 void InitializeOnUIThread(scoped_ptr<DataReductionProxyConfigRetrievalParams> 42 void InitializeOnUIThread(scoped_ptr<DataReductionProxyConfigRetrievalParams>
42 config_retrieval_params); 43 config_retrieval_params);
43 44
44 // Initializes |this| on the IO thread. 45 // Initializes |this| on the IO thread.
45 void InitializeOnIOThread(); 46 void InitializeOnIOThread();
46 47
47 // Collect received bytes for the experiment. 48 // Collect received bytes for the experiment.
48 void RecordBytes(const base::Time& request_time, 49 void RecordBytes(const base::Time& request_time,
49 DataReductionProxyRequestType request_type, 50 DataReductionProxyRequestType request_type,
50 int64 received_content_length, 51 int64_t received_content_length,
51 int64 original_content_length); 52 int64_t original_content_length);
52 53
53 private: 54 private:
54 // Updates the simulated expiration of the Data Reduction Proxy configuration 55 // Updates the simulated expiration of the Data Reduction Proxy configuration
55 // if |config_retrieval_| is set. 56 // if |config_retrieval_| is set.
56 void UpdateSimulatedConfig(); 57 void UpdateSimulatedConfig();
57 58
58 // Allows an experiment to persist data to preferences. 59 // Allows an experiment to persist data to preferences.
59 Int64ValueSetter value_setter_; 60 Int64ValueSetter value_setter_;
60 61
61 // Enables measuring of potentially uncompressed bytes during a simulated Data 62 // Enables measuring of potentially uncompressed bytes during a simulated Data
62 // Reduction Proxy configuration retrieval. 63 // Reduction Proxy configuration retrieval.
63 scoped_ptr<DataReductionProxyConfigRetrievalParams> config_retrieval_params_; 64 scoped_ptr<DataReductionProxyConfigRetrievalParams> config_retrieval_params_;
64 65
65 // If set, periodically updates the simulated expiration of the Data Reduction 66 // If set, periodically updates the simulated expiration of the Data Reduction
66 // Proxy configuration. 67 // Proxy configuration.
67 base::RepeatingTimer config_refresh_time_; 68 base::RepeatingTimer config_refresh_time_;
68 69
69 // Enforce initialization order. 70 // Enforce initialization order.
70 bool initialized_; 71 bool initialized_;
71 72
72 // Enforce usage on the IO thread. 73 // Enforce usage on the IO thread.
73 base::ThreadChecker thread_checker_; 74 base::ThreadChecker thread_checker_;
74 75
75 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyExperimentsStats); 76 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyExperimentsStats);
76 }; 77 };
77 78
78 } // namespace data_reduction_proxy 79 } // namespace data_reduction_proxy
79 80
80 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXP ERIMENTS_STATS_H_ 81 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXP ERIMENTS_STATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698