| 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,
 | 
| +                 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_
 | 
| 
 |