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 #ifndef CONTENT_PUBLIC_COMMON_RESOURCE_REQUEST_BODY_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_RESOURCE_REQUEST_BODY_H_ |
6 #define CONTENT_PUBLIC_COMMON_RESOURCE_REQUEST_BODY_H_ | 6 #define CONTENT_PUBLIC_COMMON_RESOURCE_REQUEST_BODY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "build/build_config.h" |
14 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
15 | 17 |
| 18 #if defined(OS_ANDROID) |
| 19 #include <jni.h> |
| 20 #include "base/android/scoped_java_ref.h" |
| 21 #endif |
| 22 |
16 namespace content { | 23 namespace content { |
17 | 24 |
18 // ResourceRequestBody represents body (i.e. upload data) of a HTTP request. | 25 // ResourceRequestBody represents body (i.e. upload data) of a HTTP request. |
19 class CONTENT_EXPORT ResourceRequestBody | 26 class CONTENT_EXPORT ResourceRequestBody |
20 : public base::RefCountedThreadSafe<ResourceRequestBody> { | 27 : public base::RefCountedThreadSafe<ResourceRequestBody> { |
| 28 public: |
| 29 // Creates ResourceRequestBody that holds a copy of |bytes|. |
| 30 static scoped_refptr<ResourceRequestBody> CreateFromBytes(const char* bytes, |
| 31 size_t length); |
| 32 static scoped_refptr<ResourceRequestBody> CreateFromBytes( |
| 33 const std::string& bytes); |
| 34 |
| 35 #if defined(OS_ANDROID) |
| 36 // Converts ResourceRequestBody to a Java byte array. |
| 37 // Works only for ResourceRequestBodies created via CreateFromBytes above. |
| 38 virtual base::android::ScopedJavaLocalRef<jbyteArray> ToJavaByteArray( |
| 39 JNIEnv* env) const = 0; |
| 40 #endif |
| 41 |
21 protected: | 42 protected: |
22 ResourceRequestBody(); | 43 ResourceRequestBody(); |
23 virtual ~ResourceRequestBody(); | 44 virtual ~ResourceRequestBody(); |
24 | 45 |
25 private: | 46 private: |
26 friend class base::RefCountedThreadSafe<ResourceRequestBody>; | 47 friend class base::RefCountedThreadSafe<ResourceRequestBody>; |
27 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody); | 48 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody); |
28 }; | 49 }; |
29 | 50 |
30 } // namespace content | 51 } // namespace content |
31 | 52 |
32 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_REQUEST_BODY_H_ | 53 #endif // CONTENT_PUBLIC_COMMON_RESOURCE_REQUEST_BODY_H_ |
OLD | NEW |