Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: mojo/services/html_viewer/weburlloader_impl.cc

Issue 453133002: Mojo: Generalize blink::URLRequest -> mojo::URLRequest conversion, and use it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 =
69 url_request->url = String::From(url_); 70 TypeConverter<URLRequestPtr, blink::WebURLRequest>::ConvertFrom(request);
darin (slow to review) 2014/08/12 16:23:12 nit: URLRequest::From(request)
Matt Perry 2014/08/12 18:42:53 Done.
70 url_request->method = request.httpMethod().utf8();
71 url_request->auto_follow_redirects = false; 71 url_request->auto_follow_redirects = false;
72 // TODO(darin): Copy other fields.
73 72
74 if (request.extraData()) { 73 if (request.extraData()) {
75 WebURLRequestExtraData* extra_data = 74 WebURLRequestExtraData* extra_data =
76 static_cast<WebURLRequestExtraData*>(request.extraData()); 75 static_cast<WebURLRequestExtraData*>(request.extraData());
77 base::ThreadTaskRunnerHandle::Get()->PostTask( 76 base::ThreadTaskRunnerHandle::Get()->PostTask(
78 FROM_HERE, 77 FROM_HERE,
79 base::Bind(&WebURLLoaderImpl::OnReceivedResponse, 78 base::Bind(&WebURLLoaderImpl::OnReceivedResponse,
80 weak_factory_.GetWeakPtr(), 79 weak_factory_.GetWeakPtr(),
81 base::Passed(&extra_data->synthetic_response))); 80 base::Passed(&extra_data->synthetic_response)));
82 } else { 81 } else {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 MOJO_DEADLINE_INDEFINITE, 185 MOJO_DEADLINE_INDEFINITE,
187 base::Bind(&WebURLLoaderImpl::OnResponseBodyStreamReady, 186 base::Bind(&WebURLLoaderImpl::OnResponseBodyStreamReady,
188 weak_factory_.GetWeakPtr())); 187 weak_factory_.GetWeakPtr()));
189 } 188 }
190 189
191 void WebURLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) { 190 void WebURLLoaderImpl::OnResponseBodyStreamReady(MojoResult result) {
192 ReadMore(); 191 ReadMore();
193 } 192 }
194 193
195 } // namespace mojo 194 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698