| OLD | NEW |
| 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 "content/browser/renderer_host/resource_dispatcher_host.h" | 5 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // have a different ID than the original. For the test, we want all the incoming | 167 // have a different ID than the original. For the test, we want all the incoming |
| 168 // messages to go to the same place, which is why this forwards. | 168 // messages to go to the same place, which is why this forwards. |
| 169 class ForwardingFilter : public ResourceMessageFilter { | 169 class ForwardingFilter : public ResourceMessageFilter { |
| 170 public: | 170 public: |
| 171 explicit ForwardingFilter(IPC::Message::Sender* dest) | 171 explicit ForwardingFilter(IPC::Message::Sender* dest) |
| 172 : ResourceMessageFilter( | 172 : ResourceMessageFilter( |
| 173 ChildProcessHostImpl::GenerateChildProcessUniqueId(), | 173 ChildProcessHostImpl::GenerateChildProcessUniqueId(), |
| 174 content::PROCESS_TYPE_RENDERER, | 174 content::PROCESS_TYPE_RENDERER, |
| 175 content::MockResourceContext::GetInstance(), | 175 content::MockResourceContext::GetInstance(), |
| 176 new MockURLRequestContextSelector( | 176 new MockURLRequestContextSelector( |
| 177 content::MockResourceContext::GetInstance()->request_context()), | 177 content::MockResourceContext::GetInstance()->request_context())), |
| 178 NULL), | |
| 179 dest_(dest) { | 178 dest_(dest) { |
| 180 OnChannelConnected(base::GetCurrentProcId()); | 179 OnChannelConnected(base::GetCurrentProcId()); |
| 181 } | 180 } |
| 182 | 181 |
| 183 // ResourceMessageFilter override | 182 // ResourceMessageFilter override |
| 184 virtual bool Send(IPC::Message* msg) { | 183 virtual bool Send(IPC::Message* msg) { |
| 185 if (!dest_) | 184 if (!dest_) |
| 186 return false; | 185 return false; |
| 187 return dest_->Send(msg); | 186 return dest_->Send(msg); |
| 188 } | 187 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 URLRequestTestDelayedStartJob* | 269 URLRequestTestDelayedStartJob* |
| 271 URLRequestTestDelayedStartJob::list_head_ = NULL; | 270 URLRequestTestDelayedStartJob::list_head_ = NULL; |
| 272 | 271 |
| 273 class ResourceDispatcherHostTest : public testing::Test, | 272 class ResourceDispatcherHostTest : public testing::Test, |
| 274 public IPC::Message::Sender { | 273 public IPC::Message::Sender { |
| 275 public: | 274 public: |
| 276 ResourceDispatcherHostTest() | 275 ResourceDispatcherHostTest() |
| 277 : ui_thread_(BrowserThread::UI, &message_loop_), | 276 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 278 io_thread_(BrowserThread::IO, &message_loop_), | 277 io_thread_(BrowserThread::IO, &message_loop_), |
| 279 ALLOW_THIS_IN_INITIALIZER_LIST(filter_(new ForwardingFilter(this))), | 278 ALLOW_THIS_IN_INITIALIZER_LIST(filter_(new ForwardingFilter(this))), |
| 280 host_(ResourceQueue::DelegateSet()), | |
| 281 old_factory_(NULL), | 279 old_factory_(NULL), |
| 282 resource_type_(ResourceType::SUB_RESOURCE) { | 280 resource_type_(ResourceType::SUB_RESOURCE) { |
| 283 } | 281 } |
| 284 // IPC::Message::Sender implementation | 282 // IPC::Message::Sender implementation |
| 285 virtual bool Send(IPC::Message* msg) { | 283 virtual bool Send(IPC::Message* msg) { |
| 286 accum_.AddMessage(*msg); | 284 accum_.AddMessage(*msg); |
| 287 delete msg; | 285 delete msg; |
| 288 return true; | 286 return true; |
| 289 } | 287 } |
| 290 | 288 |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 EXPECT_EQ(1, host_.pending_requests()); | 1275 EXPECT_EQ(1, host_.pending_requests()); |
| 1278 | 1276 |
| 1279 // Cancelling by other methods shouldn't work either. | 1277 // Cancelling by other methods shouldn't work either. |
| 1280 host_.CancelRequestsForProcess(render_view_id); | 1278 host_.CancelRequestsForProcess(render_view_id); |
| 1281 EXPECT_EQ(1, host_.pending_requests()); | 1279 EXPECT_EQ(1, host_.pending_requests()); |
| 1282 | 1280 |
| 1283 // Cancelling by context should work. | 1281 // Cancelling by context should work. |
| 1284 host_.CancelRequestsForContext(&filter_->resource_context()); | 1282 host_.CancelRequestsForContext(&filter_->resource_context()); |
| 1285 EXPECT_EQ(0, host_.pending_requests()); | 1283 EXPECT_EQ(0, host_.pending_requests()); |
| 1286 } | 1284 } |
| OLD | NEW |