summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--chrome/browser/browser_shutdown.cc1
-rw-r--r--chrome/browser/net/resolve_proxy_msg_helper.cc28
-rw-r--r--chrome/browser/net/resolve_proxy_msg_helper.h52
-rw-r--r--chrome/browser/net/resolve_proxy_msg_helper_unittest.cc230
-rw-r--r--chrome/browser/plugin_data_remover.cc1
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc3
-rw-r--r--chrome/common/render_messages.h8
-rw-r--r--chrome/plugin/plugin_thread.cc15
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc6
-rw-r--r--content/browser/plugin_process_host.cc21
-rw-r--r--content/browser/plugin_process_host.h16
-rw-r--r--content/browser/renderer_host/render_message_filter.cc15
-rw-r--r--content/browser/renderer_host/render_message_filter.h13
-rw-r--r--content/common/child_process_messages.h8
-rw-r--r--content/common/plugin_messages.h10
-rw-r--r--ipc/ipc_test_sink.h2
16 files changed, 177 insertions, 252 deletions
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index d37a45a..72c7735 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -15,6 +15,7 @@
#include "base/process_util.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
+#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
diff --git a/chrome/browser/net/resolve_proxy_msg_helper.cc b/chrome/browser/net/resolve_proxy_msg_helper.cc
index 967e529..01cb3bf 100644
--- a/chrome/browser/net/resolve_proxy_msg_helper.cc
+++ b/chrome/browser/net/resolve_proxy_msg_helper.cc
@@ -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.
@@ -7,19 +7,30 @@
#include "base/compiler_specific.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/net/url_request_context_getter.h"
+#include "content/common/child_process_messages.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request_context.h"
-ResolveProxyMsgHelper::ResolveProxyMsgHelper(Delegate* delegate,
- net::ProxyService* proxy_service)
+ResolveProxyMsgHelper::ResolveProxyMsgHelper(net::ProxyService* proxy_service)
: proxy_service_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
this, &ResolveProxyMsgHelper::OnResolveProxyCompleted)),
- delegate_(delegate),
proxy_service_override_(proxy_service) {
}
-void ResolveProxyMsgHelper::Start(const GURL& url, IPC::Message* reply_msg) {
+bool ResolveProxyMsgHelper::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(ResolveProxyMsgHelper, message, *message_was_ok)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ChildProcessHostMsg_ResolveProxy,
+ OnResolveProxy)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void ResolveProxyMsgHelper::OnResolveProxy(const GURL& url,
+ IPC::Message* reply_msg) {
// Enqueue the pending request.
pending_requests_.push_back(PendingRequest(url, reply_msg));
@@ -31,11 +42,10 @@ void ResolveProxyMsgHelper::Start(const GURL& url, IPC::Message* reply_msg) {
void ResolveProxyMsgHelper::OnResolveProxyCompleted(int result) {
CHECK(!pending_requests_.empty());
- // Notify the delegate of completion.
const PendingRequest& completed_req = pending_requests_.front();
- delegate_->OnResolveProxyCompleted(completed_req.reply_msg,
- result,
- proxy_info_.ToPacString());
+ ChildProcessHostMsg_ResolveProxy::WriteReplyParams(
+ completed_req.reply_msg, result, proxy_info_.ToPacString());
+ Send(completed_req.reply_msg);
// Clear the current (completed) request.
pending_requests_.pop_front();
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_;
diff --git a/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc b/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc
index 3bdb695..dffd0cf 100644
--- a/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc
+++ b/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2010 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.
#include "chrome/browser/net/resolve_proxy_msg_helper.h"
+#include "content/common/child_process_messages.h"
+#include "ipc/ipc_test_sink.h"
#include "net/base/net_errors.h"
#include "net/proxy/mock_proxy_resolver.h"
#include "net/proxy/proxy_config_service.h"
@@ -20,213 +22,213 @@ class MockProxyConfigService : public net::ProxyConfigService {
}
};
-class MyDelegate : public ResolveProxyMsgHelper::Delegate {
+class ResolveProxyMsgHelperTest : public testing::Test,
+ public IPC::Channel::Listener {
public:
struct PendingResult {
- PendingResult(IPC::Message* msg,
- int error_code,
+ PendingResult(int error_code,
const std::string& proxy_list)
- : msg(msg), error_code(error_code), proxy_list(proxy_list) {
+ : error_code(error_code), proxy_list(proxy_list) {
}
- IPC::Message* msg;
int error_code;
std::string proxy_list;
};
- // ResolveProxyMsgHelper::Delegate implementation:
- virtual void OnResolveProxyCompleted(IPC::Message* reply_msg,
- int error_code,
- const std::string& proxy_list) {
- DCHECK(!pending_result_.get());
- pending_result_.reset(new PendingResult(reply_msg, error_code, proxy_list));
+ ResolveProxyMsgHelperTest()
+ : resolver_(new net::MockAsyncProxyResolver),
+ service_(new net::ProxyService(
+ new MockProxyConfigService, resolver_, NULL)),
+ helper_(new ResolveProxyMsgHelper(service_.get())),
+ message_loop_(MessageLoop::TYPE_IO),
+ io_thread_(BrowserThread::IO, &message_loop_) {
+ test_sink_.AddFilter(this);
+ helper_->OnFilterAdded(&test_sink_);
}
+ protected:
const PendingResult* pending_result() const { return pending_result_.get(); }
void clear_pending_result() {
pending_result_.reset();
}
- private:
+ IPC::Message* GenerateReply() {
+ int temp_int;
+ std::string temp_string;
+ ChildProcessHostMsg_ResolveProxy message(GURL(), &temp_int, &temp_string);
+ return IPC::SyncMessage::GenerateReply(&message);
+ }
+
+ net::MockAsyncProxyResolver* resolver_;
+ scoped_refptr<net::ProxyService> service_;
+ scoped_refptr<ResolveProxyMsgHelper> helper_;
scoped_ptr<PendingResult> pending_result_;
-};
-// Issue three sequential requests -- each should succeed.
-TEST(ResolveProxyMsgHelperTest, Sequential) {
- net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
- scoped_refptr<net::ProxyService> service(
- new net::ProxyService(new MockProxyConfigService, resolver, NULL));
+ private:
+ virtual bool OnMessageReceived(const IPC::Message& msg) {
+ TupleTypes<ChildProcessHostMsg_ResolveProxy::ReplyParam>::ValueTuple
+ reply_data;
+ EXPECT_TRUE(
+ ChildProcessHostMsg_ResolveProxy::ReadReplyParam(&msg, &reply_data));
+ DCHECK(!pending_result_.get());
+ pending_result_.reset(new PendingResult(reply_data.a, reply_data.b));
+ test_sink_.ClearMessages();
+ return true;
+ }
- MyDelegate delegate;
- ResolveProxyMsgHelper helper(&delegate, service);
+ MessageLoop message_loop_;
+ BrowserThread io_thread_;
+ IPC::TestSink test_sink_;
+};
+// Issue three sequential requests -- each should succeed.
+TEST_F(ResolveProxyMsgHelperTest, Sequential) {
GURL url1("http://www.google1.com/");
GURL url2("http://www.google2.com/");
GURL url3("http://www.google3.com/");
- scoped_ptr<IPC::Message> msg1(new IPC::Message());
- scoped_ptr<IPC::Message> msg2(new IPC::Message());
- scoped_ptr<IPC::Message> msg3(new IPC::Message());
+ // Messages are deleted by the sink.
+ IPC::Message* msg1 = GenerateReply();
+ IPC::Message* msg2 = GenerateReply();
+ IPC::Message* msg3 = GenerateReply();
// Execute each request sequentially (so there are never 2 requests
// outstanding at the same time).
- helper.Start(url1, msg1.get());
+ helper_->OnResolveProxy(url1, msg1);
// Finish ProxyService's initialization.
- resolver->pending_set_pac_script_request()->CompleteNow(net::OK);
+ resolver_->pending_set_pac_script_request()->CompleteNow(net::OK);
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url1, resolver->pending_requests()[0]->url());
- resolver->pending_requests()[0]->results()->UseNamedProxy("result1:80");
- resolver->pending_requests()[0]->CompleteNow(net::OK);
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url1, resolver_->pending_requests()[0]->url());
+ resolver_->pending_requests()[0]->results()->UseNamedProxy("result1:80");
+ resolver_->pending_requests()[0]->CompleteNow(net::OK);
// Check result.
- EXPECT_EQ(msg1.get(), delegate.pending_result()->msg);
- EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
- EXPECT_EQ("PROXY result1:80", delegate.pending_result()->proxy_list);
- delegate.clear_pending_result();
+ EXPECT_EQ(net::OK, pending_result()->error_code);
+ EXPECT_EQ("PROXY result1:80", pending_result()->proxy_list);
+ clear_pending_result();
- helper.Start(url2, msg2.get());
+ helper_->OnResolveProxy(url2, msg2);
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url2, resolver->pending_requests()[0]->url());
- resolver->pending_requests()[0]->results()->UseNamedProxy("result2:80");
- resolver->pending_requests()[0]->CompleteNow(net::OK);
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url2, resolver_->pending_requests()[0]->url());
+ resolver_->pending_requests()[0]->results()->UseNamedProxy("result2:80");
+ resolver_->pending_requests()[0]->CompleteNow(net::OK);
// Check result.
- EXPECT_EQ(msg2.get(), delegate.pending_result()->msg);
- EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
- EXPECT_EQ("PROXY result2:80", delegate.pending_result()->proxy_list);
- delegate.clear_pending_result();
+ EXPECT_EQ(net::OK, pending_result()->error_code);
+ EXPECT_EQ("PROXY result2:80", pending_result()->proxy_list);
+ clear_pending_result();
- helper.Start(url3, msg3.get());
+ helper_->OnResolveProxy(url3, msg3);
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url3, resolver->pending_requests()[0]->url());
- resolver->pending_requests()[0]->results()->UseNamedProxy("result3:80");
- resolver->pending_requests()[0]->CompleteNow(net::OK);
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url3, resolver_->pending_requests()[0]->url());
+ resolver_->pending_requests()[0]->results()->UseNamedProxy("result3:80");
+ resolver_->pending_requests()[0]->CompleteNow(net::OK);
// Check result.
- EXPECT_EQ(msg3.get(), delegate.pending_result()->msg);
- EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
- EXPECT_EQ("PROXY result3:80", delegate.pending_result()->proxy_list);
- delegate.clear_pending_result();
+ EXPECT_EQ(net::OK, pending_result()->error_code);
+ EXPECT_EQ("PROXY result3:80", pending_result()->proxy_list);
+ clear_pending_result();
}
// Issue a request while one is already in progress -- should be queued.
-TEST(ResolveProxyMsgHelperTest, QueueRequests) {
- net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
- scoped_refptr<net::ProxyService> service(
- new net::ProxyService(new MockProxyConfigService, resolver, NULL));
-
- MyDelegate delegate;
- ResolveProxyMsgHelper helper(&delegate, service);
-
+TEST_F(ResolveProxyMsgHelperTest, QueueRequests) {
GURL url1("http://www.google1.com/");
GURL url2("http://www.google2.com/");
GURL url3("http://www.google3.com/");
- scoped_ptr<IPC::Message> msg1(new IPC::Message());
- scoped_ptr<IPC::Message> msg2(new IPC::Message());
- scoped_ptr<IPC::Message> msg3(new IPC::Message());
+ IPC::Message* msg1 = GenerateReply();
+ IPC::Message* msg2 = GenerateReply();
+ IPC::Message* msg3 = GenerateReply();
// Start three requests. Since the proxy resolver is async, all the
// requests will be pending.
- helper.Start(url1, msg1.get());
+ helper_->OnResolveProxy(url1, msg1);
// Finish ProxyService's initialization.
- resolver->pending_set_pac_script_request()->CompleteNow(net::OK);
+ resolver_->pending_set_pac_script_request()->CompleteNow(net::OK);
- helper.Start(url2, msg2.get());
- helper.Start(url3, msg3.get());
+ helper_->OnResolveProxy(url2, msg2);
+ helper_->OnResolveProxy(url3, msg3);
// ResolveProxyHelper only keeps 1 request outstanding in ProxyService
// at a time.
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url1, resolver->pending_requests()[0]->url());
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url1, resolver_->pending_requests()[0]->url());
- resolver->pending_requests()[0]->results()->UseNamedProxy("result1:80");
- resolver->pending_requests()[0]->CompleteNow(net::OK);
+ resolver_->pending_requests()[0]->results()->UseNamedProxy("result1:80");
+ resolver_->pending_requests()[0]->CompleteNow(net::OK);
// Check result.
- EXPECT_EQ(msg1.get(), delegate.pending_result()->msg);
- EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
- EXPECT_EQ("PROXY result1:80", delegate.pending_result()->proxy_list);
- delegate.clear_pending_result();
+ EXPECT_EQ(net::OK, pending_result()->error_code);
+ EXPECT_EQ("PROXY result1:80", pending_result()->proxy_list);
+ clear_pending_result();
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url2, resolver->pending_requests()[0]->url());
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url2, resolver_->pending_requests()[0]->url());
- resolver->pending_requests()[0]->results()->UseNamedProxy("result2:80");
- resolver->pending_requests()[0]->CompleteNow(net::OK);
+ resolver_->pending_requests()[0]->results()->UseNamedProxy("result2:80");
+ resolver_->pending_requests()[0]->CompleteNow(net::OK);
// Check result.
- EXPECT_EQ(msg2.get(), delegate.pending_result()->msg);
- EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
- EXPECT_EQ("PROXY result2:80", delegate.pending_result()->proxy_list);
- delegate.clear_pending_result();
+ EXPECT_EQ(net::OK, pending_result()->error_code);
+ EXPECT_EQ("PROXY result2:80", pending_result()->proxy_list);
+ clear_pending_result();
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url3, resolver->pending_requests()[0]->url());
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url3, resolver_->pending_requests()[0]->url());
- resolver->pending_requests()[0]->results()->UseNamedProxy("result3:80");
- resolver->pending_requests()[0]->CompleteNow(net::OK);
+ resolver_->pending_requests()[0]->results()->UseNamedProxy("result3:80");
+ resolver_->pending_requests()[0]->CompleteNow(net::OK);
// Check result.
- EXPECT_EQ(msg3.get(), delegate.pending_result()->msg);
- EXPECT_EQ(net::OK, delegate.pending_result()->error_code);
- EXPECT_EQ("PROXY result3:80", delegate.pending_result()->proxy_list);
- delegate.clear_pending_result();
+ EXPECT_EQ(net::OK, pending_result()->error_code);
+ EXPECT_EQ("PROXY result3:80", pending_result()->proxy_list);
+ clear_pending_result();
}
// Delete the helper while a request is in progress, and others are pending.
-TEST(ResolveProxyMsgHelperTest, CancelPendingRequests) {
- net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
- scoped_refptr<net::ProxyService> service(
- new net::ProxyService(new MockProxyConfigService, resolver, NULL));
-
- MyDelegate delegate;
- scoped_ptr<ResolveProxyMsgHelper> helper(
- new ResolveProxyMsgHelper(&delegate, service));
-
+TEST_F(ResolveProxyMsgHelperTest, CancelPendingRequests) {
GURL url1("http://www.google1.com/");
GURL url2("http://www.google2.com/");
GURL url3("http://www.google3.com/");
- // NOTE: these are not scoped ptr, since they will be deleted by the
- // request's cancellation.
- IPC::Message* msg1 = new IPC::Message();
- IPC::Message* msg2 = new IPC::Message();
- IPC::Message* msg3 = new IPC::Message();
+ // They will be deleted by the request's cancellation.
+ IPC::Message* msg1 = GenerateReply();
+ IPC::Message* msg2 = GenerateReply();
+ IPC::Message* msg3 = GenerateReply();
// Start three requests. Since the proxy resolver is async, all the
// requests will be pending.
- helper->Start(url1, msg1);
+ helper_->OnResolveProxy(url1, msg1);
// Finish ProxyService's initialization.
- resolver->pending_set_pac_script_request()->CompleteNow(net::OK);
+ resolver_->pending_set_pac_script_request()->CompleteNow(net::OK);
- helper->Start(url2, msg2);
- helper->Start(url3, msg3);
+ helper_->OnResolveProxy(url2, msg2);
+ helper_->OnResolveProxy(url3, msg3);
// ResolveProxyHelper only keeps 1 request outstanding in ProxyService
// at a time.
- ASSERT_EQ(1u, resolver->pending_requests().size());
- EXPECT_EQ(url1, resolver->pending_requests()[0]->url());
+ ASSERT_EQ(1u, resolver_->pending_requests().size());
+ EXPECT_EQ(url1, resolver_->pending_requests()[0]->url());
// Delete the underlying ResolveProxyMsgHelper -- this should cancel all
// the requests which are outstanding.
- helper.reset();
+ helper_ = NULL;
// The pending requests sent to the proxy resolver should have been cancelled.
- EXPECT_EQ(0u, resolver->pending_requests().size());
+ EXPECT_EQ(0u, resolver_->pending_requests().size());
- EXPECT_TRUE(delegate.pending_result() == NULL);
+ EXPECT_TRUE(pending_result() == NULL);
// It should also be the case that msg1, msg2, msg3 were deleted by the
// cancellation. (Else will show up as a leak in Purify/Valgrind).
diff --git a/chrome/browser/plugin_data_remover.cc b/chrome/browser/plugin_data_remover.cc
index d4c1cef..ebbacc4 100644
--- a/chrome/browser/plugin_data_remover.cc
+++ b/chrome/browser/plugin_data_remover.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/message_loop_proxy.h"
#include "base/metrics/histogram.h"
+#include "base/synchronization/waitable_event.h"
#include "base/version.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/browser_thread.h"
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index dcb8ba7..e4698c9 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -37,6 +37,7 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/net/resolve_proxy_msg_helper.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/printing/printing_message_filter.h"
#include "chrome/browser/profiles/profile.h"
@@ -493,6 +494,8 @@ void BrowserRenderProcessHost::CreateMessageFilters() {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableP2PApi))
channel_->AddFilter(new P2PSocketsHost());
+
+ channel_->AddFilter(new ResolveProxyMsgHelper(NULL));
}
int BrowserRenderProcessHost::GetNextRoutingID() {
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 3c8d989..b12f474 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1938,14 +1938,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetRootWindowRect,
gfx::NativeViewId /* window */,
gfx::Rect /* Out: Window location */)
-// Get the list of proxies to use for |url|, as a semicolon delimited list
-// of "<TYPE> <HOST>:<PORT>" | "DIRECT". See also
-// PluginProcessHostMsg_ResolveProxy which does the same thing.
-IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_ResolveProxy,
- GURL /* url */,
- int /* network error */,
- std::string /* proxy list */)
-
// Request that got sent to browser for creating an audio output stream
IPC_MESSAGE_ROUTED3(ViewHostMsg_CreateAudioStream,
int /* stream_id */,
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index c6c6842..66e780a 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -20,10 +20,10 @@
#include "base/process_util.h"
#include "base/threading/thread_local.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/render_messages.h"
#include "chrome/plugin/npobject_util.h"
#include "chrome/renderer/render_thread.h"
#include "content/common/child_process.h"
+#include "content/common/child_process_messages.h"
#include "content/common/plugin_messages.h"
#include "ipc/ipc_channel_handle.h"
#include "net/base/net_errors.h"
@@ -193,21 +193,12 @@ bool IsDefaultPluginEnabled() {
return true;
}
-// Dispatch the resolve proxy resquest to the right code, depending on which
-// process the plugin is running in {renderer, browser, plugin}.
bool FindProxyForUrl(const GURL& url, std::string* proxy_list) {
int net_error;
std::string proxy_result;
- bool result;
- if (IsPluginProcess()) {
- result = PluginThread::current()->Send(
- new PluginProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result));
- } else {
- result = RenderThread::current()->Send(
- new ViewHostMsg_ResolveProxy(url, &net_error, &proxy_result));
- }
-
+ bool result = ChildThread::current()->Send(
+ new ChildProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result));
if (!result || net_error != net::OK)
return false;
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index e3687a8..a34f1e90 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -29,6 +29,7 @@
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h"
#include "chrome/renderer/webplugin_delegate_proxy.h"
+#include "content/common/child_process_messages.h"
#include "content/common/child_thread.h"
#include "content/common/file_system/file_system_dispatcher.h"
#include "grit/locale_settings.h"
@@ -930,9 +931,8 @@ void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor,
std::string PepperPluginDelegateImpl::ResolveProxy(const GURL& url) {
int net_error;
std::string proxy_result;
- IPC::Message* msg =
- new ViewHostMsg_ResolveProxy(url, &net_error, &proxy_result);
- RenderThread::current()->Send(msg);
+ RenderThread::current()->Send(
+ new ChildProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result));
return proxy_result;
}
diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc
index 73b2f4a..c398d56 100644
--- a/content/browser/plugin_process_host.cc
+++ b/content/browser/plugin_process_host.cc
@@ -21,6 +21,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/net/resolve_proxy_msg_helper.h"
#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/plugin_download_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -95,8 +96,7 @@ void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id,
PluginProcessHost::PluginProcessHost()
: BrowserChildProcessHost(
PLUGIN_PROCESS,
- PluginService::GetInstance()->resource_dispatcher_host()),
- ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL))
+ PluginService::GetInstance()->resource_dispatcher_host())
#if defined(OS_MACOSX)
, plugin_cursor_visible_(true)
#endif
@@ -245,6 +245,8 @@ bool PluginProcessHost::Init(const webkit::npapi::WebPluginInfo& info,
#endif
cmd_line);
+ AddFilter(new ResolveProxyMsgHelper(NULL));
+
return true;
}
@@ -260,8 +262,6 @@ bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_GetPluginFinderUrl,
OnGetPluginFinderUrl)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginProcessHostMsg_ResolveProxy,
- OnResolveProxy)
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed,
OnPluginWindowDestroyed)
@@ -330,19 +330,6 @@ void PluginProcessHost::OpenChannelToPlugin(Client* client) {
RequestPluginChannel(client);
}
-void PluginProcessHost::OnResolveProxy(const GURL& url,
- IPC::Message* reply_msg) {
- resolve_proxy_msg_helper_.Start(url, reply_msg);
-}
-
-void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg,
- int result,
- const std::string& proxy_list) {
- PluginProcessHostMsg_ResolveProxy::WriteReplyParams(
- reply_msg, result, proxy_list);
- Send(reply_msg);
-}
-
void PluginProcessHost::RequestPluginChannel(Client* client) {
// We can't send any sync messages from the browser because it might lead to
// a hang. However this async messages must be answered right away by the
diff --git a/content/browser/plugin_process_host.h b/content/browser/plugin_process_host.h
index 14d1a6f..a7be1c3 100644
--- a/content/browser/plugin_process_host.h
+++ b/content/browser/plugin_process_host.h
@@ -15,7 +15,6 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
-#include "chrome/browser/net/resolve_proxy_msg_helper.h"
#include "content/browser/browser_child_process_host.h"
#include "ui/gfx/native_widget_types.h"
#include "webkit/plugins/npapi/webplugininfo.h"
@@ -38,8 +37,7 @@ class GURL;
// starting the plugin process when a plugin is created that doesn't already
// have a process. After that, most of the communication is directly between
// the renderer and plugin processes.
-class PluginProcessHost : public BrowserChildProcessHost,
- public ResolveProxyMsgHelper::Delegate {
+class PluginProcessHost : public BrowserChildProcessHost {
public:
class Client {
public:
@@ -70,11 +68,6 @@ class PluginProcessHost : public BrowserChildProcessHost,
virtual void OnChannelConnected(int32 peer_pid);
virtual void OnChannelError();
- // ResolveProxyMsgHelper::Delegate implementation:
- virtual void OnResolveProxyCompleted(IPC::Message* reply_msg,
- int result,
- const std::string& proxy_list);
-
// Tells the plugin process to create a new channel for communication with a
// renderer. When the plugin process responds with the channel name,
// OnChannelOpened in the client is called.
@@ -100,8 +93,6 @@ class PluginProcessHost : public BrowserChildProcessHost,
#endif
private:
- friend class PluginResolveProxyHelper;
-
// Sends a message to the plugin process to request creation of a new channel
// for the given mime type.
void RequestPluginChannel(Client* client);
@@ -109,7 +100,6 @@ class PluginProcessHost : public BrowserChildProcessHost,
// Message handlers.
void OnChannelCreated(const IPC::ChannelHandle& channel_handle);
void OnGetPluginFinderUrl(std::string* plugin_finder_url);
- void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
#if defined(OS_WIN)
void OnPluginWindowDestroyed(HWND window, HWND parent);
@@ -145,10 +135,6 @@ class PluginProcessHost : public BrowserChildProcessHost,
// Information about the plugin.
webkit::npapi::WebPluginInfo info_;
- // Helper class for handling PluginProcessHost_ResolveProxy messages (manages
- // the requests to the proxy service).
- ResolveProxyMsgHelper resolve_proxy_msg_helper_;
-
#if defined(OS_WIN)
// Tracks plugin parent windows created on the UI thread.
std::set<HWND> plugin_parent_windows_set_;
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 0a29798..0c5c83a 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -284,7 +284,6 @@ RenderMessageFilter::RenderMessageFilter(
plugin_service_(plugin_service),
profile_(profile),
content_settings_(profile->GetHostContentSettingsMap()),
- ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
extensions_request_context_(profile->GetRequestContextForExtensions()),
render_widget_helper_(render_widget_helper),
notification_prefs_(
@@ -372,7 +371,6 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_ResourceTypeStats, OnResourceTypeStats)
IPC_MESSAGE_HANDLER(ViewHostMsg_V8HeapStats, OnV8HeapStats)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ResolveProxy, OnResolveProxy)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewHostMsg_AllocTransportDIB, OnAllocTransportDIB)
IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, OnFreeTransportDIB)
@@ -867,19 +865,6 @@ void RenderMessageFilter::UpdateHostZoomLevelsOnUIThread(
}
}
-void RenderMessageFilter::OnResolveProxy(const GURL& url,
- IPC::Message* reply_msg) {
- resolve_proxy_msg_helper_.Start(url, reply_msg);
-}
-
-void RenderMessageFilter::OnResolveProxyCompleted(
- IPC::Message* reply_msg,
- int result,
- const std::string& proxy_list) {
- ViewHostMsg_ResolveProxy::WriteReplyParams(reply_msg, result, proxy_list);
- Send(reply_msg);
-}
-
ChromeURLRequestContext* RenderMessageFilter::GetRequestContextForURL(
const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 2edcc53..ab6ba38 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -20,7 +20,6 @@
#include "base/string16.h"
#include "base/task.h"
#include "build/build_config.h"
-#include "chrome/browser/net/resolve_proxy_msg_helper.h"
#include "chrome/common/content_settings.h"
#include "content/browser/browser_message_filter.h"
#include "content/browser/in_process_webkit/webkit_context.h"
@@ -56,8 +55,7 @@ class CookieStore;
// This class filters out incoming IPC messages for the renderer process on the
// IPC thread.
-class RenderMessageFilter : public BrowserMessageFilter,
- public ResolveProxyMsgHelper::Delegate {
+class RenderMessageFilter : public BrowserMessageFilter {
public:
// Create the filter.
RenderMessageFilter(int render_process_id,
@@ -215,11 +213,6 @@ class RenderMessageFilter : public BrowserMessageFilter,
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
- // ResolveProxyMsgHelper::Delegate implementation:
- virtual void OnResolveProxyCompleted(IPC::Message* reply_msg,
- int result,
- const std::string& proxy_list);
-
// Browser side transport DIB allocation
void OnAllocTransportDIB(size_t size,
bool cache_in_browser,
@@ -297,10 +290,6 @@ class RenderMessageFilter : public BrowserMessageFilter,
// access it on other threads.
HostContentSettingsMap* content_settings_;
- // Helper class for handling PluginProcessHost_ResolveProxy messages (manages
- // the requests to the proxy service).
- ResolveProxyMsgHelper resolve_proxy_msg_helper_;
-
// Contextual information to be used for requests created here.
scoped_refptr<URLRequestContextGetter> request_context_;
diff --git a/content/common/child_process_messages.h b/content/common/child_process_messages.h
index ce02ec9..85c824e 100644
--- a/content/common/child_process_messages.h
+++ b/content/common/child_process_messages.h
@@ -5,6 +5,7 @@
// Common IPC messages used for child processes.
// Multiply-included message file, hence no include guard.
+#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START ChildProcessMsgStart
@@ -27,3 +28,10 @@ IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
// Messages sent from the child process to the browser.
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
+
+// Get the list of proxies to use for |url|, as a semicolon delimited list
+// of "<TYPE> <HOST>:<PORT>" | "DIRECT".
+IPC_SYNC_MESSAGE_CONTROL1_2(ChildProcessHostMsg_ResolveProxy,
+ GURL /* url */,
+ int /* network error */,
+ std::string /* proxy list */) \ No newline at end of file
diff --git a/content/common/plugin_messages.h b/content/common/plugin_messages.h
index b8bd205..23f271e 100644
--- a/content/common/plugin_messages.h
+++ b/content/common/plugin_messages.h
@@ -92,16 +92,6 @@ IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_ChannelCreated,
IPC_SYNC_MESSAGE_CONTROL0_1(PluginProcessHostMsg_GetPluginFinderUrl,
std::string /* plugin finder URL */)
-IPC_MESSAGE_CONTROL0(PluginProcessHostMsg_ShutdownRequest)
-
-// Get the list of proxies to use for |url|, as a semicolon delimited list
-// of "<TYPE> <HOST>:<PORT>" | "DIRECT". See also ViewHostMsg_ResolveProxy
-// which does the same thing.
-IPC_SYNC_MESSAGE_CONTROL1_2(PluginProcessHostMsg_ResolveProxy,
- GURL /* url */,
- int /* network error */,
- std::string /* proxy list */)
-
#if defined(OS_WIN)
// Destroys the given window's parent on the UI thread.
IPC_MESSAGE_CONTROL2(PluginProcessHostMsg_PluginWindowDestroyed,
diff --git a/ipc/ipc_test_sink.h b/ipc/ipc_test_sink.h
index bac8943..c8c2114 100644
--- a/ipc/ipc_test_sink.h
+++ b/ipc/ipc_test_sink.h
@@ -46,7 +46,7 @@ class Message;
//
// IPC::Message* msg = test_sink.GetUniqueMessageMatching(IPC_REPLY_ID);
// ASSERT_TRUE(msg);
-// TupleTypes<ViewHostMsg_Foo::ReplyParam>::ValueType reply_data;
+// TupleTypes<ViewHostMsg_Foo::ReplyParam>::ValueTuple reply_data;
// EXPECT_TRUE(ViewHostMsg_Foo::ReadReplyParam(msg, &reply_data));
//
// You can also register to be notified when messages are posted to the sink.