Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/renderer/pepper/pepper_extensions_common_host.h

Issue 61383003: Pass pepper apps API calls through the existing js apps API bindings. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ 5 #ifndef CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
6 #define CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ 6 #define CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "chrome/renderer/extensions/request_sender.h" 14 #include "chrome/renderer/extensions/pepper_request_proxy.h"
15 #include "ppapi/host/resource_host.h" 15 #include "ppapi/host/resource_host.h"
16 16
17 namespace base { 17 namespace base {
18 class ListValue; 18 class ListValue;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
22 class RendererPpapiHost; 22 class RendererPpapiHost;
23 } 23 }
24 24
25 namespace ppapi { 25 namespace ppapi {
26 namespace host { 26 namespace host {
27 struct ReplyMessageContext; 27 struct ReplyMessageContext;
28 } 28 }
29 } 29 }
30 30
31 namespace extensions { 31 namespace extensions {
32 class Dispatcher; 32 class Dispatcher;
33 } 33 }
34 34
35 class PepperExtensionsCommonHost : public ppapi::host::ResourceHost, 35 class PepperExtensionsCommonHost
36 public extensions::RequestSender::Source { 36 : public ppapi::host::ResourceHost,
37 public extensions::PepperRequestProxy::Source {
37 public: 38 public:
38 virtual ~PepperExtensionsCommonHost(); 39 virtual ~PepperExtensionsCommonHost();
39 40
40 static PepperExtensionsCommonHost* Create(content::RendererPpapiHost* host, 41 static PepperExtensionsCommonHost* Create(content::RendererPpapiHost* host,
41 PP_Instance instance, 42 PP_Instance instance,
42 PP_Resource resource); 43 PP_Resource resource);
43 44
44 // ppapi::host::ResourceMessageHandler overrides. 45 // ppapi::host::ResourceMessageHandler overrides.
45 virtual int32_t OnResourceMessageReceived( 46 virtual int32_t OnResourceMessageReceived(
46 const IPC::Message& msg, 47 const IPC::Message& msg,
47 ppapi::host::HostMessageContext* context) OVERRIDE; 48 ppapi::host::HostMessageContext* context) OVERRIDE;
48 49
49 // extensions::RequestSender::Source implementation. 50 // extensions::PepperRequestProxy::Source implementation.
50 virtual extensions::ChromeV8Context* GetContext() OVERRIDE; 51 virtual void OnResponseReceived(int request_id,
51 virtual void OnResponseReceived(const std::string& name,
52 int request_id,
53 bool success, 52 bool success,
54 const base::ListValue& response, 53 const base::ListValue& response,
55 const std::string& error) OVERRIDE; 54 const std::string& error) OVERRIDE;
55
56 private: 56 private:
57 typedef std::map<int, linked_ptr<ppapi::host::ReplyMessageContext> > 57 typedef std::map<int, linked_ptr<ppapi::host::ReplyMessageContext> >
58 PendingRequestMap; 58 PendingRequestMap;
59 59
60 PepperExtensionsCommonHost(content::RendererPpapiHost* host, 60 PepperExtensionsCommonHost(
61 PP_Instance instance, 61 content::RendererPpapiHost* host,
62 PP_Resource resource, 62 PP_Instance instance,
63 extensions::Dispatcher* dispatcher); 63 PP_Resource resource,
64 extensions::PepperRequestProxy* pepper_request_proxy);
64 65
65 int32_t OnPost(ppapi::host::HostMessageContext* context, 66 int32_t OnPost(ppapi::host::HostMessageContext* context,
66 const std::string& request_name, 67 const std::string& request_name,
67 base::ListValue& args); 68 base::ListValue& args);
68 69
69 int32_t OnCall(ppapi::host::HostMessageContext* context, 70 int32_t OnCall(ppapi::host::HostMessageContext* context,
70 const std::string& request_name, 71 const std::string& request_name,
71 base::ListValue& args); 72 base::ListValue& args);
72 73
73 // Non-owning pointer. 74 // Non-owning pointer.
74 content::RendererPpapiHost* renderer_ppapi_host_; 75 content::RendererPpapiHost* renderer_ppapi_host_;
75 // Non-owning pointer. 76 // Non-owning pointer.
76 extensions::Dispatcher* dispatcher_; 77 extensions::PepperRequestProxy* pepper_request_proxy_;
77 78
78 PendingRequestMap pending_request_map_; 79 PendingRequestMap pending_request_map_;
79 80
80 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost); 81 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost);
81 }; 82 };
82 83
83 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ 84 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698