| 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 "mojo/services/network/url_loader_impl.h" | 5 #include "mojo/services/network/url_loader_impl.h" |
| 6 | 6 |
| 7 #include "mojo/services/network/network_context.h" | 7 #include "mojo/services/network/network_context.h" |
| 8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
| 9 #include "net/base/load_flags.h" |
| 9 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| 10 | 11 |
| 11 namespace mojo { | 12 namespace mojo { |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 const uint32_t kMaxReadSize = 64 * 1024; | 15 const uint32_t kMaxReadSize = 64 * 1024; |
| 15 | 16 |
| 16 // Generates an URLResponsePtr from the response state of a net::URLRequest. | 17 // Generates an URLResponsePtr from the response state of a net::URLRequest. |
| 17 URLResponsePtr MakeURLResponse(const net::URLRequest* url_request) { | 18 URLResponsePtr MakeURLResponse(const net::URLRequest* url_request) { |
| 18 URLResponsePtr response(URLResponse::New()); | 19 URLResponsePtr response(URLResponse::New()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 119 } |
| 119 | 120 |
| 120 response_body_stream_ = response_body_stream.Pass(); | 121 response_body_stream_ = response_body_stream.Pass(); |
| 121 | 122 |
| 122 GURL url(request->url); | 123 GURL url(request->url); |
| 123 url_request_.reset( | 124 url_request_.reset( |
| 124 new net::URLRequest(url, | 125 new net::URLRequest(url, |
| 125 net::DEFAULT_PRIORITY, | 126 net::DEFAULT_PRIORITY, |
| 126 this, | 127 this, |
| 127 context_->url_request_context())); | 128 context_->url_request_context())); |
| 129 if (request->bypass_cache) |
| 130 url_request_->SetLoadFlags(net::LOAD_BYPASS_CACHE); |
| 128 url_request_->Start(); | 131 url_request_->Start(); |
| 129 } | 132 } |
| 130 | 133 |
| 131 void URLLoaderImpl::FollowRedirect() { | 134 void URLLoaderImpl::FollowRedirect() { |
| 132 NOTIMPLEMENTED(); | 135 NOTIMPLEMENTED(); |
| 133 } | 136 } |
| 134 | 137 |
| 135 void URLLoaderImpl::OnReceivedRedirect(net::URLRequest* url_request, | 138 void URLLoaderImpl::OnReceivedRedirect(net::URLRequest* url_request, |
| 136 const GURL& new_url, | 139 const GURL& new_url, |
| 137 bool* defer_redirect) { | 140 bool* defer_redirect) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if (completed_synchronously) { | 226 if (completed_synchronously) { |
| 224 base::MessageLoop::current()->PostTask( | 227 base::MessageLoop::current()->PostTask( |
| 225 FROM_HERE, | 228 FROM_HERE, |
| 226 base::Bind(&URLLoaderImpl::ReadMore, weak_ptr_factory_.GetWeakPtr())); | 229 base::Bind(&URLLoaderImpl::ReadMore, weak_ptr_factory_.GetWeakPtr())); |
| 227 } else { | 230 } else { |
| 228 ReadMore(); | 231 ReadMore(); |
| 229 } | 232 } |
| 230 } | 233 } |
| 231 | 234 |
| 232 } // namespace mojo | 235 } // namespace mojo |
| OLD | NEW |