| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cronet_bidirectional_stream_adapter.h" | 5 #include "cronet_bidirectional_stream_adapter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Get http status code from response headers. | 181 // Get http status code from response headers. |
| 182 jint http_status_code = 0; | 182 jint http_status_code = 0; |
| 183 const auto http_status_header = response_headers.find(":status"); | 183 const auto http_status_header = response_headers.find(":status"); |
| 184 if (http_status_header != response_headers.end()) | 184 if (http_status_header != response_headers.end()) |
| 185 base::StringToInt(http_status_header->second, &http_status_code); | 185 base::StringToInt(http_status_header->second, &http_status_code); |
| 186 | 186 |
| 187 std::string protocol; | 187 std::string protocol; |
| 188 switch (bidi_stream_->GetProtocol()) { | 188 switch (bidi_stream_->GetProtocol()) { |
| 189 case net::kProtoHTTP2: | 189 case net::kProtoHTTP2: |
| 190 protocol = "h2"; | 190 protocol = "h2"; |
| 191 break; |
| 192 case net::kProtoQUIC1SPDY3: |
| 193 protocol = "quic/1+spdy/3"; |
| 194 break; |
| 191 default: | 195 default: |
| 192 break; | 196 break; |
| 193 } | 197 } |
| 194 | 198 |
| 195 cronet::Java_CronetBidirectionalStream_onResponseHeadersReceived( | 199 cronet::Java_CronetBidirectionalStream_onResponseHeadersReceived( |
| 196 env, owner_.obj(), http_status_code, | 200 env, owner_.obj(), http_status_code, |
| 197 ConvertUTF8ToJavaString(env, protocol).obj(), | 201 ConvertUTF8ToJavaString(env, protocol).obj(), |
| 198 GetHeadersArray(env, response_headers).obj(), | 202 GetHeadersArray(env, response_headers).obj(), |
| 199 bidi_stream_->GetTotalReceivedBytes()); | 203 bidi_stream_->GetTotalReceivedBytes()); |
| 200 } | 204 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 309 |
| 306 std::vector<std::string> headers; | 310 std::vector<std::string> headers; |
| 307 for (const auto& header : header_block) { | 311 for (const auto& header : header_block) { |
| 308 headers.push_back(header.first.as_string()); | 312 headers.push_back(header.first.as_string()); |
| 309 headers.push_back(header.second.as_string()); | 313 headers.push_back(header.second.as_string()); |
| 310 } | 314 } |
| 311 return base::android::ToJavaArrayOfStrings(env, headers); | 315 return base::android::ToJavaArrayOfStrings(env, headers); |
| 312 } | 316 } |
| 313 | 317 |
| 314 } // namespace cronet | 318 } // namespace cronet |
| OLD | NEW |