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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 24514003: Make BrowserMessageFilter not derive from IPC::ChannelProxy::MessageFilter. This allows us to hide … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 2 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 | Annotate | Revision Log
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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 public: 169 public:
170 explicit ForwardingFilter(IPC::Sender* dest, 170 explicit ForwardingFilter(IPC::Sender* dest,
171 ResourceContext* resource_context) 171 ResourceContext* resource_context)
172 : ResourceMessageFilter( 172 : ResourceMessageFilter(
173 ChildProcessHostImpl::GenerateChildProcessUniqueId(), 173 ChildProcessHostImpl::GenerateChildProcessUniqueId(),
174 PROCESS_TYPE_RENDERER, NULL, NULL, NULL, 174 PROCESS_TYPE_RENDERER, NULL, NULL, NULL,
175 base::Bind(&ForwardingFilter::GetContexts, 175 base::Bind(&ForwardingFilter::GetContexts,
176 base::Unretained(this))), 176 base::Unretained(this))),
177 dest_(dest), 177 dest_(dest),
178 resource_context_(resource_context) { 178 resource_context_(resource_context) {
179 OnChannelConnected(base::GetCurrentProcId()); 179 set_peer_pid_for_testing(base::GetCurrentProcId());
180 } 180 }
181 181
182 // ResourceMessageFilter override 182 // ResourceMessageFilter override
183 virtual bool Send(IPC::Message* msg) OVERRIDE { 183 virtual bool Send(IPC::Message* msg) OVERRIDE {
184 if (!dest_) 184 if (!dest_)
185 return false; 185 return false;
186 return dest_->Send(msg); 186 return dest_->Send(msg);
187 } 187 }
188 188
189 ResourceContext* resource_context() { return resource_context_; } 189 ResourceContext* resource_context() { return resource_context_; }
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 first_request_msg, first_filter.get(), &msg_was_ok); 1797 first_request_msg, first_filter.get(), &msg_was_ok);
1798 base::MessageLoop::current()->RunUntilIdle(); 1798 base::MessageLoop::current()->RunUntilIdle();
1799 } 1799 }
1800 // The first filter is now deleted, as if the child process died. 1800 // The first filter is now deleted, as if the child process died.
1801 1801
1802 // Restore. 1802 // Restore.
1803 SetBrowserClientForTesting(old_client); 1803 SetBrowserClientForTesting(old_client);
1804 1804
1805 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted. 1805 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted.
1806 GlobalRequestID first_global_request_id(first_child_id, request_id); 1806 GlobalRequestID first_global_request_id(first_child_id, request_id);
1807 const ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(
1808 host_.GetURLRequest(first_global_request_id));
1809 EXPECT_FALSE(info->filter());
1810 1807
1811 // This second filter is used to emulate a second process. 1808 // This second filter is used to emulate a second process.
1812 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter( 1809 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
1813 this, browser_context_->GetResourceContext()); 1810 this, browser_context_->GetResourceContext());
1814 1811
1815 int new_render_view_id = 1; 1812 int new_render_view_id = 1;
1816 int new_request_id = 2; 1813 int new_request_id = 2;
1817 1814
1818 const std::string kResponseBody = "hello world"; 1815 const std::string kResponseBody = "hello world";
1819 SetResponse("HTTP/1.1 200 OK\n" 1816 SetResponse("HTTP/1.1 200 OK\n"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 } 2086 }
2090 2087
2091 base::MessageLoop::current()->RunUntilIdle(); 2088 base::MessageLoop::current()->RunUntilIdle();
2092 2089
2093 msgs.clear(); 2090 msgs.clear();
2094 accum_.GetClassifiedMessages(&msgs); 2091 accum_.GetClassifiedMessages(&msgs);
2095 } 2092 }
2096 } 2093 }
2097 2094
2098 } // namespace content 2095 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_dispatcher_host.cc ('k') | content/browser/loader/resource_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698