| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 canceled_(false), | 216 canceled_(false), |
| 217 received_after_canceled_(0) { | 217 received_after_canceled_(0) { |
| 218 ChildProcessSecurityPolicyImpl::GetInstance()->Add(child_id()); | 218 ChildProcessSecurityPolicyImpl::GetInstance()->Add(child_id()); |
| 219 set_peer_pid_for_testing(base::GetCurrentProcId()); | 219 set_peer_pid_for_testing(base::GetCurrentProcId()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void set_canceled(bool canceled) { canceled_ = canceled; } | 222 void set_canceled(bool canceled) { canceled_ = canceled; } |
| 223 int received_after_canceled() const { return received_after_canceled_; } | 223 int received_after_canceled() const { return received_after_canceled_; } |
| 224 | 224 |
| 225 // ResourceMessageFilter override | 225 // ResourceMessageFilter override |
| 226 virtual bool Send(IPC::Message* msg) override { | 226 bool Send(IPC::Message* msg) override { |
| 227 // No messages should be received when the process has been canceled. | 227 // No messages should be received when the process has been canceled. |
| 228 if (canceled_) | 228 if (canceled_) |
| 229 received_after_canceled_++; | 229 received_after_canceled_++; |
| 230 ReleaseHandlesInMessage(*msg); | 230 ReleaseHandlesInMessage(*msg); |
| 231 delete msg; | 231 delete msg; |
| 232 return true; | 232 return true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 ResourceContext* resource_context() { return resource_context_; } | 235 ResourceContext* resource_context() { return resource_context_; } |
| 236 | 236 |
| 237 protected: | 237 protected: |
| 238 virtual ~TestFilter() {} | 238 ~TestFilter() override {} |
| 239 | 239 |
| 240 private: | 240 private: |
| 241 void GetContexts(const ResourceHostMsg_Request& request, | 241 void GetContexts(const ResourceHostMsg_Request& request, |
| 242 ResourceContext** resource_context, | 242 ResourceContext** resource_context, |
| 243 net::URLRequestContext** request_context) { | 243 net::URLRequestContext** request_context) { |
| 244 *resource_context = resource_context_; | 244 *resource_context = resource_context_; |
| 245 *request_context = resource_context_->GetRequestContext(); | 245 *request_context = resource_context_->GetRequestContext(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 ResourceContext* resource_context_; | 248 ResourceContext* resource_context_; |
| 249 bool canceled_; | 249 bool canceled_; |
| 250 int received_after_canceled_; | 250 int received_after_canceled_; |
| 251 | 251 |
| 252 DISALLOW_COPY_AND_ASSIGN(TestFilter); | 252 DISALLOW_COPY_AND_ASSIGN(TestFilter); |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 | 255 |
| 256 // This class forwards the incoming messages to the ResourceDispatcherHostTest. | 256 // This class forwards the incoming messages to the ResourceDispatcherHostTest. |
| 257 // For the test, we want all the incoming messages to go to the same place, | 257 // For the test, we want all the incoming messages to go to the same place, |
| 258 // which is why this forwards. | 258 // which is why this forwards. |
| 259 class ForwardingFilter : public TestFilter { | 259 class ForwardingFilter : public TestFilter { |
| 260 public: | 260 public: |
| 261 explicit ForwardingFilter(IPC::Sender* dest, | 261 explicit ForwardingFilter(IPC::Sender* dest, |
| 262 ResourceContext* resource_context) | 262 ResourceContext* resource_context) |
| 263 : TestFilter(resource_context), | 263 : TestFilter(resource_context), |
| 264 dest_(dest) { | 264 dest_(dest) { |
| 265 } | 265 } |
| 266 | 266 |
| 267 // TestFilter override | 267 // TestFilter override |
| 268 virtual bool Send(IPC::Message* msg) override { | 268 bool Send(IPC::Message* msg) override { return dest_->Send(msg); } |
| 269 return dest_->Send(msg); | |
| 270 } | |
| 271 | 269 |
| 272 private: | 270 private: |
| 273 virtual ~ForwardingFilter() {} | 271 ~ForwardingFilter() override {} |
| 274 | 272 |
| 275 IPC::Sender* dest_; | 273 IPC::Sender* dest_; |
| 276 | 274 |
| 277 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter); | 275 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter); |
| 278 }; | 276 }; |
| 279 | 277 |
| 280 // This class is a variation on URLRequestTestJob that will call | 278 // This class is a variation on URLRequestTestJob that will call |
| 281 // URLRequest::WillStartUsingNetwork before starting. | 279 // URLRequest::WillStartUsingNetwork before starting. |
| 282 class URLRequestTestDelayedNetworkJob : public net::URLRequestTestJob { | 280 class URLRequestTestDelayedNetworkJob : public net::URLRequestTestJob { |
| 283 public: | 281 public: |
| 284 URLRequestTestDelayedNetworkJob(net::URLRequest* request, | 282 URLRequestTestDelayedNetworkJob(net::URLRequest* request, |
| 285 net::NetworkDelegate* network_delegate) | 283 net::NetworkDelegate* network_delegate) |
| 286 : net::URLRequestTestJob(request, network_delegate) {} | 284 : net::URLRequestTestJob(request, network_delegate) {} |
| 287 | 285 |
| 288 // Only start if not deferred for network start. | 286 // Only start if not deferred for network start. |
| 289 virtual void Start() override { | 287 void Start() override { |
| 290 bool defer = false; | 288 bool defer = false; |
| 291 NotifyBeforeNetworkStart(&defer); | 289 NotifyBeforeNetworkStart(&defer); |
| 292 if (defer) | 290 if (defer) |
| 293 return; | 291 return; |
| 294 net::URLRequestTestJob::Start(); | 292 net::URLRequestTestJob::Start(); |
| 295 } | 293 } |
| 296 | 294 |
| 297 virtual void ResumeNetworkStart() override { | 295 void ResumeNetworkStart() override { net::URLRequestTestJob::StartAsync(); } |
| 298 net::URLRequestTestJob::StartAsync(); | |
| 299 } | |
| 300 | 296 |
| 301 private: | 297 private: |
| 302 virtual ~URLRequestTestDelayedNetworkJob() {} | 298 ~URLRequestTestDelayedNetworkJob() override {} |
| 303 | 299 |
| 304 DISALLOW_COPY_AND_ASSIGN(URLRequestTestDelayedNetworkJob); | 300 DISALLOW_COPY_AND_ASSIGN(URLRequestTestDelayedNetworkJob); |
| 305 }; | 301 }; |
| 306 | 302 |
| 307 // This class is a variation on URLRequestTestJob in that it does | 303 // This class is a variation on URLRequestTestJob in that it does |
| 308 // not complete start upon entry, only when specifically told to. | 304 // not complete start upon entry, only when specifically told to. |
| 309 class URLRequestTestDelayedStartJob : public net::URLRequestTestJob { | 305 class URLRequestTestDelayedStartJob : public net::URLRequestTestJob { |
| 310 public: | 306 public: |
| 311 URLRequestTestDelayedStartJob(net::URLRequest* request, | 307 URLRequestTestDelayedStartJob(net::URLRequest* request, |
| 312 net::NetworkDelegate* network_delegate) | 308 net::NetworkDelegate* network_delegate) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 326 bool auto_advance) | 322 bool auto_advance) |
| 327 : net::URLRequestTestJob(request, | 323 : net::URLRequestTestJob(request, |
| 328 network_delegate, | 324 network_delegate, |
| 329 response_headers, | 325 response_headers, |
| 330 response_data, | 326 response_data, |
| 331 auto_advance) { | 327 auto_advance) { |
| 332 Init(); | 328 Init(); |
| 333 } | 329 } |
| 334 | 330 |
| 335 // Do nothing until you're told to. | 331 // Do nothing until you're told to. |
| 336 virtual void Start() override {} | 332 void Start() override {} |
| 337 | 333 |
| 338 // Finish starting a URL request whose job is an instance of | 334 // Finish starting a URL request whose job is an instance of |
| 339 // URLRequestTestDelayedStartJob. It is illegal to call this routine | 335 // URLRequestTestDelayedStartJob. It is illegal to call this routine |
| 340 // with a URLRequest that does not use URLRequestTestDelayedStartJob. | 336 // with a URLRequest that does not use URLRequestTestDelayedStartJob. |
| 341 static void CompleteStart(net::URLRequest* request) { | 337 static void CompleteStart(net::URLRequest* request) { |
| 342 for (URLRequestTestDelayedStartJob* job = list_head_; | 338 for (URLRequestTestDelayedStartJob* job = list_head_; |
| 343 job; | 339 job; |
| 344 job = job->next_) { | 340 job = job->next_) { |
| 345 if (job->request() == request) { | 341 if (job->request() == request) { |
| 346 job->net::URLRequestTestJob::Start(); | 342 job->net::URLRequestTestJob::Start(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 357 static void ClearQueue() { | 353 static void ClearQueue() { |
| 358 if (list_head_) { | 354 if (list_head_) { |
| 359 LOG(ERROR) | 355 LOG(ERROR) |
| 360 << "Unreleased entries on URLRequestTestDelayedStartJob delay queue" | 356 << "Unreleased entries on URLRequestTestDelayedStartJob delay queue" |
| 361 << "; may result in leaks."; | 357 << "; may result in leaks."; |
| 362 list_head_ = NULL; | 358 list_head_ = NULL; |
| 363 } | 359 } |
| 364 } | 360 } |
| 365 | 361 |
| 366 protected: | 362 protected: |
| 367 virtual ~URLRequestTestDelayedStartJob() { | 363 ~URLRequestTestDelayedStartJob() override { |
| 368 for (URLRequestTestDelayedStartJob** job = &list_head_; *job; | 364 for (URLRequestTestDelayedStartJob** job = &list_head_; *job; |
| 369 job = &(*job)->next_) { | 365 job = &(*job)->next_) { |
| 370 if (*job == this) { | 366 if (*job == this) { |
| 371 *job = (*job)->next_; | 367 *job = (*job)->next_; |
| 372 return; | 368 return; |
| 373 } | 369 } |
| 374 } | 370 } |
| 375 NOTREACHED(); | 371 NOTREACHED(); |
| 376 } | 372 } |
| 377 | 373 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 404 const std::string& response_headers, | 400 const std::string& response_headers, |
| 405 const std::string& response_data, | 401 const std::string& response_data, |
| 406 bool auto_advance) | 402 bool auto_advance) |
| 407 : net::URLRequestTestJob(request, | 403 : net::URLRequestTestJob(request, |
| 408 network_delegate, | 404 network_delegate, |
| 409 response_headers, | 405 response_headers, |
| 410 response_data, | 406 response_data, |
| 411 auto_advance) {} | 407 auto_advance) {} |
| 412 | 408 |
| 413 protected: | 409 protected: |
| 414 virtual ~URLRequestTestDelayedCompletionJob() {} | 410 ~URLRequestTestDelayedCompletionJob() override {} |
| 415 | 411 |
| 416 private: | 412 private: |
| 417 virtual bool NextReadAsync() override { return true; } | 413 bool NextReadAsync() override { return true; } |
| 418 }; | 414 }; |
| 419 | 415 |
| 420 class URLRequestBigJob : public net::URLRequestSimpleJob { | 416 class URLRequestBigJob : public net::URLRequestSimpleJob { |
| 421 public: | 417 public: |
| 422 URLRequestBigJob(net::URLRequest* request, | 418 URLRequestBigJob(net::URLRequest* request, |
| 423 net::NetworkDelegate* network_delegate) | 419 net::NetworkDelegate* network_delegate) |
| 424 : net::URLRequestSimpleJob(request, network_delegate) { | 420 : net::URLRequestSimpleJob(request, network_delegate) { |
| 425 } | 421 } |
| 426 | 422 |
| 427 virtual int GetData(std::string* mime_type, | 423 int GetData(std::string* mime_type, |
| 428 std::string* charset, | 424 std::string* charset, |
| 429 std::string* data, | 425 std::string* data, |
| 430 const net::CompletionCallback& callback) const override { | 426 const net::CompletionCallback& callback) const override { |
| 431 *mime_type = "text/plain"; | 427 *mime_type = "text/plain"; |
| 432 *charset = "UTF-8"; | 428 *charset = "UTF-8"; |
| 433 | 429 |
| 434 std::string text; | 430 std::string text; |
| 435 int count; | 431 int count; |
| 436 if (!ParseURL(request_->url(), &text, &count)) | 432 if (!ParseURL(request_->url(), &text, &count)) |
| 437 return net::ERR_INVALID_URL; | 433 return net::ERR_INVALID_URL; |
| 438 | 434 |
| 439 data->reserve(text.size() * count); | 435 data->reserve(text.size() * count); |
| 440 for (int i = 0; i < count; ++i) | 436 for (int i = 0; i < count; ++i) |
| 441 data->append(text); | 437 data->append(text); |
| 442 | 438 |
| 443 return net::OK; | 439 return net::OK; |
| 444 } | 440 } |
| 445 | 441 |
| 446 private: | 442 private: |
| 447 virtual ~URLRequestBigJob() {} | 443 ~URLRequestBigJob() override {} |
| 448 | 444 |
| 449 // big-job:substring,N | 445 // big-job:substring,N |
| 450 static bool ParseURL(const GURL& url, std::string* text, int* count) { | 446 static bool ParseURL(const GURL& url, std::string* text, int* count) { |
| 451 std::vector<std::string> parts; | 447 std::vector<std::string> parts; |
| 452 base::SplitString(url.path(), ',', &parts); | 448 base::SplitString(url.path(), ',', &parts); |
| 453 | 449 |
| 454 if (parts.size() != 2) | 450 if (parts.size() != 2) |
| 455 return false; | 451 return false; |
| 456 | 452 |
| 457 *text = parts[0]; | 453 *text = parts[0]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 484 } | 480 } |
| 485 | 481 |
| 486 void SetDelayedCompleteJobGeneration(bool delay_job_complete) { | 482 void SetDelayedCompleteJobGeneration(bool delay_job_complete) { |
| 487 delay_complete_ = delay_job_complete; | 483 delay_complete_ = delay_job_complete; |
| 488 } | 484 } |
| 489 | 485 |
| 490 void SetNetworkStartNotificationJobGeneration(bool notification) { | 486 void SetNetworkStartNotificationJobGeneration(bool notification) { |
| 491 network_start_notification_ = notification; | 487 network_start_notification_ = notification; |
| 492 } | 488 } |
| 493 | 489 |
| 494 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 490 net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 495 const std::string& scheme, | 491 const std::string& scheme, |
| 496 net::URLRequest* request, | 492 net::URLRequest* request, |
| 497 net::NetworkDelegate* network_delegate) const override; | 493 net::NetworkDelegate* network_delegate) const override; |
| 498 | 494 |
| 499 virtual bool IsHandledProtocol(const std::string& scheme) const override { | 495 bool IsHandledProtocol(const std::string& scheme) const override { |
| 500 return supported_schemes_.count(scheme) > 0; | 496 return supported_schemes_.count(scheme) > 0; |
| 501 } | 497 } |
| 502 | 498 |
| 503 virtual bool IsHandledURL(const GURL& url) const override { | 499 bool IsHandledURL(const GURL& url) const override { |
| 504 return supported_schemes_.count(url.scheme()) > 0; | 500 return supported_schemes_.count(url.scheme()) > 0; |
| 505 } | 501 } |
| 506 | 502 |
| 507 virtual bool IsSafeRedirectTarget(const GURL& location) const override { | 503 bool IsSafeRedirectTarget(const GURL& location) const override { |
| 508 return false; | 504 return false; |
| 509 } | 505 } |
| 510 | 506 |
| 511 private: | 507 private: |
| 512 ResourceDispatcherHostTest* test_fixture_; | 508 ResourceDispatcherHostTest* test_fixture_; |
| 513 bool delay_start_; | 509 bool delay_start_; |
| 514 bool delay_complete_; | 510 bool delay_complete_; |
| 515 bool network_start_notification_; | 511 bool network_start_notification_; |
| 516 mutable int url_request_jobs_created_count_; | 512 mutable int url_request_jobs_created_count_; |
| 517 std::set<std::string> supported_schemes_; | 513 std::set<std::string> supported_schemes_; |
| 518 | 514 |
| 519 DISALLOW_COPY_AND_ASSIGN(TestURLRequestJobFactory); | 515 DISALLOW_COPY_AND_ASSIGN(TestURLRequestJobFactory); |
| 520 }; | 516 }; |
| 521 | 517 |
| 522 // Associated with an URLRequest to determine if the URLRequest gets deleted. | 518 // Associated with an URLRequest to determine if the URLRequest gets deleted. |
| 523 class TestUserData : public base::SupportsUserData::Data { | 519 class TestUserData : public base::SupportsUserData::Data { |
| 524 public: | 520 public: |
| 525 explicit TestUserData(bool* was_deleted) | 521 explicit TestUserData(bool* was_deleted) |
| 526 : was_deleted_(was_deleted) { | 522 : was_deleted_(was_deleted) { |
| 527 } | 523 } |
| 528 | 524 |
| 529 virtual ~TestUserData() { | 525 ~TestUserData() override { *was_deleted_ = true; } |
| 530 *was_deleted_ = true; | |
| 531 } | |
| 532 | 526 |
| 533 private: | 527 private: |
| 534 bool* was_deleted_; | 528 bool* was_deleted_; |
| 535 }; | 529 }; |
| 536 | 530 |
| 537 class TransfersAllNavigationsContentBrowserClient | 531 class TransfersAllNavigationsContentBrowserClient |
| 538 : public TestContentBrowserClient { | 532 : public TestContentBrowserClient { |
| 539 public: | 533 public: |
| 540 virtual bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context, | 534 bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context, |
| 541 const GURL& current_url, | 535 const GURL& current_url, |
| 542 const GURL& new_url) override { | 536 const GURL& new_url) override { |
| 543 return true; | 537 return true; |
| 544 } | 538 } |
| 545 }; | 539 }; |
| 546 | 540 |
| 547 enum GenericResourceThrottleFlags { | 541 enum GenericResourceThrottleFlags { |
| 548 NONE = 0, | 542 NONE = 0, |
| 549 DEFER_STARTING_REQUEST = 1 << 0, | 543 DEFER_STARTING_REQUEST = 1 << 0, |
| 550 DEFER_PROCESSING_RESPONSE = 1 << 1, | 544 DEFER_PROCESSING_RESPONSE = 1 << 1, |
| 551 CANCEL_BEFORE_START = 1 << 2, | 545 CANCEL_BEFORE_START = 1 << 2, |
| 552 DEFER_NETWORK_START = 1 << 3 | 546 DEFER_NETWORK_START = 1 << 3 |
| 553 }; | 547 }; |
| 554 | 548 |
| 555 // Throttle that tracks the current throttle blocking a request. Only one | 549 // Throttle that tracks the current throttle blocking a request. Only one |
| 556 // can throttle any request at a time. | 550 // can throttle any request at a time. |
| 557 class GenericResourceThrottle : public ResourceThrottle { | 551 class GenericResourceThrottle : public ResourceThrottle { |
| 558 public: | 552 public: |
| 559 // The value is used to indicate that the throttle should not provide | 553 // The value is used to indicate that the throttle should not provide |
| 560 // a error code when cancelling a request. net::OK is used, because this | 554 // a error code when cancelling a request. net::OK is used, because this |
| 561 // is not an error code. | 555 // is not an error code. |
| 562 static const int USE_DEFAULT_CANCEL_ERROR_CODE = net::OK; | 556 static const int USE_DEFAULT_CANCEL_ERROR_CODE = net::OK; |
| 563 | 557 |
| 564 GenericResourceThrottle(int flags, int code) | 558 GenericResourceThrottle(int flags, int code) |
| 565 : flags_(flags), | 559 : flags_(flags), |
| 566 error_code_for_cancellation_(code) { | 560 error_code_for_cancellation_(code) { |
| 567 } | 561 } |
| 568 | 562 |
| 569 virtual ~GenericResourceThrottle() { | 563 ~GenericResourceThrottle() override { |
| 570 if (active_throttle_ == this) | 564 if (active_throttle_ == this) |
| 571 active_throttle_ = NULL; | 565 active_throttle_ = NULL; |
| 572 } | 566 } |
| 573 | 567 |
| 574 // ResourceThrottle implementation: | 568 // ResourceThrottle implementation: |
| 575 virtual void WillStartRequest(bool* defer) override { | 569 void WillStartRequest(bool* defer) override { |
| 576 ASSERT_EQ(NULL, active_throttle_); | 570 ASSERT_EQ(NULL, active_throttle_); |
| 577 if (flags_ & DEFER_STARTING_REQUEST) { | 571 if (flags_ & DEFER_STARTING_REQUEST) { |
| 578 active_throttle_ = this; | 572 active_throttle_ = this; |
| 579 *defer = true; | 573 *defer = true; |
| 580 } | 574 } |
| 581 | 575 |
| 582 if (flags_ & CANCEL_BEFORE_START) { | 576 if (flags_ & CANCEL_BEFORE_START) { |
| 583 if (error_code_for_cancellation_ == USE_DEFAULT_CANCEL_ERROR_CODE) { | 577 if (error_code_for_cancellation_ == USE_DEFAULT_CANCEL_ERROR_CODE) { |
| 584 controller()->Cancel(); | 578 controller()->Cancel(); |
| 585 } else { | 579 } else { |
| 586 controller()->CancelWithError(error_code_for_cancellation_); | 580 controller()->CancelWithError(error_code_for_cancellation_); |
| 587 } | 581 } |
| 588 } | 582 } |
| 589 } | 583 } |
| 590 | 584 |
| 591 virtual void WillProcessResponse(bool* defer) override { | 585 void WillProcessResponse(bool* defer) override { |
| 592 ASSERT_EQ(NULL, active_throttle_); | 586 ASSERT_EQ(NULL, active_throttle_); |
| 593 if (flags_ & DEFER_PROCESSING_RESPONSE) { | 587 if (flags_ & DEFER_PROCESSING_RESPONSE) { |
| 594 active_throttle_ = this; | 588 active_throttle_ = this; |
| 595 *defer = true; | 589 *defer = true; |
| 596 } | 590 } |
| 597 } | 591 } |
| 598 | 592 |
| 599 virtual void WillStartUsingNetwork(bool* defer) override { | 593 void WillStartUsingNetwork(bool* defer) override { |
| 600 ASSERT_EQ(NULL, active_throttle_); | 594 ASSERT_EQ(NULL, active_throttle_); |
| 601 | 595 |
| 602 if (flags_ & DEFER_NETWORK_START) { | 596 if (flags_ & DEFER_NETWORK_START) { |
| 603 active_throttle_ = this; | 597 active_throttle_ = this; |
| 604 *defer = true; | 598 *defer = true; |
| 605 } | 599 } |
| 606 } | 600 } |
| 607 | 601 |
| 608 virtual const char* GetNameForLogging() const override { | 602 const char* GetNameForLogging() const override { |
| 609 return "GenericResourceThrottle"; | 603 return "GenericResourceThrottle"; |
| 610 } | 604 } |
| 611 | 605 |
| 612 void Resume() { | 606 void Resume() { |
| 613 ASSERT_TRUE(this == active_throttle_); | 607 ASSERT_TRUE(this == active_throttle_); |
| 614 active_throttle_ = NULL; | 608 active_throttle_ = NULL; |
| 615 controller()->Resume(); | 609 controller()->Resume(); |
| 616 } | 610 } |
| 617 | 611 |
| 618 static GenericResourceThrottle* active_throttle() { | 612 static GenericResourceThrottle* active_throttle() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 void set_error_code_for_cancellation(int code) { | 644 void set_error_code_for_cancellation(int code) { |
| 651 error_code_for_cancellation_ = code; | 645 error_code_for_cancellation_ = code; |
| 652 } | 646 } |
| 653 | 647 |
| 654 void set_create_two_throttles(bool create_two_throttles) { | 648 void set_create_two_throttles(bool create_two_throttles) { |
| 655 create_two_throttles_ = create_two_throttles; | 649 create_two_throttles_ = create_two_throttles; |
| 656 } | 650 } |
| 657 | 651 |
| 658 // ResourceDispatcherHostDelegate implementation: | 652 // ResourceDispatcherHostDelegate implementation: |
| 659 | 653 |
| 660 virtual void RequestBeginning( | 654 void RequestBeginning(net::URLRequest* request, |
| 661 net::URLRequest* request, | 655 ResourceContext* resource_context, |
| 662 ResourceContext* resource_context, | 656 AppCacheService* appcache_service, |
| 663 AppCacheService* appcache_service, | 657 ResourceType resource_type, |
| 664 ResourceType resource_type, | 658 ScopedVector<ResourceThrottle>* throttles) override { |
| 665 ScopedVector<ResourceThrottle>* throttles) override { | |
| 666 if (user_data_) { | 659 if (user_data_) { |
| 667 const void* key = user_data_.get(); | 660 const void* key = user_data_.get(); |
| 668 request->SetUserData(key, user_data_.release()); | 661 request->SetUserData(key, user_data_.release()); |
| 669 } | 662 } |
| 670 | 663 |
| 671 if (flags_ != NONE) { | 664 if (flags_ != NONE) { |
| 672 throttles->push_back(new GenericResourceThrottle( | 665 throttles->push_back(new GenericResourceThrottle( |
| 673 flags_, error_code_for_cancellation_)); | 666 flags_, error_code_for_cancellation_)); |
| 674 if (create_two_throttles_) | 667 if (create_two_throttles_) |
| 675 throttles->push_back(new GenericResourceThrottle( | 668 throttles->push_back(new GenericResourceThrottle( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 filter_ = MakeForwardingFilter(); | 715 filter_ = MakeForwardingFilter(); |
| 723 // TODO(cbentzel): Better way to get URLRequestContext? | 716 // TODO(cbentzel): Better way to get URLRequestContext? |
| 724 net::URLRequestContext* request_context = | 717 net::URLRequestContext* request_context = |
| 725 browser_context_->GetResourceContext()->GetRequestContext(); | 718 browser_context_->GetResourceContext()->GetRequestContext(); |
| 726 job_factory_.reset(new TestURLRequestJobFactory(this)); | 719 job_factory_.reset(new TestURLRequestJobFactory(this)); |
| 727 request_context->set_job_factory(job_factory_.get()); | 720 request_context->set_job_factory(job_factory_.get()); |
| 728 request_context->set_network_delegate(&network_delegate_); | 721 request_context->set_network_delegate(&network_delegate_); |
| 729 } | 722 } |
| 730 | 723 |
| 731 // IPC::Sender implementation | 724 // IPC::Sender implementation |
| 732 virtual bool Send(IPC::Message* msg) override { | 725 bool Send(IPC::Message* msg) override { |
| 733 accum_.AddMessage(*msg); | 726 accum_.AddMessage(*msg); |
| 734 | 727 |
| 735 if (send_data_received_acks_ && | 728 if (send_data_received_acks_ && |
| 736 msg->type() == ResourceMsg_DataReceived::ID) { | 729 msg->type() == ResourceMsg_DataReceived::ID) { |
| 737 GenerateDataReceivedACK(*msg); | 730 GenerateDataReceivedACK(*msg); |
| 738 } | 731 } |
| 739 | 732 |
| 740 if (wait_for_request_complete_loop_ && | 733 if (wait_for_request_complete_loop_ && |
| 741 msg->type() == ResourceMsg_RequestComplete::ID) { | 734 msg->type() == ResourceMsg_RequestComplete::ID) { |
| 742 wait_for_request_complete_loop_->Quit(); | 735 wait_for_request_complete_loop_->Quit(); |
| (...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3001 } else { | 2994 } else { |
| 3002 return new net::URLRequestTestJob( | 2995 return new net::URLRequestTestJob( |
| 3003 request, network_delegate, | 2996 request, network_delegate, |
| 3004 test_fixture_->response_headers_, test_fixture_->response_data_, | 2997 test_fixture_->response_headers_, test_fixture_->response_data_, |
| 3005 false); | 2998 false); |
| 3006 } | 2999 } |
| 3007 } | 3000 } |
| 3008 } | 3001 } |
| 3009 | 3002 |
| 3010 } // namespace content | 3003 } // namespace content |
| OLD | NEW |