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

Unified Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h

Issue 775773002: Add data reduction proxy debug info to net-internals#bandwidth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/common/data_reduction_proxy_event_store.h
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h
index f8517a4e8f5da085be2911df41cd7e296a80de0e..ba93832d9f70ad1bfc561be9a98eb8e057a809b2 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h
@@ -11,6 +11,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
+#include "net/base/net_log.h"
class GURL;
@@ -27,12 +28,19 @@ class NetLog;
namespace data_reduction_proxy {
+enum DataReductionProxyCanaryState {
+ CANARY_UNKNOWN,
+ CANARY_PENDING,
+ CANARY_SUCCESS,
+ CANARY_FAILED,
+};
+
class DataReductionProxyEventStore {
public:
- // Constructs a DataReductionProxyEventStore object with the given network
+ // Constructs a DataReductionProxyEventStore object with the given UI
// task runner.
explicit DataReductionProxyEventStore(
- const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner);
~DataReductionProxyEventStore();
@@ -75,6 +83,14 @@ class DataReductionProxyEventStore {
// when the canary request has ended.
void EndCanaryRequest(const net::BoundNetLog& net_log, int net_error);
+ // Creates a Value summary of data reduction proxy related information:
+ // - Whether the proxy is enabled
+ // - The proxy configuration
+ // - The state of the last canary response
+ // - A stream of the last data reduction proxy related events.
+ // The caller is responsible for deleting the returned value.
+ base::Value* GetSummaryValue() const;
+
private:
friend class DataReductionProxyEventStoreTest;
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyEventStoreTest,
@@ -90,26 +106,63 @@ class DataReductionProxyEventStore {
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyEventStoreTest,
TestEndCanaryRequest);
- // Prepare and post an event for the event_store on the global net_log.
- void PostGlobalNetLogEvent(net::NetLog* net_log,
- net::NetLog::EventType type,
- const net::NetLog::ParametersCallback& callback);
+ // Prepare and post enabling/disabling proxy events for the event_store on the
+ // global net_log.
+ void PostEnabledEvent(net::NetLog* net_log,
+ net::NetLog::EventType type,
+ bool enable,
+ const net::NetLog::ParametersCallback& callback);
- // Prepare and post an event for the event_store on a BoundNetLog.
- void PostBoundNetLogEvent(const net::BoundNetLog& net_log,
- net::NetLog::EventType type,
- net::NetLog::EventPhase phase,
- const net::NetLog::ParametersCallback& callback);
+ // Prepare and post a data reduction proxy bypass event for the event_store
+ // on a BoundNetLog.
+ void PostBoundNetLogBypassEvent(
+ const net::BoundNetLog& net_log,
+ net::NetLog::EventType type,
+ net::NetLog::EventPhase phase,
+ int64 expiration_ticks,
+ const net::NetLog::ParametersCallback& callback);
+
+ // Prepare and post a canary request event for the event_store on a
+ // BoundNetLog.
+ void PostBoundNetLogCanaryEvent(
+ const net::BoundNetLog& net_log,
+ net::NetLog::EventType type,
+ net::NetLog::EventPhase phase,
+ DataReductionProxyCanaryState state,
+ const net::NetLog::ParametersCallback& callback);
// Put |entry| on a deque of events to store
- void AddEventOnIOThread(scoped_ptr<base::Value> entry);
+ void AddEventOnUIThread(scoped_ptr<base::Value> entry);
+
+ // Put |entry| on the deque of stored events and set |current_configuration_|.
+ void AddEnabledEventOnUIThread(scoped_ptr<base::Value> entry,
+ bool enabled);
+
+ // Put |entry| on a deque of events to store and set |canary_state_|
+ void AddEventAndCanaryStateOnUIThread(scoped_ptr<base::Value> entry,
+ DataReductionProxyCanaryState state);
+
+ // Put |entry| on a deque of events to store and set |last_bypass_event_| and
+ // |expiration_ticks_|
+ void AddAndSetLastBypassEventOnUIThread(scoped_ptr<base::Value> entry,
+ int64 expiration_ticks);
// A task runner to ensure that all reads/writes to |stored_events_| takes
- // place on the IO thread.
- scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
+ // place on the UI thread.
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// A deque of data reduction proxy related events. It is used as a circular
// buffer to prevent unbounded memory utilization.
std::deque<base::Value*> stored_events_;
+ // Whether the data reduction proxy is enabled or not.
+ bool enabled_;
+ // The current data reduction proxy configuration.
+ scoped_ptr<base::Value> current_configuration_;
+ // The state based on the last canary request.
+ DataReductionProxyCanaryState canary_state_;
+ // The last seen data reduction proxy bypass event.
+ scoped_ptr<base::Value> last_bypass_event_;
+ // The expiration time of the |last_bypass_event_|.
+ int64 expiration_ticks_;
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyEventStore);
};

Powered by Google App Engine
This is Rietveld 408576698