OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 resource_dispatcher_->StartSync( | 551 resource_dispatcher_->StartSync( |
552 request_info, request_body.get(), sync_load_response, | 552 request_info, request_body.get(), sync_load_response, |
553 request.getLoadingIPCType(), url_loader_factory_); | 553 request.getLoadingIPCType(), url_loader_factory_); |
554 return; | 554 return; |
555 } | 555 } |
556 | 556 |
557 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this, | 557 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this, |
558 TRACE_EVENT_FLAG_FLOW_OUT); | 558 TRACE_EVENT_FLAG_FLOW_OUT); |
559 request_id_ = resource_dispatcher_->StartAsync( | 559 request_id_ = resource_dispatcher_->StartAsync( |
560 request_info, request_body.get(), | 560 request_info, request_body.get(), |
561 base::WrapUnique(new WebURLLoaderImpl::RequestPeerImpl(this)), | 561 base::MakeUnique<WebURLLoaderImpl::RequestPeerImpl>(this), |
562 request.getLoadingIPCType(), url_loader_factory_); | 562 request.getLoadingIPCType(), url_loader_factory_); |
563 | 563 |
564 if (defers_loading_ != NOT_DEFERRING) | 564 if (defers_loading_ != NOT_DEFERRING) |
565 resource_dispatcher_->SetDefersLoading(request_id_, true); | 565 resource_dispatcher_->SetDefersLoading(request_id_, true); |
566 } | 566 } |
567 | 567 |
568 void WebURLLoaderImpl::Context::SetTaskRunner( | 568 void WebURLLoaderImpl::Context::SetTaskRunner( |
569 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 569 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
570 task_runner_ = task_runner; | 570 task_runner_ = task_runner; |
571 } | 571 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 666 } |
667 | 667 |
668 if (request_.useStreamOnResponse()) { | 668 if (request_.useStreamOnResponse()) { |
669 SharedMemoryDataConsumerHandle::BackpressureMode mode = | 669 SharedMemoryDataConsumerHandle::BackpressureMode mode = |
670 SharedMemoryDataConsumerHandle::kDoNotApplyBackpressure; | 670 SharedMemoryDataConsumerHandle::kDoNotApplyBackpressure; |
671 if (info.headers && | 671 if (info.headers && |
672 info.headers->HasHeaderValue("Cache-Control", "no-store")) { | 672 info.headers->HasHeaderValue("Cache-Control", "no-store")) { |
673 mode = SharedMemoryDataConsumerHandle::kApplyBackpressure; | 673 mode = SharedMemoryDataConsumerHandle::kApplyBackpressure; |
674 } | 674 } |
675 | 675 |
676 auto read_handle = base::WrapUnique(new SharedMemoryDataConsumerHandle( | 676 auto read_handle = base::MakeUnique<SharedMemoryDataConsumerHandle>( |
677 mode, base::Bind(&Context::CancelBodyStreaming, this), | 677 mode, base::Bind(&Context::CancelBodyStreaming, this), |
678 &body_stream_writer_)); | 678 &body_stream_writer_); |
679 | 679 |
680 // Here |body_stream_writer_| has an indirect reference to |this| and that | 680 // Here |body_stream_writer_| has an indirect reference to |this| and that |
681 // creates a reference cycle, but it is not a problem because the cycle | 681 // creates a reference cycle, but it is not a problem because the cycle |
682 // will break if one of the following happens: | 682 // will break if one of the following happens: |
683 // 1) The body data transfer is done (with or without an error). | 683 // 1) The body data transfer is done (with or without an error). |
684 // 2) |read_handle| (and its reader) is detached. | 684 // 2) |read_handle| (and its reader) is detached. |
685 | 685 |
686 // The client takes |read_handle|'s ownership. | 686 // The client takes |read_handle|'s ownership. |
687 client_->didReceiveResponse(loader_, response, read_handle.release()); | 687 client_->didReceiveResponse(loader_, response, read_handle.release()); |
688 // TODO(yhirano): Support ftp listening and multipart | 688 // TODO(yhirano): Support ftp listening and multipart |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 ResourceResponseInfo info; | 864 ResourceResponseInfo info; |
865 std::string data; | 865 std::string data; |
866 | 866 |
867 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); | 867 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); |
868 | 868 |
869 if (error_code == net::OK) { | 869 if (error_code == net::OK) { |
870 OnReceivedResponse(info); | 870 OnReceivedResponse(info); |
871 auto size = data.size(); | 871 auto size = data.size(); |
872 if (size != 0) | 872 if (size != 0) |
873 OnReceivedData( | 873 OnReceivedData( |
874 base::WrapUnique(new FixedReceivedData(data.data(), size, 0, size))); | 874 base::MakeUnique<FixedReceivedData>(data.data(), size, 0, size)); |
875 } | 875 } |
876 | 876 |
877 OnCompletedRequest(error_code, false, false, info.security_info, | 877 OnCompletedRequest(error_code, false, false, info.security_info, |
878 base::TimeTicks::Now(), 0); | 878 base::TimeTicks::Now(), 0); |
879 } | 879 } |
880 | 880 |
881 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ | 881 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ |
882 | 882 |
883 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) | 883 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) |
884 : context_(context) {} | 884 : context_(context) {} |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 response->clearHTTPHeaderField(webStringName); | 1212 response->clearHTTPHeaderField(webStringName); |
1213 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1213 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
1214 response->addHTTPHeaderField(webStringName, | 1214 response->addHTTPHeaderField(webStringName, |
1215 WebString::fromLatin1(value)); | 1215 WebString::fromLatin1(value)); |
1216 } | 1216 } |
1217 } | 1217 } |
1218 return true; | 1218 return true; |
1219 } | 1219 } |
1220 | 1220 |
1221 } // namespace content | 1221 } // namespace content |
OLD | NEW |