| 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..4b7318042ca9dfd80c1bb90e028a90b86b7211ee 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
|
| @@ -8,9 +8,13 @@
|
| #include <deque>
|
| #include <string>
|
|
|
| +#include "base/basictypes.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/values.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
|
| +#include "net/base/net_log.h"
|
|
|
| class GURL;
|
|
|
| @@ -27,12 +31,23 @@ class NetLog;
|
|
|
| namespace data_reduction_proxy {
|
|
|
| +enum DataReductionProxyProbeState {
|
| + PROBE_UNKNOWN,
|
| + PROBE_PENDING,
|
| + PROBE_SUCCESS,
|
| + PROBE_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);
|
| +
|
| + // 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();
|
|
|
| @@ -68,13 +83,21 @@ class DataReductionProxyEventStore {
|
| const base::TimeDelta& bypass_duration);
|
|
|
| // Adds a DATA_REDUCTION_PROXY_CANARY_REQUEST event to the event store
|
| - // when the canary request has started.
|
| + // when the probe request has started.
|
| void BeginCanaryRequest(const net::BoundNetLog& net_log, const GURL& gurl);
|
|
|
| // Adds a DATA_REDUCTION_PROXY_CANARY_REQUEST event to the event store
|
| - // when the canary request has ended.
|
| + // when the probe 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 probe 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 +113,62 @@ 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 probe request event for the event_store on a
|
| + // BoundNetLog.
|
| + void PostBoundNetLogProbeEvent(
|
| + const net::BoundNetLog& net_log,
|
| + net::NetLog::EventType type,
|
| + net::NetLog::EventPhase phase,
|
| + DataReductionProxyProbeState 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 |probe_state_|
|
| + void AddEventAndProbeStateOnUIThread(scoped_ptr<base::Value> entry,
|
| + DataReductionProxyProbeState 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 probe request.
|
| + DataReductionProxyProbeState probe_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);
|
| };
|
|
|