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

Unified Diff: content/public/common/resource_request_body.h

Issue 2038233002: Using ResourceRequestBody as the type of HTTP body outside of //content. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/page_navigator.h ('k') | content/public/common/resource_request_body.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/resource_request_body.h
diff --git a/content/public/common/resource_request_body.h b/content/public/common/resource_request_body.h
index 59f654ed8922cfcab63e6c288873430c50f17cdc..606c31994c8d1affc189b147179a1a8c9a1f1a60 100644
--- a/content/public/common/resource_request_body.h
+++ b/content/public/common/resource_request_body.h
@@ -7,27 +7,54 @@
#include <stdint.h>
+#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "build/build_config.h"
#include "content/common/content_export.h"
+#if defined(OS_ANDROID)
+#include <jni.h>
+#include "base/android/scoped_java_ref.h"
+#endif
+
namespace content {
// ResourceRequestBody represents body (i.e. upload data) of a HTTP request.
//
// This class is intentionally opaque:
-// - Embedders cannot inspect the payload of ResourceRequestBody. Only the
-// //content layer can decompose ResourceRequestBody into references to file
-// ranges, byte vectors, blob uris, etc.
-// - Embedders can get instances of ResourceRequestBody only by receiving an
-// instance created inside //content layer (e.g. receiving it via
-// content::OpenURLParams).
-// - Embedders typically end up passing ResourceRequestBody back into the
-// //content layer via content::NavigationController::LoadUrlParams.
+// *) Embedders cannot inspect the payload of ResourceRequestBody. Only the
+// //content layer can decompose ResourceRequestBody into references to file
+// ranges, byte vectors, blob uris, etc.
+// *) Embedders can get instances of ResourceRequestBody only by
+// - receiving an instance created inside //content layer (e.g. receiving it
+// via content::OpenURLParams),
+// - calling CreateFromBytes with a vector of bytes (e.g. to support
+// Android's WebView::postUrl API, to support DoSearchByImageInNewTab and
+// to support test code).
+// *) Embedders typically end up passing ResourceRequestBody back into the
+// //content layer via content::NavigationController::LoadUrlParams.
class CONTENT_EXPORT ResourceRequestBody
: public base::RefCountedThreadSafe<ResourceRequestBody> {
+ public:
+ // Creates ResourceRequestBody that holds a copy of |bytes|.
+ static scoped_refptr<ResourceRequestBody> CreateFromBytes(const char* bytes,
+ size_t length);
+
+#if defined(OS_ANDROID)
+ // Returns a org.chromium.content_public.common.ResourceRequestBody Java
+ // object that wraps a ref-counted pointer to the |resource_request_body|.
+ base::android::ScopedJavaLocalRef<jobject> ToJavaObject(JNIEnv* env);
+
+ // Extracts and returns a C++ object out of Java's
+ // org.chromium.content_public.common.ResourceRequestBody.
+ static scoped_refptr<ResourceRequestBody> FromJavaObject(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& java_object);
+#endif
+
protected:
ResourceRequestBody();
virtual ~ResourceRequestBody();
« no previous file with comments | « content/public/browser/page_navigator.h ('k') | content/public/common/resource_request_body.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698