diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-14 15:43:42 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-14 15:43:42 +0000 |
commit | eccf8031b30e3f8cf85b1e0dc82e69966afa30d5 (patch) | |
tree | 6c10625135c1fd95eb316fdbf496c5a5ee220c6e /ppapi/proxy/plugin_resource.h | |
parent | 1c7fa0a26fed6f48fbb2a7fe5724c5f9143610ff (diff) | |
download | chromium_src-eccf8031b30e3f8cf85b1e0dc82e69966afa30d5.zip chromium_src-eccf8031b30e3f8cf85b1e0dc82e69966afa30d5.tar.gz chromium_src-eccf8031b30e3f8cf85b1e0dc82e69966afa30d5.tar.bz2 |
This implements the PPB_FileChooser resource as a new-style IPC-only resource.
Note that the new file name is file_chooser_resource in the proxy. I decided to drop the ppb_ prefix for the "new-style" files to help differentiate them, and also because it's technically wrong. PPB is an interface, and a resource "object" may support multiple interfaces. I think FooResource is easier to type and read.
Review URL: https://chromiumcodereview.appspot.com/10544089
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/plugin_resource.h')
-rw-r--r-- | ppapi/proxy/plugin_resource.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ppapi/proxy/plugin_resource.h b/ppapi/proxy/plugin_resource.h new file mode 100644 index 0000000..28d1274 --- /dev/null +++ b/ppapi/proxy/plugin_resource.h @@ -0,0 +1,64 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_PLUGIN_RESOURCE_H_ +#define PPAPI_PROXY_PLUGIN_RESOURCE_H_ + +#include "base/compiler_specific.h" +#include "ipc/ipc_sender.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/resource.h" + +namespace IPC { +class Message; +} + +namespace ppapi { +namespace proxy { + +class PluginDispatcher; + +class PPAPI_PROXY_EXPORT PluginResource : public Resource, + public IPC::Sender { + public: + PluginResource(IPC::Sender* sender, + PP_Instance instance); + virtual ~PluginResource(); + + // IPC::Sender implementation. + virtual bool Send(IPC::Message* message) OVERRIDE; + + bool sent_create_to_renderer() const { return sent_create_to_renderer_; } + + protected: + // Sends a create message to the renderer for the current resource. + void SendCreateToRenderer(const IPC::Message& msg); + + // Sends the given IPC message as a resource request to the host + // corresponding to this resource object and does not expect a reply. + void PostToRenderer(const IPC::Message& msg); + + // Like PostToRenderer but expects a response. + // + // Returns the new request's sequence number which can be used to identify + // the callback. The host will reply and ppapi::Resource::OnReplyReceived + // will be called. + // + // Note that all integers (including 0 and -1) are valid request IDs. + int32_t CallRenderer(const IPC::Message& msg); + + private: + IPC::Sender* sender_; + + int32_t next_sequence_number_; + + bool sent_create_to_renderer_; + + DISALLOW_COPY_AND_ASSIGN(PluginResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ |