• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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_PEPPER_CONTENT_BROWSER_PEPPER_HOST_FACTORY_H_
6 #define CONTENT_BROWSER_PEPPER_CONTENT_BROWSER_PEPPER_HOST_FACTORY_H_
7 
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/socket/tcp_socket.h"
12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/host/host_factory.h"
14 #include "ppapi/shared_impl/ppb_tcp_socket_shared.h"
15 
16 namespace ppapi {
17 class PpapiPermissions;
18 }
19 
20 namespace content {
21 
22 class BrowserPpapiHostImpl;
23 
24 class ContentBrowserPepperHostFactory : public ppapi::host::HostFactory {
25  public:
26   // Non-owning pointer to the filter must outlive this class.
27   explicit ContentBrowserPepperHostFactory(BrowserPpapiHostImpl* host);
28 
29   virtual ~ContentBrowserPepperHostFactory();
30 
31   virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
32       ppapi::host::PpapiHost* host,
33       const ppapi::proxy::ResourceMessageCallParams& params,
34       PP_Instance instance,
35       const IPC::Message& message) OVERRIDE;
36 
37   // Creates ResourceHost for already accepted TCP |socket|. In the case of
38   // failure returns wrapped NULL.
39   scoped_ptr<ppapi::host::ResourceHost> CreateAcceptedTCPSocket(
40       PP_Instance instance,
41       ppapi::TCPSocketVersion version,
42       scoped_ptr<net::TCPSocket> socket);
43 
44  private:
45   scoped_ptr<ppapi::host::ResourceHost> CreateNewTCPSocket(
46       PP_Instance instance,
47       PP_Resource resource,
48       ppapi::TCPSocketVersion version);
49 
50   const ppapi::PpapiPermissions& GetPermissions() const;
51 
52   // Non-owning pointer.
53   BrowserPpapiHostImpl* host_;
54 
55   DISALLOW_COPY_AND_ASSIGN(ContentBrowserPepperHostFactory);
56 };
57 
58 }  // namespace content
59 
60 #endif  // CONTENT_BROWSER_PEPPER_CONTENT_BROWSER_PEPPER_HOST_FACTORY_H_
61