Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| 11 #include "chrome/browser/child_process_security_policy.h" | 11 #include "chrome/browser/child_process_security_policy.h" |
| 12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 13 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" | 13 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 14 #include "chrome/browser/renderer_host/resource_handler.h" | 14 #include "chrome/browser/renderer_host/resource_handler.h" |
| 15 #include "chrome/browser/renderer_host/resource_message_filter.h" | |
| 15 #include "chrome/common/chrome_plugin_lib.h" | 16 #include "chrome/common/chrome_plugin_lib.h" |
| 16 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
| 17 #include "chrome/common/render_messages_params.h" | 18 #include "chrome/common/render_messages_params.h" |
| 18 #include "chrome/common/resource_response.h" | 19 #include "chrome/common/resource_response.h" |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/base/upload_data.h" | 21 #include "net/base/upload_data.h" |
| 21 #include "net/http/http_util.h" | 22 #include "net/http/http_util.h" |
| 22 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 23 #include "net/url_request/url_request_job.h" | 24 #include "net/url_request/url_request_job.h" |
| 24 #include "net/url_request/url_request_test_job.h" | 25 #include "net/url_request/url_request_test_job.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 messages_.erase(messages_.begin() + i); | 121 messages_.erase(messages_.begin() + i); |
| 121 i--; | 122 i--; |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 messages_.erase(messages_.begin()); | 125 messages_.erase(messages_.begin()); |
| 125 msgs->push_back(cur_requests); | 126 msgs->push_back(cur_requests); |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 // This class forwards the incoming messages to the ResourceDispatcherHostTest. | 130 // This class forwards the incoming messages to the ResourceDispatcherHostTest. |
| 130 // This is used to emulate different sub-procseses, since this receiver will | 131 // This is used to emulate different sub-processes, since this filter will |
| 131 // have a different ID than the original. For the test, we want all the incoming | 132 // have a different ID than the original. For the test, we want all the incoming |
| 132 // messages to go to the same place, which is why this forwards. | 133 // messages to go to the same place, which is why this forwards. |
| 133 class ForwardingReceiver : public ResourceDispatcherHost::Receiver { | 134 class ForwardingFilter : public ResourceMessageFilter { |
| 134 public: | 135 public: |
| 135 explicit ForwardingReceiver(ResourceDispatcherHost::Receiver* dest) | 136 explicit ForwardingFilter(IPC::Message::Sender* dest) |
| 136 : ResourceDispatcherHost::Receiver(dest->type(), -1), | 137 : ResourceMessageFilter(ChildProcessInfo::GenerateChildProcessUniqueId(), |
| 138 ChildProcessInfo::RENDER_PROCESS, | |
| 139 NULL), | |
| 137 dest_(dest) { | 140 dest_(dest) { |
| 138 set_handle(dest->handle()); | 141 OnChannelConnected(base::GetCurrentProcId()); |
| 139 } | 142 } |
| 140 | 143 |
| 141 // ResourceDispatcherHost::Receiver implementation | 144 // ResourceMessageFilter override |
| 142 virtual bool Send(IPC::Message* msg) { | 145 virtual bool Send(IPC::Message* msg) { |
| 146 if (!dest_) | |
| 147 return false; | |
| 143 return dest_->Send(msg); | 148 return dest_->Send(msg); |
| 144 } | 149 } |
| 145 URLRequestContext* GetRequestContext( | |
| 146 uint32 request_id, | |
| 147 const ViewHostMsg_Resource_Request& request_data) { | |
| 148 return dest_->GetRequestContext(request_id, request_data); | |
| 149 } | |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 ResourceDispatcherHost::Receiver* dest_; | 152 IPC::Message::Sender* dest_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(ForwardingReceiver); | 154 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 class ResourceDispatcherHostTest : public testing::Test, | 157 class ResourceDispatcherHostTest : public testing::Test, |
| 158 public ResourceDispatcherHost::Receiver { | 158 public IPC::Message::Sender { |
| 159 public: | 159 public: |
| 160 ResourceDispatcherHostTest() | 160 ResourceDispatcherHostTest() |
| 161 : Receiver(ChildProcessInfo::RENDER_PROCESS, -1), | 161 : ALLOW_THIS_IN_INITIALIZER_LIST(filter_(new ForwardingFilter(this))), |
| 162 ui_thread_(BrowserThread::UI, &message_loop_), | 162 ui_thread_(BrowserThread::UI, &message_loop_), |
| 163 io_thread_(BrowserThread::IO, &message_loop_), | 163 io_thread_(BrowserThread::IO, &message_loop_), |
| 164 old_factory_(NULL), | 164 old_factory_(NULL), |
| 165 resource_type_(ResourceType::SUB_RESOURCE) { | 165 resource_type_(ResourceType::SUB_RESOURCE) { |
| 166 set_handle(base::GetCurrentProcessHandle()); | |
| 167 } | 166 } |
| 168 // ResourceDispatcherHost::Receiver implementation | 167 // IPC::Message::Sender implementation |
| 169 virtual bool Send(IPC::Message* msg) { | 168 virtual bool Send(IPC::Message* msg) { |
| 170 accum_.AddMessage(*msg); | 169 accum_.AddMessage(*msg); |
| 171 delete msg; | 170 delete msg; |
| 172 return true; | 171 return true; |
| 173 } | 172 } |
| 174 | 173 |
| 175 URLRequestContext* GetRequestContext( | |
| 176 uint32 request_id, | |
| 177 const ViewHostMsg_Resource_Request& request_data) { | |
| 178 return NULL; | |
| 179 } | |
| 180 | |
| 181 protected: | 174 protected: |
| 182 // testing::Test | 175 // testing::Test |
| 183 virtual void SetUp() { | 176 virtual void SetUp() { |
| 184 DCHECK(!test_fixture_); | 177 DCHECK(!test_fixture_); |
| 185 test_fixture_ = this; | 178 test_fixture_ = this; |
| 186 ChildProcessSecurityPolicy::GetInstance()->Add(0); | 179 ChildProcessSecurityPolicy::GetInstance()->Add(0); |
| 187 net::URLRequest::RegisterProtocolFactory( | 180 net::URLRequest::RegisterProtocolFactory( |
| 188 "test", | 181 "test", |
| 189 &ResourceDispatcherHostTest::Factory); | 182 &ResourceDispatcherHostTest::Factory); |
| 190 EnsureTestSchemeIsAllowed(); | 183 EnsureTestSchemeIsAllowed(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 203 ChildProcessSecurityPolicy::GetInstance()->Remove(0); | 196 ChildProcessSecurityPolicy::GetInstance()->Remove(0); |
| 204 | 197 |
| 205 // The plugin lib is automatically loaded during these test | 198 // The plugin lib is automatically loaded during these test |
| 206 // and we want a clean environment for other tests. | 199 // and we want a clean environment for other tests. |
| 207 ChromePluginLib::UnloadAllPlugins(); | 200 ChromePluginLib::UnloadAllPlugins(); |
| 208 | 201 |
| 209 // Flush the message loop to make Purify happy. | 202 // Flush the message loop to make Purify happy. |
| 210 message_loop_.RunAllPending(); | 203 message_loop_.RunAllPending(); |
| 211 } | 204 } |
| 212 | 205 |
| 213 // Creates a request using the current test object as the receiver. | 206 // Creates a request using the current test object as the filter. |
| 214 void MakeTestRequest(int render_view_id, | 207 void MakeTestRequest(int render_view_id, |
| 215 int request_id, | 208 int request_id, |
| 216 const GURL& url); | 209 const GURL& url); |
| 217 | 210 |
| 218 // Generates a request using the given receiver. This will probably be a | 211 // Generates a request using the given filter. This will probably be a |
| 219 // ForwardingReceiver. | 212 // ForwardingFilter. |
| 220 void MakeTestRequest(ResourceDispatcherHost::Receiver* receiver, | 213 void MakeTestRequest(ResourceMessageFilter* filter, |
| 221 int render_view_id, | 214 int render_view_id, |
| 222 int request_id, | 215 int request_id, |
| 223 const GURL& url); | 216 const GURL& url); |
| 224 | 217 |
| 225 void MakeCancelRequest(int request_id); | 218 void MakeCancelRequest(int request_id); |
| 226 | 219 |
| 227 void EnsureTestSchemeIsAllowed() { | 220 void EnsureTestSchemeIsAllowed() { |
| 228 static bool have_white_listed_test_scheme = false; | 221 static bool have_white_listed_test_scheme = false; |
| 229 | 222 |
| 230 if (!have_white_listed_test_scheme) { | 223 if (!have_white_listed_test_scheme) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 259 static net::URLRequestJob* Factory(net::URLRequest* request, | 252 static net::URLRequestJob* Factory(net::URLRequest* request, |
| 260 const std::string& scheme) { | 253 const std::string& scheme) { |
| 261 if (test_fixture_->response_headers_.empty()) { | 254 if (test_fixture_->response_headers_.empty()) { |
| 262 return new URLRequestTestJob(request); | 255 return new URLRequestTestJob(request); |
| 263 } else { | 256 } else { |
| 264 return new URLRequestTestJob(request, test_fixture_->response_headers_, | 257 return new URLRequestTestJob(request, test_fixture_->response_headers_, |
| 265 test_fixture_->response_data_, false); | 258 test_fixture_->response_data_, false); |
| 266 } | 259 } |
| 267 } | 260 } |
| 268 | 261 |
| 262 scoped_refptr<ForwardingFilter> filter_; | |
| 269 MessageLoopForIO message_loop_; | 263 MessageLoopForIO message_loop_; |
| 270 BrowserThread ui_thread_; | 264 BrowserThread ui_thread_; |
| 271 BrowserThread io_thread_; | 265 BrowserThread io_thread_; |
| 272 ResourceDispatcherHost host_; | 266 ResourceDispatcherHost host_; |
| 273 ResourceIPCAccumulator accum_; | 267 ResourceIPCAccumulator accum_; |
| 274 std::string response_headers_; | 268 std::string response_headers_; |
| 275 std::string response_data_; | 269 std::string response_data_; |
| 276 std::string scheme_; | 270 std::string scheme_; |
| 277 net::URLRequest::ProtocolFactory* old_factory_; | 271 net::URLRequest::ProtocolFactory* old_factory_; |
| 278 ResourceType::Type resource_type_; | 272 ResourceType::Type resource_type_; |
| 279 static ResourceDispatcherHostTest* test_fixture_; | 273 static ResourceDispatcherHostTest* test_fixture_; |
| 280 }; | 274 }; |
| 281 // Static. | 275 // Static. |
| 282 ResourceDispatcherHostTest* ResourceDispatcherHostTest::test_fixture_ = NULL; | 276 ResourceDispatcherHostTest* ResourceDispatcherHostTest::test_fixture_ = NULL; |
| 283 | 277 |
| 284 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, | 278 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, |
| 285 int request_id, | 279 int request_id, |
| 286 const GURL& url) { | 280 const GURL& url) { |
| 287 MakeTestRequest(this, render_view_id, request_id, url); | 281 MakeTestRequest(filter_.get(), render_view_id, request_id, url); |
| 288 } | 282 } |
| 289 | 283 |
| 290 void ResourceDispatcherHostTest::MakeTestRequest( | 284 void ResourceDispatcherHostTest::MakeTestRequest( |
| 291 ResourceDispatcherHost::Receiver* receiver, | 285 ResourceMessageFilter* filter, |
| 292 int render_view_id, | 286 int render_view_id, |
| 293 int request_id, | 287 int request_id, |
| 294 const GURL& url) { | 288 const GURL& url) { |
| 295 ViewHostMsg_Resource_Request request = | 289 ViewHostMsg_Resource_Request request = |
| 296 CreateResourceRequest("GET", resource_type_, url); | 290 CreateResourceRequest("GET", resource_type_, url); |
| 297 ViewHostMsg_RequestResource msg(render_view_id, request_id, request); | 291 ViewHostMsg_RequestResource msg(render_view_id, request_id, request); |
| 298 bool msg_was_ok; | 292 bool msg_was_ok; |
| 299 host_.OnMessageReceived(msg, receiver, &msg_was_ok); | 293 host_.OnMessageReceived(msg, filter, &msg_was_ok); |
| 300 KickOffRequest(); | 294 KickOffRequest(); |
| 301 } | 295 } |
| 302 | 296 |
| 303 void ResourceDispatcherHostTest::MakeCancelRequest(int request_id) { | 297 void ResourceDispatcherHostTest::MakeCancelRequest(int request_id) { |
| 304 host_.CancelRequest(id(), request_id, false); | 298 host_.CancelRequest(filter_->child_id(), request_id, false); |
| 305 } | 299 } |
| 306 | 300 |
| 307 void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages, | 301 void CheckSuccessfulRequest(const std::vector<IPC::Message>& messages, |
| 308 const std::string& reference_data) { | 302 const std::string& reference_data) { |
| 309 // A successful request will have received 4 messages: | 303 // A successful request will have received 4 messages: |
| 310 // ReceivedResponse (indicates headers received) | 304 // ReceivedResponse (indicates headers received) |
| 311 // DataReceived (data) | 305 // DataReceived (data) |
| 312 // XXX DataReceived (0 bytes remaining from a read) | 306 // XXX DataReceived (0 bytes remaining from a read) |
| 313 // RequestComplete (request is done) | 307 // RequestComplete (request is done) |
| 314 // | 308 // |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 int request_id; | 396 int request_id; |
| 403 URLRequestStatus status; | 397 URLRequestStatus status; |
| 404 | 398 |
| 405 void* iter = NULL; | 399 void* iter = NULL; |
| 406 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); | 400 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); |
| 407 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); | 401 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); |
| 408 | 402 |
| 409 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); | 403 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); |
| 410 } | 404 } |
| 411 | 405 |
| 406 // the host delegate acts as a second one so we can have some requests | |
|
brettw
2010/12/15 21:31:10
Style nit: can you capitalize this?
jam
2010/12/15 21:41:04
Done.
| |
| 407 // pending and some canceled | |
| 408 class TestFilter : public ForwardingFilter { | |
| 409 public: | |
| 410 TestFilter() | |
| 411 : ForwardingFilter(NULL), | |
| 412 has_canceled_(false), received_after_canceled_(0) { | |
|
brettw
2010/12/15 21:31:10
Style nit: can you move the last initializer to it
jam
2010/12/15 21:41:04
Done.
| |
| 413 } | |
| 414 | |
| 415 // ForwardingFilter override | |
| 416 virtual bool Send(IPC::Message* msg) { | |
| 417 // no messages should be received when the process has been canceled | |
| 418 if (has_canceled_) | |
| 419 received_after_canceled_++; | |
| 420 delete msg; | |
| 421 return true; | |
| 422 } | |
| 423 bool has_canceled_; | |
| 424 int received_after_canceled_; | |
| 425 }; | |
| 426 | |
| 412 // Tests CancelRequestsForProcess | 427 // Tests CancelRequestsForProcess |
| 413 TEST_F(ResourceDispatcherHostTest, TestProcessCancel) { | 428 TEST_F(ResourceDispatcherHostTest, TestProcessCancel) { |
| 414 // the host delegate acts as a second one so we can have some requests | 429 scoped_refptr<TestFilter> test_filter = new TestFilter(); |
| 415 // pending and some canceled | |
| 416 class TestReceiver : public ResourceDispatcherHost::Receiver { | |
| 417 public: | |
| 418 TestReceiver() | |
| 419 : Receiver(ChildProcessInfo::RENDER_PROCESS, -1), | |
| 420 has_canceled_(false), | |
| 421 received_after_canceled_(0) { | |
| 422 } | |
| 423 | |
| 424 // ResourceDispatcherHost::Receiver implementation | |
| 425 virtual bool Send(IPC::Message* msg) { | |
| 426 // no messages should be received when the process has been canceled | |
| 427 if (has_canceled_) | |
| 428 received_after_canceled_++; | |
| 429 delete msg; | |
| 430 return true; | |
| 431 } | |
| 432 URLRequestContext* GetRequestContext( | |
| 433 uint32 request_id, | |
| 434 const ViewHostMsg_Resource_Request& request_data) { | |
| 435 return NULL; | |
| 436 } | |
| 437 bool has_canceled_; | |
| 438 int received_after_canceled_; | |
| 439 }; | |
| 440 TestReceiver test_receiver; | |
| 441 | 430 |
| 442 // request 1 goes to the test delegate | 431 // request 1 goes to the test delegate |
| 443 ViewHostMsg_Resource_Request request = CreateResourceRequest( | 432 ViewHostMsg_Resource_Request request = CreateResourceRequest( |
| 444 "GET", ResourceType::SUB_RESOURCE, URLRequestTestJob::test_url_1()); | 433 "GET", ResourceType::SUB_RESOURCE, URLRequestTestJob::test_url_1()); |
| 445 | 434 |
| 446 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 435 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
| 447 | 436 |
| 448 MakeTestRequest(&test_receiver, 0, 1, URLRequestTestJob::test_url_1()); | 437 MakeTestRequest(test_filter.get(), 0, 1, URLRequestTestJob::test_url_1()); |
| 449 | 438 |
| 450 // request 2 goes to us | 439 // request 2 goes to us |
| 451 MakeTestRequest(0, 2, URLRequestTestJob::test_url_2()); | 440 MakeTestRequest(0, 2, URLRequestTestJob::test_url_2()); |
| 452 | 441 |
| 453 // request 3 goes to the test delegate | 442 // request 3 goes to the test delegate |
| 454 MakeTestRequest(&test_receiver, 0, 3, URLRequestTestJob::test_url_3()); | 443 MakeTestRequest(test_filter.get(), 0, 3, URLRequestTestJob::test_url_3()); |
| 455 | 444 |
| 456 // TODO(mbelshe): | 445 // TODO(mbelshe): |
| 457 // Now that the async IO path is in place, the IO always completes on the | 446 // Now that the async IO path is in place, the IO always completes on the |
| 458 // initial call; so the requests have already completed. This basically | 447 // initial call; so the requests have already completed. This basically |
| 459 // breaks the whole test. | 448 // breaks the whole test. |
| 460 //EXPECT_EQ(3, host_.pending_requests()); | 449 //EXPECT_EQ(3, host_.pending_requests()); |
| 461 | 450 |
| 462 // Process each request for one level so one callback is called. | 451 // Process each request for one level so one callback is called. |
| 463 for (int i = 0; i < 3; i++) | 452 for (int i = 0; i < 3; i++) |
| 464 EXPECT_TRUE(URLRequestTestJob::ProcessOnePendingMessage()); | 453 EXPECT_TRUE(URLRequestTestJob::ProcessOnePendingMessage()); |
| 465 | 454 |
| 466 // Cancel the requests to the test process. | 455 // Cancel the requests to the test process. |
| 467 host_.CancelRequestsForProcess(id()); | 456 host_.CancelRequestsForProcess(filter_->child_id()); |
| 468 test_receiver.has_canceled_ = true; | 457 test_filter->has_canceled_ = true; |
| 469 | 458 |
| 470 // Flush all the pending requests. | 459 // Flush all the pending requests. |
| 471 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 460 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 472 | 461 |
| 473 EXPECT_EQ(0, host_.pending_requests()); | 462 EXPECT_EQ(0, host_.pending_requests()); |
| 474 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost( | 463 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 475 id())); | |
| 476 | 464 |
| 477 // The test delegate should not have gotten any messages after being canceled. | 465 // The test delegate should not have gotten any messages after being canceled. |
| 478 ASSERT_EQ(0, test_receiver.received_after_canceled_); | 466 ASSERT_EQ(0, test_filter->received_after_canceled_); |
| 479 | 467 |
| 480 // We should have gotten exactly one result. | 468 // We should have gotten exactly one result. |
| 481 ResourceIPCAccumulator::ClassifiedMessages msgs; | 469 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 482 accum_.GetClassifiedMessages(&msgs); | 470 accum_.GetClassifiedMessages(&msgs); |
| 483 ASSERT_EQ(1U, msgs.size()); | 471 ASSERT_EQ(1U, msgs.size()); |
| 484 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_2()); | 472 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_2()); |
| 485 } | 473 } |
| 486 | 474 |
| 487 // Tests blocking and resuming requests. | 475 // Tests blocking and resuming requests. |
| 488 TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { | 476 TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { |
| 489 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost( | 477 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 490 id())); | |
| 491 | 478 |
| 492 host_.BlockRequestsForRoute(id(), 1); | 479 host_.BlockRequestsForRoute(filter_->child_id(), 1); |
| 493 host_.BlockRequestsForRoute(id(), 2); | 480 host_.BlockRequestsForRoute(filter_->child_id(), 2); |
| 494 host_.BlockRequestsForRoute(id(), 3); | 481 host_.BlockRequestsForRoute(filter_->child_id(), 3); |
| 495 | 482 |
| 496 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); | 483 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); |
| 497 MakeTestRequest(1, 2, URLRequestTestJob::test_url_2()); | 484 MakeTestRequest(1, 2, URLRequestTestJob::test_url_2()); |
| 498 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); | 485 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); |
| 499 MakeTestRequest(1, 4, URLRequestTestJob::test_url_1()); | 486 MakeTestRequest(1, 4, URLRequestTestJob::test_url_1()); |
| 500 MakeTestRequest(2, 5, URLRequestTestJob::test_url_2()); | 487 MakeTestRequest(2, 5, URLRequestTestJob::test_url_2()); |
| 501 MakeTestRequest(3, 6, URLRequestTestJob::test_url_3()); | 488 MakeTestRequest(3, 6, URLRequestTestJob::test_url_3()); |
| 502 | 489 |
| 503 // Flush all the pending requests | 490 // Flush all the pending requests |
| 504 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 491 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 505 | 492 |
| 506 // Sort out all the messages we saw by request | 493 // Sort out all the messages we saw by request |
| 507 ResourceIPCAccumulator::ClassifiedMessages msgs; | 494 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 508 accum_.GetClassifiedMessages(&msgs); | 495 accum_.GetClassifiedMessages(&msgs); |
| 509 | 496 |
| 510 // All requests but the 2 for the RVH 0 should have been blocked. | 497 // All requests but the 2 for the RVH 0 should have been blocked. |
| 511 ASSERT_EQ(2U, msgs.size()); | 498 ASSERT_EQ(2U, msgs.size()); |
| 512 | 499 |
| 513 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); | 500 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); |
| 514 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); | 501 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); |
| 515 | 502 |
| 516 // Resume requests for RVH 1 and flush pending requests. | 503 // Resume requests for RVH 1 and flush pending requests. |
| 517 host_.ResumeBlockedRequestsForRoute(id(), 1); | 504 host_.ResumeBlockedRequestsForRoute(filter_->child_id(), 1); |
| 518 KickOffRequest(); | 505 KickOffRequest(); |
| 519 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 506 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 520 | 507 |
| 521 msgs.clear(); | 508 msgs.clear(); |
| 522 accum_.GetClassifiedMessages(&msgs); | 509 accum_.GetClassifiedMessages(&msgs); |
| 523 ASSERT_EQ(2U, msgs.size()); | 510 ASSERT_EQ(2U, msgs.size()); |
| 524 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_2()); | 511 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_2()); |
| 525 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_1()); | 512 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_1()); |
| 526 | 513 |
| 527 // Test that new requests are not blocked for RVH 1. | 514 // Test that new requests are not blocked for RVH 1. |
| 528 MakeTestRequest(1, 7, URLRequestTestJob::test_url_1()); | 515 MakeTestRequest(1, 7, URLRequestTestJob::test_url_1()); |
| 529 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 516 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 530 msgs.clear(); | 517 msgs.clear(); |
| 531 accum_.GetClassifiedMessages(&msgs); | 518 accum_.GetClassifiedMessages(&msgs); |
| 532 ASSERT_EQ(1U, msgs.size()); | 519 ASSERT_EQ(1U, msgs.size()); |
| 533 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); | 520 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); |
| 534 | 521 |
| 535 // Now resumes requests for all RVH (2 and 3). | 522 // Now resumes requests for all RVH (2 and 3). |
| 536 host_.ResumeBlockedRequestsForRoute(id(), 2); | 523 host_.ResumeBlockedRequestsForRoute(filter_->child_id(), 2); |
| 537 host_.ResumeBlockedRequestsForRoute(id(), 3); | 524 host_.ResumeBlockedRequestsForRoute(filter_->child_id(), 3); |
| 538 KickOffRequest(); | 525 KickOffRequest(); |
| 539 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 526 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 540 | 527 |
| 541 EXPECT_EQ(0, | 528 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 542 host_.GetOutstandingRequestsMemoryCost(id())); | |
| 543 | 529 |
| 544 msgs.clear(); | 530 msgs.clear(); |
| 545 accum_.GetClassifiedMessages(&msgs); | 531 accum_.GetClassifiedMessages(&msgs); |
| 546 ASSERT_EQ(2U, msgs.size()); | 532 ASSERT_EQ(2U, msgs.size()); |
| 547 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_2()); | 533 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_2()); |
| 548 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); | 534 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); |
| 549 } | 535 } |
| 550 | 536 |
| 551 // Tests blocking and canceling requests. | 537 // Tests blocking and canceling requests. |
| 552 TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) { | 538 TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) { |
| 553 EXPECT_EQ(0, | 539 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 554 host_.GetOutstandingRequestsMemoryCost(id())); | |
| 555 | 540 |
| 556 host_.BlockRequestsForRoute(id(), 1); | 541 host_.BlockRequestsForRoute(filter_->child_id(), 1); |
| 557 | 542 |
| 558 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); | 543 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); |
| 559 MakeTestRequest(1, 2, URLRequestTestJob::test_url_2()); | 544 MakeTestRequest(1, 2, URLRequestTestJob::test_url_2()); |
| 560 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); | 545 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); |
| 561 MakeTestRequest(1, 4, URLRequestTestJob::test_url_1()); | 546 MakeTestRequest(1, 4, URLRequestTestJob::test_url_1()); |
| 562 | 547 |
| 563 // Flush all the pending requests. | 548 // Flush all the pending requests. |
| 564 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 549 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 565 | 550 |
| 566 // Sort out all the messages we saw by request. | 551 // Sort out all the messages we saw by request. |
| 567 ResourceIPCAccumulator::ClassifiedMessages msgs; | 552 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 568 accum_.GetClassifiedMessages(&msgs); | 553 accum_.GetClassifiedMessages(&msgs); |
| 569 | 554 |
| 570 // The 2 requests for the RVH 0 should have been processed. | 555 // The 2 requests for the RVH 0 should have been processed. |
| 571 ASSERT_EQ(2U, msgs.size()); | 556 ASSERT_EQ(2U, msgs.size()); |
| 572 | 557 |
| 573 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); | 558 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); |
| 574 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); | 559 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); |
| 575 | 560 |
| 576 // Cancel requests for RVH 1. | 561 // Cancel requests for RVH 1. |
| 577 host_.CancelBlockedRequestsForRoute(id(), 1); | 562 host_.CancelBlockedRequestsForRoute(filter_->child_id(), 1); |
| 578 KickOffRequest(); | 563 KickOffRequest(); |
| 579 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 564 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 580 | 565 |
| 581 EXPECT_EQ(0, | 566 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 582 host_.GetOutstandingRequestsMemoryCost(id())); | |
| 583 | 567 |
| 584 msgs.clear(); | 568 msgs.clear(); |
| 585 accum_.GetClassifiedMessages(&msgs); | 569 accum_.GetClassifiedMessages(&msgs); |
| 586 ASSERT_EQ(0U, msgs.size()); | 570 ASSERT_EQ(0U, msgs.size()); |
| 587 } | 571 } |
| 588 | 572 |
| 589 // Tests that blocked requests are canceled if their associated process dies. | 573 // Tests that blocked requests are canceled if their associated process dies. |
| 590 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) { | 574 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) { |
| 591 // This second receiver is used to emulate a second process. | 575 // This second filter is used to emulate a second process. |
| 592 ForwardingReceiver second_receiver(this); | 576 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(this); |
| 593 | 577 |
| 594 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost( | 578 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 595 id())); | 579 EXPECT_EQ(0, |
| 596 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost( | 580 host_.GetOutstandingRequestsMemoryCost(second_filter->child_id())); |
| 597 second_receiver.id())); | |
| 598 | 581 |
| 599 host_.BlockRequestsForRoute(second_receiver.id(), 0); | 582 host_.BlockRequestsForRoute(second_filter->child_id(), 0); |
| 600 | 583 |
| 601 MakeTestRequest(this, 0, 1, URLRequestTestJob::test_url_1()); | 584 MakeTestRequest(filter_.get(), 0, 1, URLRequestTestJob::test_url_1()); |
| 602 MakeTestRequest(&second_receiver, 0, 2, URLRequestTestJob::test_url_2()); | 585 MakeTestRequest(second_filter.get(), 0, 2, URLRequestTestJob::test_url_2()); |
| 603 MakeTestRequest(this, 0, 3, URLRequestTestJob::test_url_3()); | 586 MakeTestRequest(filter_.get(), 0, 3, URLRequestTestJob::test_url_3()); |
| 604 MakeTestRequest(&second_receiver, 0, 4, URLRequestTestJob::test_url_1()); | 587 MakeTestRequest(second_filter.get(), 0, 4, URLRequestTestJob::test_url_1()); |
| 605 | 588 |
| 606 // Simulate process death. | 589 // Simulate process death. |
| 607 host_.CancelRequestsForProcess(second_receiver.id()); | 590 host_.CancelRequestsForProcess(second_filter->child_id()); |
| 608 | 591 |
| 609 // Flush all the pending requests. | 592 // Flush all the pending requests. |
| 610 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 593 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 611 | 594 |
| 612 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost( | 595 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 613 id())); | 596 EXPECT_EQ(0, |
| 614 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost( | 597 host_.GetOutstandingRequestsMemoryCost(second_filter->child_id())); |
| 615 second_receiver.id())); | |
| 616 | 598 |
| 617 // Sort out all the messages we saw by request. | 599 // Sort out all the messages we saw by request. |
| 618 ResourceIPCAccumulator::ClassifiedMessages msgs; | 600 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 619 accum_.GetClassifiedMessages(&msgs); | 601 accum_.GetClassifiedMessages(&msgs); |
| 620 | 602 |
| 621 // The 2 requests for the RVH 0 should have been processed. | 603 // The 2 requests for the RVH 0 should have been processed. |
| 622 ASSERT_EQ(2U, msgs.size()); | 604 ASSERT_EQ(2U, msgs.size()); |
| 623 | 605 |
| 624 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); | 606 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); |
| 625 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); | 607 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); |
| 626 | 608 |
| 627 EXPECT_TRUE(host_.blocked_requests_map_.empty()); | 609 EXPECT_TRUE(host_.blocked_requests_map_.empty()); |
| 628 } | 610 } |
| 629 | 611 |
| 630 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes | 612 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes |
| 631 // away. Note that we rely on Purify for finding the leaks if any. | 613 // away. Note that we rely on Purify for finding the leaks if any. |
| 632 // If this test turns the Purify bot red, check the ResourceDispatcherHost | 614 // If this test turns the Purify bot red, check the ResourceDispatcherHost |
| 633 // destructor to make sure the blocked requests are deleted. | 615 // destructor to make sure the blocked requests are deleted. |
| 634 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { | 616 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { |
| 635 // This second receiver is used to emulate a second process. | 617 // This second filter is used to emulate a second process. |
| 636 ForwardingReceiver second_receiver(this); | 618 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(this); |
| 637 | 619 |
| 638 host_.BlockRequestsForRoute(id(), 1); | 620 host_.BlockRequestsForRoute(filter_->child_id(), 1); |
| 639 host_.BlockRequestsForRoute(id(), 2); | 621 host_.BlockRequestsForRoute(filter_->child_id(), 2); |
| 640 host_.BlockRequestsForRoute(second_receiver.id(), 1); | 622 host_.BlockRequestsForRoute(second_filter->child_id(), 1); |
| 641 | 623 |
| 642 MakeTestRequest(this, 0, 1, URLRequestTestJob::test_url_1()); | 624 MakeTestRequest(filter_.get(), 0, 1, URLRequestTestJob::test_url_1()); |
| 643 MakeTestRequest(this, 1, 2, URLRequestTestJob::test_url_2()); | 625 MakeTestRequest(filter_.get(), 1, 2, URLRequestTestJob::test_url_2()); |
| 644 MakeTestRequest(this, 0, 3, URLRequestTestJob::test_url_3()); | 626 MakeTestRequest(filter_.get(), 0, 3, URLRequestTestJob::test_url_3()); |
| 645 MakeTestRequest(&second_receiver, 1, 4, URLRequestTestJob::test_url_1()); | 627 MakeTestRequest(second_filter.get(), 1, 4, URLRequestTestJob::test_url_1()); |
| 646 MakeTestRequest(this, 2, 5, URLRequestTestJob::test_url_2()); | 628 MakeTestRequest(filter_.get(), 2, 5, URLRequestTestJob::test_url_2()); |
| 647 MakeTestRequest(this, 2, 6, URLRequestTestJob::test_url_3()); | 629 MakeTestRequest(filter_.get(), 2, 6, URLRequestTestJob::test_url_3()); |
| 648 | 630 |
| 649 // Flush all the pending requests. | 631 // Flush all the pending requests. |
| 650 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 632 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 651 } | 633 } |
| 652 | 634 |
| 653 // Test the private helper method "CalculateApproximateMemoryCost()". | 635 // Test the private helper method "CalculateApproximateMemoryCost()". |
| 654 TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { | 636 TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { |
| 655 net::URLRequest req(GURL("http://www.google.com"), NULL); | 637 net::URLRequest req(GURL("http://www.google.com"), NULL); |
| 656 EXPECT_EQ(4427, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req)); | 638 EXPECT_EQ(4427, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req)); |
| 657 | 639 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 // When an entry reaches 0, it should be deleted. | 684 // When an entry reaches 0, it should be deleted. |
| 703 EXPECT_TRUE(host_.outstanding_requests_memory_cost_map_.end() == | 685 EXPECT_TRUE(host_.outstanding_requests_memory_cost_map_.end() == |
| 704 host_.outstanding_requests_memory_cost_map_.find(7)); | 686 host_.outstanding_requests_memory_cost_map_.find(7)); |
| 705 EXPECT_TRUE(host_.outstanding_requests_memory_cost_map_.end() == | 687 EXPECT_TRUE(host_.outstanding_requests_memory_cost_map_.end() == |
| 706 host_.outstanding_requests_memory_cost_map_.find(3)); | 688 host_.outstanding_requests_memory_cost_map_.find(3)); |
| 707 } | 689 } |
| 708 | 690 |
| 709 // Test that when too many requests are outstanding for a particular | 691 // Test that when too many requests are outstanding for a particular |
| 710 // render_process_host_id, any subsequent request from it fails. | 692 // render_process_host_id, any subsequent request from it fails. |
| 711 TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) { | 693 TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) { |
| 712 EXPECT_EQ(0, | 694 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 713 host_.GetOutstandingRequestsMemoryCost(id())); | |
| 714 | 695 |
| 715 // Expected cost of each request as measured by | 696 // Expected cost of each request as measured by |
| 716 // ResourceDispatcherHost::CalculateApproximateMemoryCost(). | 697 // ResourceDispatcherHost::CalculateApproximateMemoryCost(). |
| 717 int kMemoryCostOfTest2Req = | 698 int kMemoryCostOfTest2Req = |
| 718 ResourceDispatcherHost::kAvgBytesPerOutstandingRequest + | 699 ResourceDispatcherHost::kAvgBytesPerOutstandingRequest + |
| 719 std::string("GET").size() + | 700 std::string("GET").size() + |
| 720 URLRequestTestJob::test_url_2().spec().size(); | 701 URLRequestTestJob::test_url_2().spec().size(); |
| 721 | 702 |
| 722 // Tighten the bound on the ResourceDispatcherHost, to speed things up. | 703 // Tighten the bound on the ResourceDispatcherHost, to speed things up. |
| 723 int kMaxCostPerProcess = 440000; | 704 int kMaxCostPerProcess = 440000; |
| 724 host_.set_max_outstanding_requests_cost_per_process(kMaxCostPerProcess); | 705 host_.set_max_outstanding_requests_cost_per_process(kMaxCostPerProcess); |
| 725 | 706 |
| 726 // Determine how many instance of test_url_2() we can request before | 707 // Determine how many instance of test_url_2() we can request before |
| 727 // throttling kicks in. | 708 // throttling kicks in. |
| 728 size_t kMaxRequests = kMaxCostPerProcess / kMemoryCostOfTest2Req; | 709 size_t kMaxRequests = kMaxCostPerProcess / kMemoryCostOfTest2Req; |
| 729 | 710 |
| 730 // This second receiver is used to emulate a second process. | 711 // This second filter is used to emulate a second process. |
| 731 ForwardingReceiver second_receiver(this); | 712 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(this); |
| 732 | 713 |
| 733 // Saturate the number of outstanding requests for our process. | 714 // Saturate the number of outstanding requests for our process. |
| 734 for (size_t i = 0; i < kMaxRequests; ++i) | 715 for (size_t i = 0; i < kMaxRequests; ++i) |
| 735 MakeTestRequest(this, 0, i + 1, URLRequestTestJob::test_url_2()); | 716 MakeTestRequest(filter_.get(), 0, i + 1, URLRequestTestJob::test_url_2()); |
| 736 | 717 |
| 737 // Issue two more requests for our process -- these should fail immediately. | 718 // Issue two more requests for our process -- these should fail immediately. |
| 738 MakeTestRequest(this, 0, kMaxRequests + 1, URLRequestTestJob::test_url_2()); | 719 MakeTestRequest(filter_.get(), 0, kMaxRequests + 1, |
| 739 MakeTestRequest(this, 0, kMaxRequests + 2, URLRequestTestJob::test_url_2()); | 720 URLRequestTestJob::test_url_2()); |
| 721 MakeTestRequest(filter_.get(), 0, kMaxRequests + 2, | |
| 722 URLRequestTestJob::test_url_2()); | |
| 740 | 723 |
| 741 // Issue two requests for the second process -- these should succeed since | 724 // Issue two requests for the second process -- these should succeed since |
| 742 // it is just process 0 that is saturated. | 725 // it is just process 0 that is saturated. |
| 743 MakeTestRequest(&second_receiver, 0, kMaxRequests + 3, | 726 MakeTestRequest(second_filter.get(), 0, kMaxRequests + 3, |
| 744 URLRequestTestJob::test_url_2()); | 727 URLRequestTestJob::test_url_2()); |
| 745 MakeTestRequest(&second_receiver, 0, kMaxRequests + 4, | 728 MakeTestRequest(second_filter.get(), 0, kMaxRequests + 4, |
| 746 URLRequestTestJob::test_url_2()); | 729 URLRequestTestJob::test_url_2()); |
| 747 | 730 |
| 748 // Flush all the pending requests. | 731 // Flush all the pending requests. |
| 749 while (URLRequestTestJob::ProcessOnePendingMessage()) {} | 732 while (URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 750 MessageLoop::current()->RunAllPending(); | 733 MessageLoop::current()->RunAllPending(); |
| 751 | 734 |
| 752 EXPECT_EQ(0, | 735 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
| 753 host_.GetOutstandingRequestsMemoryCost(id())); | |
| 754 | 736 |
| 755 // Sorts out all the messages we saw by request. | 737 // Sorts out all the messages we saw by request. |
| 756 ResourceIPCAccumulator::ClassifiedMessages msgs; | 738 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 757 accum_.GetClassifiedMessages(&msgs); | 739 accum_.GetClassifiedMessages(&msgs); |
| 758 | 740 |
| 759 // We issued (kMaxRequests + 4) total requests. | 741 // We issued (kMaxRequests + 4) total requests. |
| 760 ASSERT_EQ(kMaxRequests + 4, msgs.size()); | 742 ASSERT_EQ(kMaxRequests + 4, msgs.size()); |
| 761 | 743 |
| 762 // Check that the first kMaxRequests succeeded. | 744 // Check that the first kMaxRequests succeeded. |
| 763 for (size_t i = 0; i < kMaxRequests; ++i) | 745 for (size_t i = 0; i < kMaxRequests; ++i) |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 EXPECT_TRUE(request_info_->replace_extension_localization_templates()); | 1009 EXPECT_TRUE(request_info_->replace_extension_localization_templates()); |
| 1028 } | 1010 } |
| 1029 | 1011 |
| 1030 TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) { | 1012 TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) { |
| 1031 resource_type_ = ResourceType::MAIN_FRAME; | 1013 resource_type_ = ResourceType::MAIN_FRAME; |
| 1032 ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_, | 1014 ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_, |
| 1033 resource_type_, request_info_.get()); | 1015 resource_type_, request_info_.get()); |
| 1034 | 1016 |
| 1035 EXPECT_FALSE(request_info_->replace_extension_localization_templates()); | 1017 EXPECT_FALSE(request_info_->replace_extension_localization_templates()); |
| 1036 } | 1018 } |
| OLD | NEW |