Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / renderer / extensions / pepper_request_proxy.h
blob8c05c85dd8b690da7f0f651bccc41011ebca5e5c
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.
5 #ifndef CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
6 #define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_
8 #include <map>
9 #include <string>
11 #include "base/callback.h"
13 namespace base {
14 class ListValue;
17 namespace v8 {
18 class Isolate;
21 namespace extensions {
23 class ChromeV8Context;
25 // A proxy that forwards pepper apps API calls through the Javascript API
26 // bindings.
27 class PepperRequestProxy {
28 public:
29 // A callback to be called with the result of an API call. If |success| is
30 // true, |response| will contain the response value. Otherwise, |error| will
31 // contain the error message.
32 typedef base::Callback<void(bool success,
33 const base::ListValue& response,
34 const std::string& error)> ResponseCallback;
36 explicit PepperRequestProxy(ChromeV8Context* context);
37 ~PepperRequestProxy();
39 // Starts an API request. Returns whether the call was successful. On failure,
40 // |error| will contain the error message. |callback| will only be called on
41 // success.
42 bool StartRequest(const ResponseCallback& callback,
43 const std::string& request_name,
44 const base::ListValue& args,
45 std::string* error);
47 void OnResponseReceived(int request_id,
48 bool success,
49 const base::ListValue& args,
50 const std::string& error);
52 private:
53 typedef std::map<int, ResponseCallback> PendingRequestMap;
55 // Non-owning pointer.
56 ChromeV8Context* context_;
57 // Non-owning pointer.
58 v8::Isolate* isolate_;
59 PendingRequestMap pending_request_map_;
60 int next_request_id_;
63 } // namespace extensions
65 #endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_