| 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/html_viewer/weburlloader_impl.h" | 5 #include "mojo/services/html_viewer/weburlloader_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 void WebURLLoaderImpl::cancel() { | 119 void WebURLLoaderImpl::cancel() { |
| 120 url_loader_.reset(); | 120 url_loader_.reset(); |
| 121 response_body_stream_.reset(); | 121 response_body_stream_.reset(); |
| 122 | 122 |
| 123 URLResponsePtr failed_response(mojo::URLResponse::New()); | 123 URLResponsePtr failed_response(mojo::URLResponse::New()); |
| 124 failed_response->url = mojo::String::From(url_); | 124 failed_response->url = mojo::String::From(url_); |
| 125 failed_response->error = mojo::NetworkError::New(); | 125 failed_response->error = mojo::NetworkError::New(); |
| 126 failed_response->error->code = net::ERR_ABORTED; | 126 failed_response->error->code = mojo::NETWORK_CODE_ABORTED; |
| 127 | 127 |
| 128 base::ThreadTaskRunnerHandle::Get()->PostTask( | 128 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 129 FROM_HERE, | 129 FROM_HERE, |
| 130 base::Bind(&WebURLLoaderImpl::OnReceivedResponse, | 130 base::Bind(&WebURLLoaderImpl::OnReceivedResponse, |
| 131 weak_factory_.GetWeakPtr(), | 131 weak_factory_.GetWeakPtr(), |
| 132 base::Passed(&failed_response))); | 132 base::Passed(&failed_response))); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void WebURLLoaderImpl::setDefersLoading(bool defers_loading) { | 135 void WebURLLoaderImpl::setDefersLoading(bool defers_loading) { |
| 136 NOTIMPLEMENTED(); | 136 NOTIMPLEMENTED(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 void WebURLLoaderImpl::OnReceivedError(URLResponsePtr url_response) { | 160 void WebURLLoaderImpl::OnReceivedError(URLResponsePtr url_response) { |
| 161 blink::WebURLError web_error; | 161 blink::WebURLError web_error; |
| 162 web_error.domain = blink::WebString::fromUTF8(net::kErrorDomain); | 162 web_error.domain = blink::WebString::fromUTF8(net::kErrorDomain); |
| 163 web_error.reason = url_response->error->code; | 163 web_error.reason = url_response->error->code; |
| 164 web_error.unreachableURL = GURL(url_response->url); | 164 web_error.unreachableURL = GURL(url_response->url); |
| 165 web_error.staleCopyInCache = false; | 165 web_error.staleCopyInCache = false; |
| 166 web_error.isCancellation = | 166 web_error.isCancellation = |
| 167 url_response->error->code == net::ERR_ABORTED ? true : false; | 167 url_response->error->code == mojo::NETWORK_CODE_ABORTED ? true : false; |
| 168 | 168 |
| 169 client_->didFail(this, web_error); | 169 client_->didFail(this, web_error); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void WebURLLoaderImpl::OnReceivedRedirect(URLResponsePtr url_response) { | 172 void WebURLLoaderImpl::OnReceivedRedirect(URLResponsePtr url_response) { |
| 173 blink::WebURLRequest new_request; | 173 blink::WebURLRequest new_request; |
| 174 new_request.initialize(); | 174 new_request.initialize(); |
| 175 new_request.setURL(GURL(url_response->redirect_url)); | 175 new_request.setURL(GURL(url_response->redirect_url)); |
| 176 new_request.setHTTPMethod( | 176 new_request.setHTTPMethod( |
| 177 blink::WebString::fromUTF8(url_response->redirect_method)); | 177 blink::WebString::fromUTF8(url_response->redirect_method)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 MOJO_DEADLINE_INDEFINITE, | 216 MOJO_DEADLINE_INDEFINITE, |
| 217 base::Bind(&WebURLLoaderImpl::OnResponseBodyStreamReady, | 217 base::Bind(&WebURLLoaderImpl::OnResponseBodyStreamReady, |
| 218 weak_factory_.GetWeakPtr())); | 218 weak_factory_.GetWeakPtr())); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void WebURLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) { | 221 void WebURLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) { |
| 222 ReadMore(); | 222 ReadMore(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace html_viewer | 225 } // namespace html_viewer |
| OLD | NEW |