Home | History | Annotate | Download | only in proxy
      1 // Copyright (c) 2011 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_INTERFACE_PROXY_H_
      6 #define PPAPI_PROXY_INTERFACE_PROXY_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "ipc/ipc_listener.h"
     10 #include "ipc/ipc_sender.h"
     11 #include "ppapi/c/pp_completion_callback.h"
     12 #include "ppapi/c/pp_resource.h"
     13 #include "ppapi/c/pp_var.h"
     14 #include "ppapi/shared_impl/api_id.h"
     15 
     16 namespace ppapi {
     17 namespace proxy {
     18 
     19 class Dispatcher;
     20 
     21 class InterfaceProxy : public IPC::Listener, public IPC::Sender {
     22  public:
     23   // Factory function type for interfaces. Ownership of the returned pointer
     24   // is transferred to the caller.
     25   typedef InterfaceProxy* (*Factory)(Dispatcher* dispatcher);
     26 
     27   // DEPRECATED: New classes should be registered directly in the interface
     28   // list. This is kept around until we convert all the existing code.
     29   //
     30   // Information about the interface. Each interface has a static function to
     31   // return its info, which allows either construction on the target side, and
     32   // getting the proxied interface on the source side (see dispatcher.h for
     33   // terminology).
     34   struct Info {
     35     const void* interface_ptr;
     36 
     37     const char* name;
     38     ApiID id;
     39 
     40     bool is_trusted;
     41 
     42     InterfaceProxy::Factory create_proxy;
     43   };
     44 
     45   virtual ~InterfaceProxy();
     46 
     47   Dispatcher* dispatcher() const { return dispatcher_; }
     48 
     49   // IPC::Sender implementation.
     50   virtual bool Send(IPC::Message* msg);
     51 
     52   // Sub-classes must implement IPC::Listener which contains this:
     53   //virtual bool OnMessageReceived(const IPC::Message& msg);
     54 
     55  protected:
     56   // Creates the given interface associated with the given dispatcher. The
     57   // dispatcher manages our lifetime.
     58   InterfaceProxy(Dispatcher* dispatcher);
     59 
     60  private:
     61   Dispatcher* dispatcher_;
     62 };
     63 
     64 }  // namespace proxy
     65 }  // namespace ppapi
     66 
     67 #endif  // PPAPI_PROXY_INTERFACE_PROXY_H_
     68 
     69