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

Side by Side Diff: android_webview/browser/aw_browser_context.cc

Issue 888713002: DataReductionProxyStatisticsPrefs should support WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/aw_browser_context.h" 5 #include "android_webview/browser/aw_browser_context.h"
6 6
7 #include "android_webview/browser/aw_form_database_service.h" 7 #include "android_webview/browser/aw_form_database_service.h"
8 #include "android_webview/browser/aw_pref_store.h" 8 #include "android_webview/browser/aw_pref_store.h"
9 #include "android_webview/browser/aw_quota_manager_bridge.h" 9 #include "android_webview/browser/aw_quota_manager_bridge.h"
10 #include "android_webview/browser/aw_resource_context.h" 10 #include "android_webview/browser/aw_resource_context.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (context == NULL || context->user_pref_service_.get() == NULL) 118 if (context == NULL || context->user_pref_service_.get() == NULL)
119 return; 119 return;
120 data_reduction_proxy::DataReductionProxySettings* proxy_settings = 120 data_reduction_proxy::DataReductionProxySettings* proxy_settings =
121 context->GetDataReductionProxySettings(); 121 context->GetDataReductionProxySettings();
122 if (proxy_settings == NULL) 122 if (proxy_settings == NULL)
123 return; 123 return;
124 // At this point, context->PreMainMessageLoopRun() has run, so 124 // At this point, context->PreMainMessageLoopRun() has run, so
125 // context->data_reduction_proxy_io_data() is valid. 125 // context->data_reduction_proxy_io_data() is valid.
126 DCHECK(context->GetDataReductionProxyIOData()); 126 DCHECK(context->GetDataReductionProxyIOData());
127 context->CreateDataReductionProxyStatisticsIfNecessary(); 127 context->CreateDataReductionProxyStatisticsIfNecessary();
128 proxy_settings->SetDataReductionProxyStatisticsPrefs(
129 context->GetDataReductionProxyIOData()->statistics_prefs());
130 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); 128 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_);
131 } 129 }
132 130
133 // static 131 // static
134 void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) { 132 void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) {
135 legacy_cache_removal_delay_ms_ = delay_ms; 133 legacy_cache_removal_delay_ms_ = delay_ms;
136 } 134 }
137 135
138 void AwBrowserContext::PreMainMessageLoopRun() { 136 void AwBrowserContext::PreMainMessageLoopRun() {
139 cookie_store_ = CreateCookieStore(this); 137 cookie_store_ = CreateCookieStore(this);
(...skipping 20 matching lines...) Expand all
160 158
161 data_reduction_proxy_settings_.reset( 159 data_reduction_proxy_settings_.reset(
162 new data_reduction_proxy::DataReductionProxySettings( 160 new data_reduction_proxy::DataReductionProxySettings(
163 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>( 161 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>(
164 new data_reduction_proxy::DataReductionProxyParams( 162 new data_reduction_proxy::DataReductionProxyParams(
165 data_reduction_proxy::DataReductionProxyParams::kAllowed)) 163 data_reduction_proxy::DataReductionProxyParams::kAllowed))
166 .Pass())); 164 .Pass()));
167 data_reduction_proxy_io_data_.reset( 165 data_reduction_proxy_io_data_.reset(
168 new data_reduction_proxy::DataReductionProxyIOData( 166 new data_reduction_proxy::DataReductionProxyIOData(
169 data_reduction_proxy::Client::WEBVIEW_ANDROID, 167 data_reduction_proxy::Client::WEBVIEW_ANDROID,
170 scoped_ptr<
171 data_reduction_proxy::DataReductionProxyStatisticsPrefs>(),
172 data_reduction_proxy_settings_.get(), 168 data_reduction_proxy_settings_.get(),
173 url_request_context_getter_->GetNetLog(), 169 url_request_context_getter_->GetNetLog(),
174 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 170 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
175 BrowserThread::GetMessageLoopProxyForThread( 171 BrowserThread::GetMessageLoopProxyForThread(
176 BrowserThread::UI))); 172 BrowserThread::UI)));
177 data_reduction_proxy_settings_->SetProxyConfigurator( 173 data_reduction_proxy_settings_->SetProxyConfigurator(
178 data_reduction_proxy_io_data_->configurator()); 174 data_reduction_proxy_io_data_->configurator());
179 175
180 visitedlink_master_.reset( 176 visitedlink_master_.reset(
181 new visitedlink::VisitedLinkMaster(this, this, false)); 177 new visitedlink::VisitedLinkMaster(this, this, false));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 base::PrefServiceFactory pref_service_factory; 268 base::PrefServiceFactory pref_service_factory;
273 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); 269 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore()));
274 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); 270 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError));
275 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); 271 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass();
276 272
277 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); 273 user_prefs::UserPrefs::Set(this, user_pref_service_.get());
278 274
279 if (data_reduction_proxy_settings_) { 275 if (data_reduction_proxy_settings_) {
280 data_reduction_proxy_settings_->InitDataReductionProxySettings( 276 data_reduction_proxy_settings_->InitDataReductionProxySettings(
281 user_pref_service_.get(), 277 user_pref_service_.get(),
278 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(),
282 GetRequestContext(), 279 GetRequestContext(),
283 GetAwURLRequestContext()->GetNetLog(), 280 GetAwURLRequestContext()->GetNetLog(),
284 data_reduction_proxy_io_data_->event_store()); 281 data_reduction_proxy_io_data_->event_store());
285 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); 282 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true);
286 283
287 SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); 284 SetDataReductionProxyEnabled(data_reduction_proxy_enabled_);
288 } 285 }
289 } 286 }
290 287
291 scoped_ptr<content::ZoomLevelDelegate> 288 scoped_ptr<content::ZoomLevelDelegate>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 void AwBrowserContext::RebuildTable( 365 void AwBrowserContext::RebuildTable(
369 const scoped_refptr<URLEnumerator>& enumerator) { 366 const scoped_refptr<URLEnumerator>& enumerator) {
370 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client 367 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client
371 // can change in the lifetime of this WebView and may not yet be set here. 368 // can change in the lifetime of this WebView and may not yet be set here.
372 // Therefore this initialization path is not used. 369 // Therefore this initialization path is not used.
373 enumerator->OnComplete(true); 370 enumerator->OnComplete(true);
374 } 371 }
375 372
376 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { 373 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() {
377 DCHECK(user_pref_service_.get()); 374 DCHECK(user_pref_service_.get());
378 DCHECK(GetDataReductionProxyIOData()); 375 DCHECK(GetDataReductionProxySettings());
379 if (GetDataReductionProxyIOData()->statistics_prefs()) 376 if (GetDataReductionProxySettings()->statistics_prefs())
380 return; 377 return;
381 // We don't care about commit_delay for now. It is just a dummy value. 378 // We don't care about commit_delay for now. It is just a dummy value.
382 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); 379 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
383 GetDataReductionProxyIOData()->EnableCompressionStatisticsLogging( 380 GetDataReductionProxySettings()->EnableCompressionStatisticsLogging(
384 user_pref_service_.get(), commit_delay); 381 user_pref_service_.get(),
382 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
383 commit_delay);
384 GetDataReductionProxyIOData()->SetDataReductionProxyStatisticsPrefs(
385 GetDataReductionProxySettings()->statistics_prefs()->GetWeakPtr());
385 } 386 }
386 387
387 } // namespace android_webview 388 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698