OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
6 #define PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 6 #define PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
| 10 #include "ppapi/proxy/connection.h" |
10 #include "ppapi/proxy/ppapi_proxy_export.h" | 11 #include "ppapi/proxy/ppapi_proxy_export.h" |
11 #include "ppapi/shared_impl/resource.h" | 12 #include "ppapi/shared_impl/resource.h" |
12 | 13 |
13 namespace IPC { | 14 namespace IPC { |
14 class Message; | 15 class Message; |
15 } | 16 } |
16 | 17 |
17 namespace ppapi { | 18 namespace ppapi { |
18 namespace proxy { | 19 namespace proxy { |
19 | 20 |
20 class PluginDispatcher; | 21 class PluginDispatcher; |
21 | 22 |
22 class PPAPI_PROXY_EXPORT PluginResource : public Resource, | 23 class PPAPI_PROXY_EXPORT PluginResource : public Resource { |
23 public IPC::Sender { | |
24 public: | 24 public: |
25 PluginResource(IPC::Sender* sender, | 25 PluginResource(Connection connection, PP_Instance instance); |
26 PP_Instance instance); | |
27 virtual ~PluginResource(); | 26 virtual ~PluginResource(); |
28 | 27 |
29 // IPC::Sender implementation. | 28 // Returns true if we've previously sent a create message to the browser |
30 virtual bool Send(IPC::Message* message) OVERRIDE; | 29 // or renderer. Generally resources will use these to tell if they should |
31 | 30 // lazily send create messages. |
| 31 bool sent_create_to_browser() const { return sent_create_to_browser_; } |
32 bool sent_create_to_renderer() const { return sent_create_to_renderer_; } | 32 bool sent_create_to_renderer() const { return sent_create_to_renderer_; } |
33 | 33 |
34 protected: | 34 protected: |
35 // Sends a create message to the renderer for the current resource. | 35 // Sends a create message to the browser or renderer for the current resource. |
| 36 void SendCreateToBrowser(const IPC::Message& msg); |
36 void SendCreateToRenderer(const IPC::Message& msg); | 37 void SendCreateToRenderer(const IPC::Message& msg); |
37 | 38 |
38 // Sends the given IPC message as a resource request to the host | 39 // Sends the given IPC message as a resource request to the host |
39 // corresponding to this resource object and does not expect a reply. | 40 // corresponding to this resource object and does not expect a reply. |
| 41 void PostToBrowser(const IPC::Message& msg); |
40 void PostToRenderer(const IPC::Message& msg); | 42 void PostToRenderer(const IPC::Message& msg); |
41 | 43 |
42 // Like PostToRenderer but expects a response. | 44 // Like PostToBrowser/Renderer but expects a response. |
43 // | 45 // |
44 // Returns the new request's sequence number which can be used to identify | 46 // Returns the new request's sequence number which can be used to identify |
45 // the callback. The host will reply and ppapi::Resource::OnReplyReceived | 47 // the callback. The host will reply and ppapi::Resource::OnReplyReceived |
46 // will be called. | 48 // will be called. |
47 // | 49 // |
48 // Note that all integers (including 0 and -1) are valid request IDs. | 50 // Note that all integers (including 0 and -1) are valid request IDs. |
| 51 int32_t CallBrowser(const IPC::Message& msg); |
49 int32_t CallRenderer(const IPC::Message& msg); | 52 int32_t CallRenderer(const IPC::Message& msg); |
50 | 53 |
51 private: | 54 private: |
52 IPC::Sender* sender_; | 55 Connection connection_; |
53 | 56 |
54 int32_t next_sequence_number_; | 57 int32_t next_sequence_number_; |
55 | 58 |
| 59 bool sent_create_to_browser_; |
56 bool sent_create_to_renderer_; | 60 bool sent_create_to_renderer_; |
57 | 61 |
58 DISALLOW_COPY_AND_ASSIGN(PluginResource); | 62 DISALLOW_COPY_AND_ASSIGN(PluginResource); |
59 }; | 63 }; |
60 | 64 |
61 } // namespace proxy | 65 } // namespace proxy |
62 } // namespace ppapi | 66 } // namespace ppapi |
63 | 67 |
64 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 68 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
OLD | NEW |