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

Side by Side Diff: content/common/resource_request_body_impl.cc

Issue 2030473002: ABANDONED CL: Using ResourceRequestBody as the type of browser_initiated_post_data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make-resource-request-body-public
Patch Set: Rebasing... Created 4 years, 6 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
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 "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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698