summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/resolve_proxy_msg_helper.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 17:16:55 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 17:16:55 +0000
commitf6b224d1e92a0986adf6fb3bdaebef1c606147e1 (patch)
tree051d106c0d20fdeba08e3d5f482d538b035589c7 /chrome/browser/net/resolve_proxy_msg_helper.h
parent79a90d230d67c14292d1807dca6938c11de9275d (diff)
downloadchromium_src-f6b224d1e92a0986adf6fb3bdaebef1c606147e1.zip
chromium_src-f6b224d1e92a0986adf6fb3bdaebef1c606147e1.tar.gz
chromium_src-f6b224d1e92a0986adf6fb3bdaebef1c606147e1.tar.bz2
Simplify ResolveProxyMsgHelper. Make it not special case renderer/plugin, and derive from BrowserMessageFilter for easier filtering and replying.
Review URL: http://codereview.chromium.org/6695009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/resolve_proxy_msg_helper.h')
-rw-r--r--chrome/browser/net/resolve_proxy_msg_helper.h52
1 files changed, 16 insertions, 36 deletions
diff --git a/chrome/browser/net/resolve_proxy_msg_helper.h b/chrome/browser/net/resolve_proxy_msg_helper.h
index e596adc..f0f6911 100644
--- a/chrome/browser/net/resolve_proxy_msg_helper.h
+++ b/chrome/browser/net/resolve_proxy_msg_helper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,55 +10,37 @@
#include <string>
#include "base/ref_counted.h"
+#include "content/browser/browser_message_filter.h"
#include "googleurl/src/gurl.h"
-#include "ipc/ipc_message.h"
#include "net/base/completion_callback.h"
#include "net/proxy/proxy_service.h"
-// This class holds the common logic used to respond to the messages:
-// {PluginProcessHostMsg_ResolveProxy, ViewHostMsg_ResolveProxy}.
-//
-// This involves kicking off a ProxyResolve request on the IO thread using
-// the specified proxy service.
-//
-// When the request completes, it calls the delegate's OnProxyResolveCompleted()
-// method, passing it the result (error code + proxy list), as well as the
-// IPC::Message pointer that had been stored.
+// Responds to ChildProcessHostMsg_ResolveProxy, kicking off a ProxyResolve
+// request on the IO thread using the specified proxy service. Completion is
+// notified through the delegate. If multiple requests are started at the same
+// time, they will run in FIFO order, with only 1 being outstanding at a time.
//
// When an instance of ResolveProxyMsgHelper is destroyed, it cancels any
// outstanding proxy resolve requests with the proxy service. It also deletes
// the stored IPC::Message pointers for pending requests.
//
// This object is expected to live on the IO thread.
-class ResolveProxyMsgHelper {
+class ResolveProxyMsgHelper : public BrowserMessageFilter {
public:
- class Delegate {
- public:
- // Callback for when the proxy resolve request has completed.
- // |reply_msg| -- The same pointer that the request was started with.
- // |result| -- The network error code from ProxyService.
- // |proxy_list| -- The PAC string result from ProxyService.
- virtual void OnResolveProxyCompleted(IPC::Message* reply_msg,
- int result,
- const std::string& proxy_list) = 0;
- virtual ~Delegate() {}
- };
-
- // Constructs a ResolveProxyMsgHelper instance that notifies request
- // completion to |delegate|. Note that |delegate| must be live throughout
- // our lifespan. If |proxy_service| is NULL, then the current profile's
- // proxy service will be used.
- ResolveProxyMsgHelper(Delegate* delegate, net::ProxyService* proxy_service);
-
- // Resolves proxies for |url|. Completion is notified through the delegate.
- // If multiple requests are started at the same time, they will run in
- // FIFO order, with only 1 being outstanding at a time.
- void Start(const GURL& url, IPC::Message* reply_msg);
+ // If |proxy_service| is NULL, then the main profile's proxy service will
+ // be used.
+ explicit ResolveProxyMsgHelper(net::ProxyService* proxy_service);
// Destruction cancels the current outstanding request, and clears the
// pending queue.
~ResolveProxyMsgHelper();
+ // BrowserMessageFilter implementation
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
+
+ void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
+
private:
// Callback for the ProxyService (bound to |callback_|).
void OnResolveProxyCompleted(int result);
@@ -95,8 +77,6 @@ class ResolveProxyMsgHelper {
typedef std::deque<PendingRequest> PendingRequestList;
PendingRequestList pending_requests_;
- Delegate* delegate_;
-
// Specified by unit-tests, to use this proxy service in place of the
// global one.
scoped_refptr<net::ProxyService> proxy_service_override_;