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

Unified Diff: chrome/browser/browser_process_impl.cc

Issue 6292017: Extended: Add "system" URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browser_process_impl.cc
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index b7d11153c96e25d69122fe0994347bb4ffdfdf4f..9ca56867bdf4dd02b0edb9ebce83023d5c47d93c 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/predictor_api.h"
+#include "chrome/browser/net/pref_proxy_config_service.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/plugin_data_remover.h"
@@ -57,6 +58,7 @@
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/json_pref_store.h"
+#include "chrome/common/net/url_request_context_getter.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -199,6 +201,10 @@ BrowserProcessImpl::~BrowserProcessImpl() {
// Wait for removing plugin data to finish before shutting down the IO thread.
WaitForPluginDataRemoverToFinish();
+ // Give up reference before io_thread_ checks that there is no one left
+ // holding a reference.
+ system_request_context_ = NULL;
+
// Need to stop io_thread_ before resource_dispatcher_host_, since
// io_thread_ may still deref ResourceDispatcherHost and handle resource
// request before going away.
@@ -245,6 +251,11 @@ BrowserProcessImpl::~BrowserProcessImpl() {
// on the db thread too.
db_thread_.reset();
+ // Need to destroy PrefProxyConfigTracker before local state, since it
+ // caches a pointer to it.
+ pref_proxy_config_tracker_->DetachFromPrefService();
+ pref_proxy_config_tracker_ = NULL;
+
// At this point, no render process exist and the file, io, db, and
// webkit threads in this process have all terminated, so it's safe
// to access local state data such as cookies, database, or local storage.
@@ -423,6 +434,21 @@ ui::Clipboard* BrowserProcessImpl::clipboard() {
return clipboard_.get();
}
+PrefProxyConfigTracker* BrowserProcessImpl::pref_proxy_config_tracker() {
+ DCHECK(CalledOnValidThread());
+ if (!created_pref_proxy_config_tracker_)
+ CreatePrefProxyConfigTracker();
+ return pref_proxy_config_tracker_.get();
+}
+
+scoped_refptr<URLRequestContextGetter>
+ BrowserProcessImpl::system_request_context() {
+ DCHECK(CalledOnValidThread());
+ if (!created_system_request_context_)
+ CreateSystemRequestContextGetter();
+ return system_request_context_.get();
+}
+
NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
DCHECK(CalledOnValidThread());
if (!created_notification_ui_manager_)
@@ -833,6 +859,18 @@ void BrowserProcessImpl::CreateSafeBrowsingDetectionService() {
}
}
+void BrowserProcessImpl::CreatePrefProxyConfigTracker() {
+ DCHECK(pref_proxy_config_tracker_.get() == NULL);
+ created_pref_proxy_config_tracker_ = true;
+ pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state());
+}
+
+void BrowserProcessImpl::CreateSystemRequestContextGetter() {
+ DCHECK(system_request_context_.get() == NULL);
+ created_system_request_context_ = true;
+ system_request_context_ = io_thread()->system_url_request_context_getter();
+}
+
bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() {
// The safe browsing client-side detection is enabled only if the switch is
// enabled and when safe browsing related stats is allowed to be collected.
@@ -954,3 +992,32 @@ void BrowserProcessImpl::OnAutoupdateTimer() {
}
#endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
+
+void BrowserProcessImpl::InitSystemRequestContext() {
+ // The linux gconf-based proxy settings getter relies on being initialized
+ // from the UI thread.
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // Create a baseline service that provides proxy configuration in case nothing
+ // is configured through prefs (Note: prefs include command line and
+ // configuration policy).
+ net::ProxyConfigService* base_service = NULL;
+
+ // TODO(port): the IO and FILE message loops are only used by Linux. Can
+ // that code be moved to chrome/browser instead of being in net, so that it
+ // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354.
+#if defined(OS_CHROMEOS)
+ base_service = new chromeos::ProxyConfigService(
+ new chromeos::ProxyConfigServiceImpl());
+#else
+ base_service = net::ProxyService::CreateSystemProxyConfigService(
+ io_thread()->message_loop(), file_thread()->message_loop());
+#endif // defined(OS_CHROMEOS)
+
+ net::ProxyConfigService* config_service =
+ new PrefProxyConfigService(pref_proxy_config_tracker(),
+ base_service);
+
+ // Takes ownership of config_service.
+ io_thread()->InitSystemRequestContext(config_service);
+}

Powered by Google App Engine
This is Rietveld 408576698