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..cba95a7cf0cab353dc61bd5ea166bb99067a196f 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,23 @@ class NetLog; |
namespace data_reduction_proxy { |
+enum DataReductionProxyCanaryState { |
bengr
2014/12/11 00:16:07
Canary is a better name, but we use "ProbeURL" all
jeremyim
2014/12/11 05:24:22
Done.
|
+ CANARY_UNKNOWN, |
+ CANARY_PENDING, |
+ CANARY_SUCCESS, |
+ CANARY_FAILED, |
+}; |
+ |
class DataReductionProxyEventStore { |
public: |
- // Constructs a DataReductionProxyEventStore object with the given network |
+ // Adds data reduction proxy specific constants to the net_internals |
+ // constants dictionary. |
+ static void AddConstants(base::DictionaryValue *constants_dict); |
bengr
2014/12/11 00:16:07
base::DictionaryValue* constants_dict
jeremyim
2014/12/11 05:24:22
Done.
|
+ |
+ // 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 +87,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: |
bengr
2014/12/11 00:16:07
Capitalize: "Data Reduction Proxy"
jeremyim
2014/12/11 05:24:22
Done.
|
+ // - 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. |
bengr
2014/12/11 00:16:07
here too.
jeremyim
2014/12/11 05:24:22
Done.
|
+ // The caller is responsible for deleting the returned value. |
+ base::Value* GetSummaryValue() const; |
+ |
private: |
friend class DataReductionProxyEventStoreTest; |
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyEventStoreTest, |
@@ -90,26 +110,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 |
bengr
2014/12/11 00:16:07
and here.
jeremyim
2014/12/11 05:24:22
Done.
|
+ // 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); |
bengr
2014/12/11 00:16:07
Can this fit on the line above?
jeremyim
2014/12/11 05:24:22
Done.
|
+ |
+ // 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); |
}; |