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

Unified Diff: chrome/renderer/extensions/pepper_request_proxy.h

Issue 61383003: Pass pepper apps API calls through the existing js apps API bindings. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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
Index: chrome/renderer/extensions/pepper_request_proxy.h
diff --git a/chrome/renderer/extensions/pepper_request_proxy.h b/chrome/renderer/extensions/pepper_request_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..2e4d2d9ff07952bcaaa967380203527da5ca899f
--- /dev/null
+++ b/chrome/renderer/extensions/pepper_request_proxy.h
@@ -0,0 +1,75 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
+#define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
+
+#include <map>
+#include <string>
+
+#include "base/callback.h"
+
+namespace base {
+class ListValue;
+}
+
+namespace extensions {
+
+class ChromeV8Context;
+
+// A proxy that forwards pepper apps API calls through the Javascript API
+// bindings.
+class PepperRequestProxy {
+ public:
+ // A callback to be called with the result of an API call. If |success| is
+ // true, |response| will contain the response value. Otherwise, |error| will
+ // contain the error message.
+ typedef base::Callback<void(int request_id,
+ bool success,
+ const base::ListValue& response,
+ const std::string& error)> ResponseCallback;
+
+ explicit PepperRequestProxy(ChromeV8Context* context);
+ ~PepperRequestProxy();
+
+ // Starts an API request. Returns whether the call was successful. If the call
+ // was successful, |request_id| will contain the request ID that will be
+ // passed to |callback| when the response is received. Otherwise, |error| will
+ // contain the error message. |callback| will only be called on success. This
+ // will modify the contents of |args| but does not take ownership.
+ bool StartCall(const ResponseCallback& callback,
+ const std::string& request_name,
+ base::ListValue* args,
+ int* request_id,
+ std::string* error);
+
+ // Starts an API request that does not expect a response. Returns whether the
+ // call was successful. On failure, |error| will contain the error message.
+ // This will modify the contents of |args| but does not take ownership.
+ bool StartPost(const std::string& request_name,
not at google - send to devlin 2013/12/03 17:32:50 StartPost seems unnecessary, particularly if you r
Sam McNally 2013/12/04 00:01:36 Done.
+ base::ListValue* args,
+ std::string* error);
+
+ void OnResponseReceived(int request_id,
+ bool success,
+ const base::ListValue& args,
+ const std::string& error);
+
+ private:
+ typedef std::map<int, ResponseCallback> PendingRequestMap;
+
+ bool StartRequest(const std::string& request_name,
+ const std::string& method_name,
+ base::ListValue* args,
+ std::string* error);
+
+ // Non-owning pointer.
+ ChromeV8Context* context_;
+ PendingRequestMap pending_request_map_;
+ int next_request_id_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_

Powered by Google App Engine
This is Rietveld 408576698