summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 14:44:02 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 14:44:02 +0000
commitcc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d (patch)
treebc595667061dde2db1c835dde6e7505ae257a54d /chrome/test
parent8e0e513103bb5dc6ff104c669432c3aba4af18d3 (diff)
downloadchromium_src-cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d.zip
chromium_src-cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d.tar.gz
chromium_src-cc5bfd4de6d8b8c6f33ff1f4a9b28eecf562ec9d.tar.bz2
Dynamically refresh pref-configured proxies.
BUG=63175,48930 TEST=unit tests Review URL: http://codereview.chromium.org/5005002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/testing_profile.cc31
-rw-r--r--chrome/test/testing_profile.h5
2 files changed, 35 insertions, 1 deletions
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 184a703..9e1f428 100644
--- a/chrome/test/testing_profile.cc
+++ b/chrome/test/testing_profile.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/net/pref_proxy_config_service.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
@@ -39,7 +40,6 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_pref_service.h"
-#include "chrome/test/test_url_request_context_getter.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/cookie_monster.h"
#include "net/url_request/url_request_context.h"
@@ -112,6 +112,26 @@ class BookmarkLoadObserver : public BookmarkModelObserver {
DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver);
};
+// Used to return a dummy context (normally the context is on the IO thread).
+// The one here can be run on the main test thread. Note that this can lead to
+// a leak if your test does not have a BrowserThread::IO in it because
+// URLRequestContextGetter is defined as a ReferenceCounted object with a
+// special trait that deletes it on the IO thread.
+class TestURLRequestContextGetter : public URLRequestContextGetter {
+ public:
+ virtual URLRequestContext* GetURLRequestContext() {
+ if (!context_)
+ context_ = new TestURLRequestContext();
+ return context_.get();
+ }
+ virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
+ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
+ }
+
+ private:
+ scoped_refptr<URLRequestContext> context_;
+};
+
class TestExtensionURLRequestContext : public URLRequestContext {
public:
TestExtensionURLRequestContext() {
@@ -185,6 +205,8 @@ TestingProfile::~TestingProfile() {
extensions_service_->DestroyingProfile();
extensions_service_ = NULL;
}
+ if (pref_proxy_config_tracker_.get())
+ pref_proxy_config_tracker_->DetachFromPrefService();
}
void TestingProfile::CreateFaviconService() {
@@ -470,6 +492,13 @@ DesktopNotificationService* TestingProfile::GetDesktopNotificationService() {
return desktop_notification_service_.get();
}
+PrefProxyConfigTracker* TestingProfile::GetProxyConfigTracker() {
+ if (!pref_proxy_config_tracker_)
+ pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs());
+
+ return pref_proxy_config_tracker_;
+}
+
void TestingProfile::BlockUntilHistoryProcessesPendingRequests() {
DCHECK(history_service_.get());
DCHECK(MessageLoop::current());
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index dbfa266..de7f32f 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -294,6 +294,8 @@ class TestingProfile : public Profile {
}
#endif // defined(OS_CHROMEOS)
+ virtual PrefProxyConfigTracker* GetProxyConfigTracker();
+
// Schedules a task on the history backend and runs a nested loop until the
// task is processed. This has the effect of blocking the caller until the
// history service processes all pending requests.
@@ -404,6 +406,9 @@ class TestingProfile : public Profile {
// is disposed.
scoped_refptr<ExtensionsService> extensions_service_;
+ // The proxy prefs tracker.
+ scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
+
// We use a temporary directory to store testing profile data.
ScopedTempDir temp_dir_;
};