Home | History | Annotate | Download | only in proxy
      1 // Copyright (c) 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 PPAPI_PROXY_EXTENSIONS_COMMON_RESOURCE_H_
      6 #define PPAPI_PROXY_EXTENSIONS_COMMON_RESOURCE_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/compiler_specific.h"
     10 #include "ppapi/proxy/connection.h"
     11 #include "ppapi/proxy/plugin_resource.h"
     12 #include "ppapi/thunk/extensions_common_api.h"
     13 
     14 namespace base {
     15 class ListValue;
     16 }
     17 
     18 namespace ppapi {
     19 namespace proxy {
     20 
     21 class ResourceMessageReplyParams;
     22 
     23 class ExtensionsCommonResource : public PluginResource,
     24                                  public thunk::ExtensionsCommon_API {
     25  public:
     26   ExtensionsCommonResource(Connection connection, PP_Instance instance);
     27   virtual ~ExtensionsCommonResource();
     28 
     29   // Resource overrides.
     30   virtual thunk::ExtensionsCommon_API* AsExtensionsCommon_API() OVERRIDE;
     31 
     32   // ExtensionsCommon_API implementation.
     33   virtual int32_t CallRenderer(
     34       const std::string& request_name,
     35       const std::vector<PP_Var>& input_args,
     36       const std::vector<PP_Var*>& output_args,
     37       scoped_refptr<TrackedCallback> callback) OVERRIDE;
     38   virtual void PostRenderer(const std::string& request_name,
     39                             const std::vector<PP_Var>& args) OVERRIDE;
     40   virtual int32_t CallBrowser(const std::string& request_name,
     41                               const std::vector<PP_Var>& input_args,
     42                               const std::vector<PP_Var*>& output_args,
     43                               scoped_refptr<TrackedCallback> callback) OVERRIDE;
     44   virtual void PostBrowser(const std::string& request_name,
     45                            const std::vector<PP_Var>& args) OVERRIDE;
     46 
     47  private:
     48   int32_t CommonCall(Destination dest,
     49                      const std::string& request_name,
     50                      const std::vector<PP_Var>& input_args,
     51                      const std::vector<PP_Var*>& output_args,
     52                      scoped_refptr<TrackedCallback> callback);
     53   void CommonPost(Destination dest,
     54                   const std::string& request_name,
     55                   const std::vector<PP_Var>& args);
     56 
     57   void OnPluginMsgCallReply(const std::vector<PP_Var*>& output_args,
     58                             scoped_refptr<TrackedCallback> callback,
     59                             const ResourceMessageReplyParams& params,
     60                             const base::ListValue& output);
     61 
     62   DISALLOW_COPY_AND_ASSIGN(ExtensionsCommonResource);
     63 };
     64 
     65 }  // namespace proxy
     66 }  // namespace ppapi
     67 
     68 #endif  // PPAPI_PROXY_EXTENSIONS_COMMON_RESOURCE_H_
     69