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 "net/url_request/url_fetcher_core.h" | 5 #include "net/url_request/url_fetcher_core.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util_proxy.h" | 8 #include "base/file_util_proxy.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // Since StartURLRequest() is posted as a *delayed* task, it may | 655 // Since StartURLRequest() is posted as a *delayed* task, it may |
656 // run after the URLFetcher was already stopped. | 656 // run after the URLFetcher was already stopped. |
657 return; | 657 return; |
658 } | 658 } |
659 | 659 |
660 DCHECK(request_context_getter_); | 660 DCHECK(request_context_getter_); |
661 DCHECK(!request_.get()); | 661 DCHECK(!request_.get()); |
662 | 662 |
663 g_registry.Get().AddURLFetcherCore(this); | 663 g_registry.Get().AddURLFetcherCore(this); |
664 current_response_bytes_ = 0; | 664 current_response_bytes_ = 0; |
665 request_.reset(new URLRequest(original_url_, this)); | 665 request_.reset(new URLRequest( |
| 666 original_url_, |
| 667 this, |
| 668 request_context_getter_->GetURLRequestContext())); |
666 request_->set_stack_trace(stack_trace_); | 669 request_->set_stack_trace(stack_trace_); |
667 int flags = request_->load_flags() | load_flags_; | 670 int flags = request_->load_flags() | load_flags_; |
668 if (!g_interception_enabled) | 671 if (!g_interception_enabled) |
669 flags = flags | LOAD_DISABLE_INTERCEPT; | 672 flags = flags | LOAD_DISABLE_INTERCEPT; |
670 | 673 |
671 if (is_chunked_upload_) | 674 if (is_chunked_upload_) |
672 request_->EnableChunkedUpload(); | 675 request_->EnableChunkedUpload(); |
673 request_->set_load_flags(flags); | 676 request_->set_load_flags(flags); |
674 request_->set_context(request_context_getter_->GetURLRequestContext()); | |
675 request_->set_referrer(referrer_); | 677 request_->set_referrer(referrer_); |
676 request_->set_first_party_for_cookies(first_party_for_cookies_.is_empty() ? | 678 request_->set_first_party_for_cookies(first_party_for_cookies_.is_empty() ? |
677 original_url_ : first_party_for_cookies_); | 679 original_url_ : first_party_for_cookies_); |
678 if (url_request_data_key_ && !url_request_create_data_callback_.is_null()) { | 680 if (url_request_data_key_ && !url_request_create_data_callback_.is_null()) { |
679 request_->SetUserData(url_request_data_key_, | 681 request_->SetUserData(url_request_data_key_, |
680 url_request_create_data_callback_.Run()); | 682 url_request_create_data_callback_.Run()); |
681 } | 683 } |
682 | 684 |
683 switch (request_type_) { | 685 switch (request_type_) { |
684 case URLFetcher::GET: | 686 case URLFetcher::GET: |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 } | 998 } |
997 | 999 |
998 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( | 1000 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( |
999 scoped_ptr<std::string> download_data) { | 1001 scoped_ptr<std::string> download_data) { |
1000 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 1002 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
1001 if (delegate_) | 1003 if (delegate_) |
1002 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); | 1004 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); |
1003 } | 1005 } |
1004 | 1006 |
1005 } // namespace net | 1007 } // namespace net |
OLD | NEW |