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/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
| 11 #include "mojo/services/html_viewer/blink_url_request_type_converters.h" |
11 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | 12 #include "mojo/services/public/interfaces/network/network_service.mojom.h" |
12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
13 #include "third_party/WebKit/public/platform/WebURLError.h" | 14 #include "third_party/WebKit/public/platform/WebURLError.h" |
14 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" | 15 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" |
15 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 16 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
16 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 17 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 namespace { | 20 namespace { |
20 | 21 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 blink::WebURLError& error, | 59 blink::WebURLError& error, |
59 blink::WebData& data) { | 60 blink::WebData& data) { |
60 NOTIMPLEMENTED(); | 61 NOTIMPLEMENTED(); |
61 } | 62 } |
62 | 63 |
63 void WebURLLoaderImpl::loadAsynchronously(const blink::WebURLRequest& request, | 64 void WebURLLoaderImpl::loadAsynchronously(const blink::WebURLRequest& request, |
64 blink::WebURLLoaderClient* client) { | 65 blink::WebURLLoaderClient* client) { |
65 client_ = client; | 66 client_ = client; |
66 url_ = request.url(); | 67 url_ = request.url(); |
67 | 68 |
68 URLRequestPtr url_request(URLRequest::New()); | 69 URLRequestPtr url_request = URLRequest::From(request); |
69 url_request->url = String::From(url_); | |
70 url_request->method = request.httpMethod().utf8(); | |
71 url_request->auto_follow_redirects = false; | 70 url_request->auto_follow_redirects = false; |
72 // TODO(darin): Copy other fields. | |
73 | 71 |
74 if (request.extraData()) { | 72 if (request.extraData()) { |
75 WebURLRequestExtraData* extra_data = | 73 WebURLRequestExtraData* extra_data = |
76 static_cast<WebURLRequestExtraData*>(request.extraData()); | 74 static_cast<WebURLRequestExtraData*>(request.extraData()); |
77 base::ThreadTaskRunnerHandle::Get()->PostTask( | 75 base::ThreadTaskRunnerHandle::Get()->PostTask( |
78 FROM_HERE, | 76 FROM_HERE, |
79 base::Bind(&WebURLLoaderImpl::OnReceivedResponse, | 77 base::Bind(&WebURLLoaderImpl::OnReceivedResponse, |
80 weak_factory_.GetWeakPtr(), | 78 weak_factory_.GetWeakPtr(), |
81 base::Passed(&extra_data->synthetic_response))); | 79 base::Passed(&extra_data->synthetic_response))); |
82 } else { | 80 } else { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 MOJO_DEADLINE_INDEFINITE, | 184 MOJO_DEADLINE_INDEFINITE, |
187 base::Bind(&WebURLLoaderImpl::OnResponseBodyStreamReady, | 185 base::Bind(&WebURLLoaderImpl::OnResponseBodyStreamReady, |
188 weak_factory_.GetWeakPtr())); | 186 weak_factory_.GetWeakPtr())); |
189 } | 187 } |
190 | 188 |
191 void WebURLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) { | 189 void WebURLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) { |
192 ReadMore(); | 190 ReadMore(); |
193 } | 191 } |
194 | 192 |
195 } // namespace mojo | 193 } // namespace mojo |
OLD | NEW |