diff options
author | jeremyim <jeremyim@chromium.org> | 2015-04-28 16:29:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-28 23:30:03 +0000 |
commit | 3074bf4dcf5b9a89ede7cba949f3e4ef606d40ac (patch) | |
tree | 617507706bb20dccbab66d92fc5d54007f2f79d3 /components/data_reduction_proxy | |
parent | eaf365a0d6373700b3cb8d51a6de09e52039461c (diff) | |
download | chromium_src-3074bf4dcf5b9a89ede7cba949f3e4ef606d40ac.zip chromium_src-3074bf4dcf5b9a89ede7cba949f3e4ef606d40ac.tar.gz chromium_src-3074bf4dcf5b9a89ede7cba949f3e4ef606d40ac.tar.bz2 |
Add net_log events for the Data Reduction Proxy config service client.
The start and completion of the config retrieval requests will be logged,
and made available to the chrome://net-internals/#bandwidth page.
BUG=466753
Review URL: https://codereview.chromium.org/1105443003
Cr-Commit-Position: refs/heads/master@{#327389}
Diffstat (limited to 'components/data_reduction_proxy')
16 files changed, 175 insertions, 43 deletions
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc index 67728a9..e231d30 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc @@ -19,6 +19,7 @@ #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_client_config_parser.h" +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "components/data_reduction_proxy/proto/client_config.pb.h" @@ -111,11 +112,15 @@ DataReductionProxyConfigServiceClient::DataReductionProxyConfigServiceClient( const net::BackoffEntry::Policy& backoff_policy, DataReductionProxyRequestOptions* request_options, DataReductionProxyMutableConfigValues* config_values, - DataReductionProxyConfig* config) + DataReductionProxyConfig* config, + DataReductionProxyEventCreator* event_creator, + net::NetLog* net_log) : params_(params.Pass()), request_options_(request_options), config_values_(config_values), config_(config), + event_creator_(event_creator), + net_log_(net_log), backoff_entry_(&backoff_policy), config_service_url_( GetConfigServiceURL(*base::CommandLine::ForCurrentProcess())), @@ -124,6 +129,8 @@ DataReductionProxyConfigServiceClient::DataReductionProxyConfigServiceClient( DCHECK(request_options); DCHECK(config_values); DCHECK(config); + DCHECK(event_creator); + DCHECK(net_log); // Constructed on the UI thread, but should be checked on the IO thread. thread_checker_.DetachFromThread(); } @@ -142,6 +149,9 @@ void DataReductionProxyConfigServiceClient::InitializeOnIOThread( void DataReductionProxyConfigServiceClient::RetrieveConfig() { DCHECK(thread_checker_.CalledOnValidThread()); + bound_net_log_ = net::BoundNetLog::Make( + net_log_, net::NetLog::SOURCE_DATA_REDUCTION_PROXY); + event_creator_->BeginConfigRequest(bound_net_log_, config_service_url_); if (use_local_config_) { ReadAndApplyStaticConfig(); return; @@ -251,6 +261,9 @@ void DataReductionProxyConfigServiceClient::HandleResponse( CalculateNextConfigRefreshTime(succeeded, expiration_time, Now(), GetBackoffEntry()->GetTimeUntilRelease()); SetConfigRefreshTimer(next_config_refresh_time); + event_creator_->EndConfigRequest( + bound_net_log_, status.error(), response_code, + GetBackoffEntry()->failure_count(), next_config_refresh_time); } bool DataReductionProxyConfigServiceClient::ParseAndApplyProxyConfig( diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h index 41b0424..95e8a4c 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h @@ -14,6 +14,7 @@ #include "base/timer/timer.h" #include "net/base/backoff_entry.h" #include "net/base/network_change_notifier.h" +#include "net/log/net_log.h" #include "net/url_request/url_fetcher_delegate.h" #include "url/gurl.h" @@ -33,6 +34,7 @@ namespace data_reduction_proxy { class ClientConfig; class DataReductionProxyConfig; +class DataReductionProxyEventCreator; class DataReductionProxyMutableConfigValues; class DataReductionProxyParams; class DataReductionProxyRequestOptions; @@ -55,14 +57,15 @@ class DataReductionProxyConfigServiceClient // The caller must ensure that all parameters remain alive for the lifetime of // the |DataReductionProxyConfigClient|, with the exception of |params| - // which this instance will own. The |io_task_runner| is used to enforce that - // configurations are applied on the IO thread. + // which this instance will own. DataReductionProxyConfigServiceClient( scoped_ptr<DataReductionProxyParams> params, const net::BackoffEntry::Policy& backoff_policy, DataReductionProxyRequestOptions* request_options, DataReductionProxyMutableConfigValues* config_values, - DataReductionProxyConfig* config); + DataReductionProxyConfig* config, + DataReductionProxyEventCreator* event_creator, + net::NetLog* net_log); ~DataReductionProxyConfigServiceClient() override; @@ -140,6 +143,12 @@ class DataReductionProxyConfigServiceClient // The caller must ensure that the |config_| outlives this instance. DataReductionProxyConfig* config_; + // The caller must ensure that the |event_creator_| outlives this instance. + DataReductionProxyEventCreator* event_creator_; + + // The caller must ensure that the |net_log_| outlives this instance. + net::NetLog* net_log_; + // Used to calculate the backoff time on request failures. net::BackoffEntry backoff_entry_; @@ -162,6 +171,9 @@ class DataReductionProxyConfigServiceClient // A |net::URLFetcher| to retrieve the Data Reduction Proxy configuration. scoped_ptr<net::URLFetcher> fetcher_; + // Used to correlate the start and end of requests. + net::BoundNetLog bound_net_log_; + // Enforce usage on the IO thread. base::ThreadChecker thread_checker_; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc index ca35828..cc15782 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc @@ -106,7 +106,8 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test { new DataReductionProxyConfigServiceClient( params.Pass(), GetBackoffPolicy(), request_options_.get(), test_context_->mutable_config_values(), - test_context_->io_data()->config())); + test_context_->io_data()->config(), test_context_->event_creator(), + test_context_->net_log())); } void ResetBackoffEntryReleaseTime() { diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc index 9245544..50a303c 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc @@ -137,7 +137,7 @@ DataReductionProxyIOData::DataReductionProxyIOData( if (use_config_client) { config_client_.reset(new DataReductionProxyConfigServiceClient( params.Pass(), GetBackoffPolicy(), request_options_.get(), - raw_mutable_config, config_.get())); + raw_mutable_config, config_.get(), event_creator_.get(), net_log_)); } proxy_delegate_.reset( @@ -236,32 +236,39 @@ void DataReductionProxyIOData::UpdateContentLengths( data_reduction_proxy_enabled, request_type)); } -void DataReductionProxyIOData::AddEnabledEvent(scoped_ptr<base::Value> entry, +void DataReductionProxyIOData::AddEvent(scoped_ptr<base::Value> event) { + DCHECK(io_task_runner_->BelongsToCurrentThread()); + ui_task_runner_->PostTask( + FROM_HERE, base::Bind(&DataReductionProxyService::AddEvent, service_, + base::Passed(&event))); +} + +void DataReductionProxyIOData::AddEnabledEvent(scoped_ptr<base::Value> event, bool enabled) { DCHECK(io_task_runner_->BelongsToCurrentThread()); ui_task_runner_->PostTask( FROM_HERE, base::Bind(&DataReductionProxyService::AddEnabledEvent, - service_, base::Passed(&entry), enabled)); + service_, base::Passed(&event), enabled)); } void DataReductionProxyIOData::AddEventAndSecureProxyCheckState( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, SecureProxyCheckState state) { DCHECK(io_task_runner_->BelongsToCurrentThread()); ui_task_runner_->PostTask( FROM_HERE, base::Bind(&DataReductionProxyService::AddEventAndSecureProxyCheckState, - service_, base::Passed(&entry), state)); + service_, base::Passed(&event), state)); } void DataReductionProxyIOData::AddAndSetLastBypassEvent( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, int64 expiration_ticks) { DCHECK(io_task_runner_->BelongsToCurrentThread()); ui_task_runner_->PostTask( FROM_HERE, base::Bind(&DataReductionProxyService::AddAndSetLastBypassEvent, service_, - base::Passed(&entry), expiration_ticks)); + base::Passed(&event), expiration_ticks)); } void DataReductionProxyIOData::SetUnreachable(bool unreachable) { diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h index 4acbc48..d68001f 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h @@ -93,10 +93,11 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { // Overrides of DataReductionProxyEventStorageDelegate. Bridges to the UI // thread objects. - void AddEnabledEvent(scoped_ptr<base::Value> entry, bool enabled) override; - void AddEventAndSecureProxyCheckState(scoped_ptr<base::Value> entry, + void AddEvent(scoped_ptr<base::Value> event) override; + void AddEnabledEvent(scoped_ptr<base::Value> event, bool enabled) override; + void AddEventAndSecureProxyCheckState(scoped_ptr<base::Value> event, SecureProxyCheckState state) override; - void AddAndSetLastBypassEvent(scoped_ptr<base::Value> entry, + void AddAndSetLastBypassEvent(scoped_ptr<base::Value> event, int64 expiration_ticks) override; // Returns true if the Data Reduction Proxy is enabled and false otherwise. diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc index cf25df9..374489e 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc @@ -70,24 +70,29 @@ void DataReductionProxyService::UpdateContentLengths( } } -void DataReductionProxyService::AddEnabledEvent(scoped_ptr<base::Value> entry, +void DataReductionProxyService::AddEvent(scoped_ptr<base::Value> event) { + DCHECK(CalledOnValidThread()); + event_store_->AddEvent(event.Pass()); +} + +void DataReductionProxyService::AddEnabledEvent(scoped_ptr<base::Value> event, bool enabled) { DCHECK(CalledOnValidThread()); - event_store_->AddEnabledEvent(entry.Pass(), enabled); + event_store_->AddEnabledEvent(event.Pass(), enabled); } void DataReductionProxyService::AddEventAndSecureProxyCheckState( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, SecureProxyCheckState state) { DCHECK(CalledOnValidThread()); - event_store_->AddEventAndSecureProxyCheckState(entry.Pass(), state); + event_store_->AddEventAndSecureProxyCheckState(event.Pass(), state); } void DataReductionProxyService::AddAndSetLastBypassEvent( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, int64 expiration_ticks) { DCHECK(CalledOnValidThread()); - event_store_->AddAndSetLastBypassEvent(entry.Pass(), expiration_ticks); + event_store_->AddAndSetLastBypassEvent(event.Pass(), expiration_ticks); } void DataReductionProxyService::SetUnreachable(bool unreachable) { diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h index 54a3365..2fbc18d 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h @@ -79,10 +79,11 @@ class DataReductionProxyService DataReductionProxyRequestType request_type); // Overrides of DataReductionProxyEventStorageDelegate. - void AddEnabledEvent(scoped_ptr<base::Value> entry, bool enabled) override; - void AddEventAndSecureProxyCheckState(scoped_ptr<base::Value> entry, + void AddEvent(scoped_ptr<base::Value> event) override; + void AddEnabledEvent(scoped_ptr<base::Value> event, bool enabled) override; + void AddEventAndSecureProxyCheckState(scoped_ptr<base::Value> event, SecureProxyCheckState state) override; - void AddAndSetLastBypassEvent(scoped_ptr<base::Value> entry, + void AddAndSetLastBypassEvent(scoped_ptr<base::Value> event, int64 expiration_ticks) override; // Records whether the Data Reduction Proxy is unreachable or not. diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc index 71dec53..96a80d7 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc @@ -93,12 +93,16 @@ TestDataReductionProxyConfigServiceClient:: scoped_ptr<DataReductionProxyParams> params, DataReductionProxyRequestOptions* request_options, DataReductionProxyMutableConfigValues* config_values, - DataReductionProxyConfig* config) + DataReductionProxyConfig* config, + DataReductionProxyEventCreator* event_creator, + net::NetLog* net_log) : DataReductionProxyConfigServiceClient(params.Pass(), kTestBackoffPolicy, request_options, config_values, - config), + config, + event_creator, + net_log), tick_clock_(base::Time::UnixEpoch()), test_backoff_entry_(&kTestBackoffPolicy, &tick_clock_) { } @@ -364,12 +368,12 @@ DataReductionProxyTestContext::Builder::Build() { if (use_test_config_client_) { test_context_flags |= USE_TEST_CONFIG_CLIENT; config_client.reset(new TestDataReductionProxyConfigServiceClient( - params.Pass(), request_options.get(), raw_mutable_config, - config.get())); + params.Pass(), request_options.get(), raw_mutable_config, config.get(), + event_creator.get(), net_log.get())); } else if (use_config_client_) { config_client.reset(new DataReductionProxyConfigServiceClient( params.Pass(), GetBackoffPolicy(), request_options.get(), - raw_mutable_config, config.get())); + raw_mutable_config, config.get(), event_creator.get(), net_log.get())); } scoped_ptr<DataReductionProxySettings> settings( diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h index 81a8984..004a3a5 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h @@ -99,7 +99,9 @@ class TestDataReductionProxyConfigServiceClient scoped_ptr<DataReductionProxyParams> params, DataReductionProxyRequestOptions* request_options, DataReductionProxyMutableConfigValues* config_values, - DataReductionProxyConfig* config); + DataReductionProxyConfig* config, + DataReductionProxyEventCreator* event_creator, + net::NetLog* net_log); ~TestDataReductionProxyConfigServiceClient() override; diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.cc index 1ce6246..98fdd68 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.cc @@ -125,6 +125,23 @@ base::Value* EndCanaryRequestCallback( return dict; } +// A callback that creates a base::Value containing information about +// completing the Data Reduction Proxy configuration request. Ownership of the +// base::Value is passed to the caller. +base::Value* EndConfigRequestCallback( + int net_error, + int http_response_code, + int failure_count, + int64 expiration_ticks, + net::NetLogCaptureMode /* capture_mode */) { + base::DictionaryValue* dict = new base::DictionaryValue(); + dict->SetInteger("net_error", net_error); + dict->SetInteger("http_response_code", http_response_code); + dict->SetInteger("failure_count", failure_count); + dict->SetString("expiration", base::Int64ToString(expiration_ticks)); + return dict; +} + } // namespace namespace data_reduction_proxy { @@ -224,6 +241,32 @@ void DataReductionProxyEventCreator::EndSecureProxyCheck( parameters_callback); } +void DataReductionProxyEventCreator::BeginConfigRequest( + const net::BoundNetLog& net_log, + const GURL& url) { + // This callback must be invoked synchronously. + const net::NetLog::ParametersCallback& parameters_callback = + net::NetLog::StringCallback("url", &url.spec()); + PostBoundNetLogConfigRequestEvent( + net_log, net::NetLog::TYPE_DATA_REDUCTION_PROXY_CONFIG_REQUEST, + net::NetLog::PHASE_BEGIN, parameters_callback); +} + +void DataReductionProxyEventCreator::EndConfigRequest( + const net::BoundNetLog& net_log, + int net_error, + int http_response_code, + int failure_count, + const base::TimeDelta& retry_delay) { + int64 expiration_ticks = GetExpirationTicks(retry_delay.InSeconds()); + const net::NetLog::ParametersCallback& parameters_callback = + base::Bind(&EndConfigRequestCallback, net_error, http_response_code, + failure_count, expiration_ticks); + PostBoundNetLogConfigRequestEvent( + net_log, net::NetLog::TYPE_DATA_REDUCTION_PROXY_CONFIG_REQUEST, + net::NetLog::PHASE_END, parameters_callback); +} + void DataReductionProxyEventCreator::PostEnabledEvent( net::NetLog* net_log, net::NetLog::EventType type, @@ -264,4 +307,17 @@ void DataReductionProxyEventCreator::PostBoundNetLogSecureProxyCheckEvent( net_log.AddEntry(type, phase, callback); } +void DataReductionProxyEventCreator::PostBoundNetLogConfigRequestEvent( + const net::BoundNetLog& net_log, + net::NetLog::EventType type, + net::NetLog::EventPhase phase, + const net::NetLog::ParametersCallback& callback) { + scoped_ptr<base::Value> event( + BuildDataReductionProxyEvent(type, net_log.source(), phase, callback)); + if (event) { + storage_delegate_->AddEvent(event.Pass()); + net_log.AddEntry(type, phase, callback); + } +} + } // namespace data_reduction_proxy diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h index cd37e83..b85f0e2a 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h @@ -80,6 +80,18 @@ class DataReductionProxyEventCreator { int http_response_code, bool succeeded); + // Adds a DATA_REDUCTION_PROXY_CONFIG_REQUEST event to the event store + // when the config request has started. + void BeginConfigRequest(const net::BoundNetLog& net_log, const GURL& url); + + // Adds a DATA_REDUCTION_PROXY_CONFIG_REQUEST event to the event store + // when the config request has ended. + void EndConfigRequest(const net::BoundNetLog& net_log, + int net_error, + int http_response_code, + int failure_count, + const base::TimeDelta& retry_delay); + private: // Prepare and post enabling/disabling proxy events for the event store on the // a net::NetLog. @@ -106,6 +118,14 @@ class DataReductionProxyEventCreator { DataReductionProxyEventStorageDelegate::SecureProxyCheckState state, const net::NetLog::ParametersCallback& callback); + // Prepare and post a config request event for the event store on a + // BoundNetLog. + void PostBoundNetLogConfigRequestEvent( + const net::BoundNetLog& net_log, + net::NetLog::EventType type, + net::NetLog::EventPhase phase, + const net::NetLog::ParametersCallback& callback); + // Must outlive |this|. Used for posting calls to the UI thread. DataReductionProxyEventStorageDelegate* storage_delegate_; diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate.h index d80bcaf..94f10b6 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate.h +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate.h @@ -24,6 +24,9 @@ class DataReductionProxyEventStorageDelegate { CHECK_FAILED, }; + // Stores a DATA_REDUCTION_PROXY event with no parameters. + virtual void AddEvent(scoped_ptr<base::Value> event) = 0; + // Stores a DATA_REDUCTION_PROXY_ENABLED event. virtual void AddEnabledEvent(scoped_ptr<base::Value> event, bool enabled) = 0; diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.cc index a20a68e..a916b78 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.cc @@ -25,6 +25,12 @@ void TestDataReductionProxyEventStorageDelegate::SetStorageDelegate( delegate_ = delegate; } +void TestDataReductionProxyEventStorageDelegate::AddEvent( + scoped_ptr<base::Value> event) { + if (delegate_) + delegate_->AddEvent(event.Pass()); +} + void TestDataReductionProxyEventStorageDelegate::AddEnabledEvent( scoped_ptr<base::Value> event, bool enabled) { diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.h index 65d3116..90cc8d1 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.h +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_storage_delegate_test_utils.h @@ -27,6 +27,7 @@ class TestDataReductionProxyEventStorageDelegate void SetStorageDelegate(DataReductionProxyEventStorageDelegate* delegate); // Overrides of DataReductionProxyEventStorageDelegate: + void AddEvent(scoped_ptr<base::Value> event) override; void AddEnabledEvent(scoped_ptr<base::Value> event, bool enabled) override; void AddAndSetLastBypassEvent(scoped_ptr<base::Value> event, int64 expiration_ticks) override; diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc index b0734b6..3fefcc4 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc @@ -101,43 +101,43 @@ base::Value* DataReductionProxyEventStore::GetSummaryValue() const { return data_reduction_proxy_values.release(); } -void DataReductionProxyEventStore::AddEvent(scoped_ptr<base::Value> entry) { +void DataReductionProxyEventStore::AddEvent(scoped_ptr<base::Value> event) { if (stored_events_.size() == kMaxEventsToStore) { base::Value* head = stored_events_.front(); stored_events_.pop_front(); delete head; } - stored_events_.push_back(entry.release()); + stored_events_.push_back(event.release()); } void DataReductionProxyEventStore::AddEnabledEvent( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, bool enabled) { DCHECK(thread_checker_.CalledOnValidThread()); enabled_ = enabled; if (enabled) - current_configuration_.reset(entry->DeepCopy()); + current_configuration_.reset(event->DeepCopy()); else current_configuration_.reset(); - AddEvent(entry.Pass()); + AddEvent(event.Pass()); } void DataReductionProxyEventStore::AddEventAndSecureProxyCheckState( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, SecureProxyCheckState state) { DCHECK(thread_checker_.CalledOnValidThread()); secure_proxy_check_state_ = state; - AddEvent(entry.Pass()); + AddEvent(event.Pass()); } void DataReductionProxyEventStore::AddAndSetLastBypassEvent( - scoped_ptr<base::Value> entry, + scoped_ptr<base::Value> event, int64 expiration_ticks) { DCHECK(thread_checker_.CalledOnValidThread()); - last_bypass_event_.reset(entry->DeepCopy()); + last_bypass_event_.reset(event->DeepCopy()); expiration_ticks_ = expiration_ticks; - AddEvent(entry.Pass()); + AddEvent(event.Pass()); } } // namespace data_reduction_proxy 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 e55eb04..e42133a 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 @@ -42,6 +42,9 @@ class DataReductionProxyEventStore // The caller is responsible for deleting the returned value. base::Value* GetSummaryValue() const; + // Adds DATA_REDUCTION_PROXY event with no parameters to the event store. + void AddEvent(scoped_ptr<base::Value> event) override; + // Override of DataReductionProxyEventStorageDelegate. // Put |entry| on the deque of stored events and set |current_configuration_|. void AddEnabledEvent(scoped_ptr<base::Value> entry, bool enabled) override; @@ -73,9 +76,6 @@ class DataReductionProxyEventStore FRIEND_TEST_ALL_PREFIXES(DataReductionProxyEventStoreTest, TestEndSecureProxyCheck); - // Put |entry| on a deque of events to store - void AddEvent(scoped_ptr<base::Value> entry); - // 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_; |