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

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/bind.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
14 #include "chrome/renderer/extensions/request_sender.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/renderer/extensions/pepper_request_proxy.h"
15 #include "ppapi/host/resource_host.h" 17 #include "ppapi/host/resource_host.h"
16 18
17 namespace base { 19 namespace base {
18 class ListValue; 20 class ListValue;
19 } 21 }
20 22
21 namespace content { 23 namespace content {
22 class RendererPpapiHost; 24 class RendererPpapiHost;
23 } 25 }
24 26
25 namespace ppapi { 27 namespace ppapi {
26 namespace host { 28 namespace host {
27 struct ReplyMessageContext; 29 struct ReplyMessageContext;
28 } 30 }
29 } 31 }
30 32
31 namespace extensions { 33 namespace extensions {
32 class Dispatcher; 34 class Dispatcher;
33 } 35 }
34 36
35 class PepperExtensionsCommonHost : public ppapi::host::ResourceHost, 37 class PepperExtensionsCommonHost : public ppapi::host::ResourceHost {
36 public extensions::RequestSender::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 virtual extensions::ChromeV8Context* GetContext() OVERRIDE;
51 virtual void OnResponseReceived(const std::string& name,
52 int request_id,
53 bool success,
54 const base::ListValue& response,
55 const std::string& error) OVERRIDE;
56 private: 50 private:
57 typedef std::map<int, linked_ptr<ppapi::host::ReplyMessageContext> > 51 typedef std::map<int, linked_ptr<ppapi::host::ReplyMessageContext> >
58 PendingRequestMap; 52 PendingRequestMap;
59 53
60 PepperExtensionsCommonHost(content::RendererPpapiHost* host, 54 PepperExtensionsCommonHost(
61 PP_Instance instance, 55 content::RendererPpapiHost* host,
62 PP_Resource resource, 56 PP_Instance instance,
63 extensions::Dispatcher* dispatcher); 57 PP_Resource resource,
58 extensions::PepperRequestProxy* pepper_request_proxy);
64 59
65 int32_t OnPost(ppapi::host::HostMessageContext* context, 60 int32_t OnPost(ppapi::host::HostMessageContext* context,
66 const std::string& request_name, 61 const std::string& request_name,
67 base::ListValue& args); 62 base::ListValue& args);
68 63
69 int32_t OnCall(ppapi::host::HostMessageContext* context, 64 int32_t OnCall(ppapi::host::HostMessageContext* context,
70 const std::string& request_name, 65 const std::string& request_name,
71 base::ListValue& args); 66 base::ListValue& args);
72 67
68 void OnResponseReceived(int request_id,
69 bool success,
70 const base::ListValue& response,
71 const std::string& error);
72
73 // Non-owning pointer. 73 // Non-owning pointer.
74 content::RendererPpapiHost* renderer_ppapi_host_; 74 content::RendererPpapiHost* renderer_ppapi_host_;
75 // Non-owning pointer. 75 // Non-owning pointer.
76 extensions::Dispatcher* dispatcher_; 76 extensions::PepperRequestProxy* pepper_request_proxy_;
77 77
78 PendingRequestMap pending_request_map_; 78 PendingRequestMap pending_request_map_;
79 79
80 extensions::PepperRequestProxy::ResponseCallback callback_;
81
82 base::WeakPtrFactory<PepperExtensionsCommonHost> weak_factory_;
83
80 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost); 84 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost);
81 }; 85 };
82 86
83 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ 87 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698