blob: 3bde7cbe349a05d352f3049061a38693696964bf [file] [log] [blame]
[email protected]eccf80312012-07-14 15:43:421// 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 PPAPI_PROXY_PLUGIN_RESOURCE_H_
6#define PPAPI_PROXY_PLUGIN_RESOURCE_H_
7
8#include "base/compiler_specific.h"
9#include "ipc/ipc_sender.h"
[email protected]93df81e2012-08-10 22:22:4610#include "ppapi/proxy/connection.h"
[email protected]eccf80312012-07-14 15:43:4211#include "ppapi/proxy/ppapi_proxy_export.h"
12#include "ppapi/shared_impl/resource.h"
13
14namespace IPC {
15class Message;
16}
17
18namespace ppapi {
19namespace proxy {
20
21class PluginDispatcher;
22
[email protected]93df81e2012-08-10 22:22:4623class PPAPI_PROXY_EXPORT PluginResource : public Resource {
[email protected]eccf80312012-07-14 15:43:4224 public:
[email protected]93df81e2012-08-10 22:22:4625 PluginResource(Connection connection, PP_Instance instance);
[email protected]eccf80312012-07-14 15:43:4226 virtual ~PluginResource();
27
[email protected]93df81e2012-08-10 22:22:4628 // Returns true if we've previously sent a create message to the browser
29 // or renderer. Generally resources will use these to tell if they should
30 // lazily send create messages.
31 bool sent_create_to_browser() const { return sent_create_to_browser_; }
[email protected]eccf80312012-07-14 15:43:4232 bool sent_create_to_renderer() const { return sent_create_to_renderer_; }
33
34 protected:
[email protected]93df81e2012-08-10 22:22:4635 // Sends a create message to the browser or renderer for the current resource.
36 void SendCreateToBrowser(const IPC::Message& msg);
[email protected]eccf80312012-07-14 15:43:4237 void SendCreateToRenderer(const IPC::Message& msg);
38
39 // Sends the given IPC message as a resource request to the host
40 // corresponding to this resource object and does not expect a reply.
[email protected]93df81e2012-08-10 22:22:4641 void PostToBrowser(const IPC::Message& msg);
[email protected]eccf80312012-07-14 15:43:4242 void PostToRenderer(const IPC::Message& msg);
43
[email protected]93df81e2012-08-10 22:22:4644 // Like PostToBrowser/Renderer but expects a response.
[email protected]eccf80312012-07-14 15:43:4245 //
46 // Returns the new request's sequence number which can be used to identify
47 // the callback. The host will reply and ppapi::Resource::OnReplyReceived
48 // will be called.
49 //
50 // Note that all integers (including 0 and -1) are valid request IDs.
[email protected]93df81e2012-08-10 22:22:4651 int32_t CallBrowser(const IPC::Message& msg);
[email protected]eccf80312012-07-14 15:43:4252 int32_t CallRenderer(const IPC::Message& msg);
53
[email protected]ff44fc12012-10-03 00:52:1654 // Call the browser/renderer with sync messages. The pepper error code from
55 // the call is returned and the reply message is stored in |reply_msg|.
56 int32_t CallBrowserSync(const IPC::Message& msg, IPC::Message* reply_msg);
57 int32_t CallRendererSync(const IPC::Message& msg, IPC::Message* reply_msg);
58
[email protected]eccf80312012-07-14 15:43:4259 private:
[email protected]93df81e2012-08-10 22:22:4660 Connection connection_;
[email protected]eccf80312012-07-14 15:43:4261
62 int32_t next_sequence_number_;
63
[email protected]93df81e2012-08-10 22:22:4664 bool sent_create_to_browser_;
[email protected]eccf80312012-07-14 15:43:4265 bool sent_create_to_renderer_;
66
67 DISALLOW_COPY_AND_ASSIGN(PluginResource);
68};
69
70} // namespace proxy
71} // namespace ppapi
72
73#endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_