Home | History | Annotate | Download | only in pepper
      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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_RENDERER_CONNECTION_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_RENDERER_CONNECTION_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/compiler_specific.h"
     10 #include "base/memory/scoped_ptr.h"
     11 #include "content/public/browser/browser_message_filter.h"
     12 #include "ppapi/c/pp_instance.h"
     13 #include "ppapi/c/pp_resource.h"
     14 
     15 class GURL;
     16 
     17 namespace ppapi {
     18 namespace proxy {
     19 class ResourceMessageCallParams;
     20 }
     21 }
     22 
     23 namespace content {
     24 
     25 class BrowserPpapiHostImpl;
     26 struct PepperRendererInstanceData;
     27 
     28 // This class represents a connection from the browser to the renderer for
     29 // sending/receiving pepper ResourceHost related messages. When the browser
     30 // and renderer communicate about ResourceHosts, they should pass the plugin
     31 // process ID to identify which plugin they are talking about.
     32 class PepperRendererConnection : public BrowserMessageFilter {
     33  public:
     34   explicit PepperRendererConnection(int render_process_id);
     35 
     36   // BrowserMessageFilter overrides.
     37   virtual bool OnMessageReceived(const IPC::Message& msg,
     38                                  bool* message_was_ok) OVERRIDE;
     39 
     40  private:
     41   virtual ~PepperRendererConnection();
     42 
     43   // Returns the host for the child process for the given |child_process_id|.
     44   // If |child_process_id| is 0, returns the host owned by this
     45   // PepperRendererConnection, which serves as the host for in-process plugins.
     46   BrowserPpapiHostImpl* GetHostForChildProcess(int child_process_id) const;
     47 
     48   void OnMsgCreateResourceHostFromHost(
     49       int routing_id,
     50       int child_process_id,
     51       const ppapi::proxy::ResourceMessageCallParams& params,
     52       PP_Instance instance,
     53       const IPC::Message& nested_msg);
     54 
     55   void OnMsgFileRefGetInfoForRenderer(
     56       int routing_id,
     57       int child_process_id,
     58       int32_t sequence_num,
     59       const std::vector<PP_Resource>& resources);
     60 
     61   void OnMsgDidCreateInProcessInstance(
     62       PP_Instance instance,
     63       const PepperRendererInstanceData& instance_data);
     64   void OnMsgDidDeleteInProcessInstance(PP_Instance instance);
     65 
     66   int render_process_id_;
     67 
     68   // We have a single BrowserPpapiHost per-renderer for all in-process plugins
     69   // running. This is just a work-around allowing new style resources to work
     70   // with the browser when running in-process but it means that plugin-specific
     71   // information (like the plugin name) won't be available.
     72   scoped_ptr<BrowserPpapiHostImpl> in_process_host_;
     73 
     74   DISALLOW_COPY_AND_ASSIGN(PepperRendererConnection);
     75 };
     76 
     77 }  // namespace content
     78 
     79 #endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_RENDERER_CONNECTION_H_
     80