| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/client/plugin/pepper_url_request.h" | 5 #include "remoting/client/plugin/pepper_url_request.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 10 #include "ppapi/cpp/url_response_info.h" | 11 #include "ppapi/cpp/url_response_info.h" |
| 11 | 12 |
| 12 // Read buffer we allocate per read when reading response from | 13 // Read buffer we allocate per read when reading response from |
| 13 // URLLoader. | 14 // URLLoader. |
| 14 static const int kReadSize = 1024; | 15 static const int kReadSize = 1024; |
| 15 | 16 |
| 16 namespace remoting { | 17 namespace remoting { |
| 17 | 18 |
| 18 PepperUrlRequest::PepperUrlRequest(pp::InstanceHandle pp_instance, | 19 PepperUrlRequest::PepperUrlRequest( |
| 19 UrlRequest::Type type, | 20 pp::InstanceHandle pp_instance, |
| 20 const std::string& url) | 21 UrlRequest::Type type, |
| 22 const std::string& url, |
| 23 const net::NetworkTrafficAnnotationTag& traffic_annotation) |
| 21 : request_info_(pp_instance), | 24 : request_info_(pp_instance), |
| 22 url_loader_(pp_instance), | 25 url_loader_(pp_instance), |
| 23 url_(url), | 26 url_(url), |
| 24 callback_factory_(this) { | 27 callback_factory_(this) { |
| 25 request_info_.SetURL(url); | 28 request_info_.SetURL(url); |
| 26 switch (type) { | 29 switch (type) { |
| 27 case Type::GET: | 30 case Type::GET: |
| 28 request_info_.SetMethod("GET"); | 31 request_info_.SetMethod("GET"); |
| 29 break; | 32 break; |
| 30 case Type::POST: | 33 case Type::POST: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 base::ResetAndReturn(&on_result_callback_) | 106 base::ResetAndReturn(&on_result_callback_) |
| 104 .Run(Result(url_loader_.GetResponseInfo().GetStatusCode(), response_)); | 107 .Run(Result(url_loader_.GetResponseInfo().GetStatusCode(), response_)); |
| 105 } | 108 } |
| 106 | 109 |
| 107 PepperUrlRequestFactory::PepperUrlRequestFactory(pp::InstanceHandle pp_instance) | 110 PepperUrlRequestFactory::PepperUrlRequestFactory(pp::InstanceHandle pp_instance) |
| 108 : pp_instance_(pp_instance) {} | 111 : pp_instance_(pp_instance) {} |
| 109 PepperUrlRequestFactory::~PepperUrlRequestFactory() {} | 112 PepperUrlRequestFactory::~PepperUrlRequestFactory() {} |
| 110 | 113 |
| 111 std::unique_ptr<UrlRequest> PepperUrlRequestFactory::CreateUrlRequest( | 114 std::unique_ptr<UrlRequest> PepperUrlRequestFactory::CreateUrlRequest( |
| 112 UrlRequest::Type type, | 115 UrlRequest::Type type, |
| 113 const std::string& url) { | 116 const std::string& url, |
| 114 return base::MakeUnique<PepperUrlRequest>(pp_instance_, type, url); | 117 const net::NetworkTrafficAnnotationTag& traffic_annotation) { |
| 118 return base::MakeUnique<PepperUrlRequest>(pp_instance_, type, url, |
| 119 traffic_annotation); |
| 115 } | 120 } |
| 116 | 121 |
| 117 } // namespace remoting | 122 } // namespace remoting |
| OLD | NEW |