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

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 PepperExtensionsCommonHost(
58 PendingRequestMap; 52 content::RendererPpapiHost* host,
59 53 PP_Instance instance,
60 PepperExtensionsCommonHost(content::RendererPpapiHost* host, 54 PP_Resource resource,
61 PP_Instance instance, 55 extensions::PepperRequestProxy* pepper_request_proxy);
62 PP_Resource resource,
63 extensions::Dispatcher* dispatcher);
64 56
65 int32_t OnPost(ppapi::host::HostMessageContext* context, 57 int32_t OnPost(ppapi::host::HostMessageContext* context,
66 const std::string& request_name, 58 const std::string& request_name,
67 base::ListValue& args); 59 const base::ListValue& args);
68 60
69 int32_t OnCall(ppapi::host::HostMessageContext* context, 61 int32_t OnCall(ppapi::host::HostMessageContext* context,
70 const std::string& request_name, 62 const std::string& request_name,
71 base::ListValue& args); 63 const base::ListValue& args);
64
65 void OnResponseReceived(
66 scoped_ptr<ppapi::host::ReplyMessageContext> response_context,
67 bool success,
68 const base::ListValue& response,
69 const std::string& error);
72 70
73 // Non-owning pointer. 71 // Non-owning pointer.
74 content::RendererPpapiHost* renderer_ppapi_host_; 72 content::RendererPpapiHost* renderer_ppapi_host_;
75 // Non-owning pointer. 73 // Non-owning pointer.
76 extensions::Dispatcher* dispatcher_; 74 extensions::PepperRequestProxy* pepper_request_proxy_;
77 75
78 PendingRequestMap pending_request_map_; 76 base::WeakPtrFactory<PepperExtensionsCommonHost> weak_factory_;
79 77
80 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost); 78 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost);
81 }; 79 };
82 80
83 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ 81 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/pepper_request_proxy.cc ('k') | chrome/renderer/pepper/pepper_extensions_common_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698