| 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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 net::URLRequestStatus status; | 1308 net::URLRequestStatus status; |
| 1311 | 1309 |
| 1312 void* iter = NULL; | 1310 void* iter = NULL; |
| 1313 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); | 1311 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); |
| 1314 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); | 1312 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); |
| 1315 | 1313 |
| 1316 EXPECT_EQ(1, request_id); | 1314 EXPECT_EQ(1, request_id); |
| 1317 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); | 1315 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); |
| 1318 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); | 1316 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); |
| 1319 } | 1317 } |
| OLD | NEW |