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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
6 #define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/callback.h"
12
13 namespace base {
14 class ListValue;
15 }
16
17 namespace extensions {
18
19 class ChromeV8Context;
20
21 // A proxy that forwards pepper apps API calls through the Javascript API
22 // bindings.
23 class PepperRequestProxy {
24 public:
25 // A callback to be called with the result of an API call. If |success| is
26 // true, |response| will contain the response value. Otherwise, |error| will
27 // contain the error message.
28 typedef base::Callback<void(int request_id,
29 bool success,
30 const base::ListValue& response,
31 const std::string& error)> ResponseCallback;
32
33 explicit PepperRequestProxy(ChromeV8Context* context);
34 ~PepperRequestProxy();
35
36 // Starts an API request. Returns whether the call was successful. If the call
37 // was successful, |request_id| will contain the request ID that will be
38 // passed to |callback| when the response is received. Otherwise, |error| will
39 // contain the error message. |callback| will only be called on success. This
40 // will modify the contents of |args| but does not take ownership.
41 bool StartCall(const ResponseCallback& callback,
42 const std::string& request_name,
43 base::ListValue* args,
44 int* request_id,
45 std::string* error);
46
47 // Starts an API request that does not expect a response. Returns whether the
48 // call was successful. On failure, |error| will contain the error message.
49 // This will modify the contents of |args| but does not take ownership.
50 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.
51 base::ListValue* args,
52 std::string* error);
53
54 void OnResponseReceived(int request_id,
55 bool success,
56 const base::ListValue& args,
57 const std::string& error);
58
59 private:
60 typedef std::map<int, ResponseCallback> PendingRequestMap;
61
62 bool StartRequest(const std::string& request_name,
63 const std::string& method_name,
64 base::ListValue* args,
65 std::string* error);
66
67 // Non-owning pointer.
68 ChromeV8Context* context_;
69 PendingRequestMap pending_request_map_;
70 int next_request_id_;
71 };
72
73 } // namespace extensions
74
75 #endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698