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 "content/common/resource_request_body_impl.h" | 5 #include "content/common/resource_request_body_impl.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/common/page_state_serialization.h" | 8 #include "content/common/page_state_serialization.h" |
9 | 9 |
| 10 #if defined(OS_ANDROID) |
| 11 #include "base/android/jni_array.h" |
| 12 #endif |
| 13 |
10 using blink::WebHTTPBody; | 14 using blink::WebHTTPBody; |
11 using blink::WebString; | 15 using blink::WebString; |
12 | 16 |
13 namespace content { | 17 namespace content { |
14 | 18 |
15 ResourceRequestBodyImpl::ResourceRequestBodyImpl() : identifier_(0) {} | 19 ResourceRequestBodyImpl::ResourceRequestBodyImpl() : identifier_(0) {} |
16 | 20 |
17 void ResourceRequestBodyImpl::AppendBytes(const char* bytes, int bytes_len) { | 21 void ResourceRequestBodyImpl::AppendBytes(const char* bytes, int bytes_len) { |
18 if (bytes_len > 0) { | 22 if (bytes_len > 0) { |
19 elements_.push_back(Element()); | 23 elements_.push_back(Element()); |
(...skipping 21 matching lines...) Expand all Loading... |
41 uint64_t offset, | 45 uint64_t offset, |
42 uint64_t length, | 46 uint64_t length, |
43 const base::Time& expected_modification_time) { | 47 const base::Time& expected_modification_time) { |
44 elements_.push_back(Element()); | 48 elements_.push_back(Element()); |
45 elements_.back().SetToFileSystemUrlRange(url, offset, length, | 49 elements_.back().SetToFileSystemUrlRange(url, offset, length, |
46 expected_modification_time); | 50 expected_modification_time); |
47 } | 51 } |
48 | 52 |
49 ResourceRequestBodyImpl::~ResourceRequestBodyImpl() {} | 53 ResourceRequestBodyImpl::~ResourceRequestBodyImpl() {} |
50 | 54 |
| 55 #if defined(OS_ANDROID) |
| 56 base::android::ScopedJavaLocalRef<jbyteArray> |
| 57 ResourceRequestBodyImpl::ToJavaByteArray(JNIEnv* env) const { |
| 58 if (elements_.size() != 1 || |
| 59 elements_[0].type() != ResourceRequestBodyImpl::Element::TYPE_BYTES) { |
| 60 // This method should only be used on instances created via |
| 61 // ResourceRequestBody::CreateFromBytes. |
| 62 NOTREACHED(); |
| 63 return base::android::ScopedJavaLocalRef<jbyteArray>(); |
| 64 } |
| 65 |
| 66 return base::android::ToJavaByteArray( |
| 67 env, reinterpret_cast<const uint8_t*>(elements_[0].bytes()), |
| 68 elements_[0].length()); |
| 69 } |
| 70 #endif |
| 71 |
51 } // namespace content | 72 } // namespace content |
OLD | NEW |