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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h

Issue 1127893002: Add DataReductionProxyExperimentsStats and UMA for measuring potentially non-compressed bytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test failures Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h
new file mode 100644
index 0000000000000000000000000000000000000000..1806d5167c39d4a2e3707a495c8f3424d6ddf006
--- /dev/null
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_experiments_stats.h
@@ -0,0 +1,80 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERIMENTS_STATS_H_
+#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERIMENTS_STATS_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "base/timer/timer.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
+
+namespace base {
+class Time;
+}
+
+namespace data_reduction_proxy {
+
+class DataReductionProxyConfigRetrievalParams;
+
+typedef base::Callback<void(const std::string&, int64)> Int64ValueSetter;
+
+// Collects statistics specific to experiments of which a client may be part.
+// Any calls into this class should be as lightweight as possible such that if
+// no experiments are being performed, there should be minimal code being
+// executed.
+// Currently supported experiments are:
+// - Measuring potentially uncompressed bytes during simulated config retrieval.
+class DataReductionProxyExperimentsStats {
+ public:
+ DataReductionProxyExperimentsStats(const Int64ValueSetter& value_setter);
+ virtual ~DataReductionProxyExperimentsStats();
+
+ // Initializes |this| on the UI thread. If called, must be called prior to
+ // InitializeOnIOThread.
+ void InitializeOnUIThread(scoped_ptr<DataReductionProxyConfigRetrievalParams>
+ config_retrieval_params);
+
+ // Initializes |this| on the IO thread.
+ void InitializeOnIOThread();
+
+ // Collect received bytes for the experiment.
+ void RecordBytes(const base::Time& request_time,
+ DataReductionProxyRequestType request_type,
+ int64 received_content_length,
+ int64 original_content_length);
+
+ private:
+ // Updates the simulated expiration of the Data Reduction Proxy configuration
+ // if |config_retrieval_| is set.
+ void UpdateSimulatedConfig();
+
+ // Allows an experiment to persist data to preferences.
+ Int64ValueSetter value_setter_;
+
+ // Enables measuring of potentially uncompressed bytes during a simulated Data
+ // Reduction Proxy configuration retrieval.
+ scoped_ptr<DataReductionProxyConfigRetrievalParams> config_retrieval_params_;
+
+ // If set, periodically updates the simulated expiration of the Data Reduction
+ // Proxy configuration.
+ base::RepeatingTimer<DataReductionProxyExperimentsStats> config_refresh_time_;
+
+ // Enforce initialization order.
+ bool initialized_;
+
+ // Enforce usage on the IO thread.
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(DataReductionProxyExperimentsStats);
+};
+
+} // namespace data_reduction_proxy
+
+#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_EXPERIMENTS_STATS_H_

Powered by Google App Engine
This is Rietveld 408576698