summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppb_file_chooser_proxy.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 20:07:29 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 20:07:29 +0000
commit62cccdac4221f25d83c84da8da70e7c540d4af35 (patch)
tree227fb39351ee5df0d6ac143f31527270b0c493d2 /ppapi/proxy/ppb_file_chooser_proxy.cc
parentcc89cd9a46629ca8230aae41f8ad2855c8b30264 (diff)
downloadchromium_src-62cccdac4221f25d83c84da8da70e7c540d4af35.zip
chromium_src-62cccdac4221f25d83c84da8da70e7c540d4af35.tar.gz
chromium_src-62cccdac4221f25d83c84da8da70e7c540d4af35.tar.bz2
This patch tries to remove most of the manual registration for Pepper interfaces, and replaces it with a list of macros. When files want to know which Pepper interface names and structs there are, they define what they want to do with the macros, and then include the relevant files for the classes of interfaces they want (stable, private, dev).
This does not convert all the dev interfaces. I just did a few to keep the patch smaller. So there is still a lot of manual registration. This fixes the previous design problem where we assumed one *_Proxy object == one interface. We have been hacking around this lately with duplicate GetInfo calls, but this doesn't work for PPP interfaces. Now, a _Proxy object is just there to help keep things organized. One proxy can handle zero, one, or many interfaces, and this mapping is controlled by just one line in the interfaces file. So for example, to add a new function to a new version of an interface with backward compatibility, you would add that function to the _api.h file, and write a thunk for the new interface. Then you only need to add one line to the interfaces_ppb_public_stable.h file and that will be hooked up with the proxy and the implementation. This removes some _proxy objects/files that were used only to declare that the interfaces existed, since they're no longer necessary. I folded Console into the Instance API which removed a bunch of code. I removed FileChooser 0.4. I think everybody has converted to the new one, and I think parts of it weren't even hooked up properly anymore. Review URL: http://codereview.chromium.org/7740038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_file_chooser_proxy.cc')
-rw-r--r--ppapi/proxy/ppb_file_chooser_proxy.cc90
1 files changed, 14 insertions, 76 deletions
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc
index f13ea86..73f7a6a 100644
--- a/ppapi/proxy/ppb_file_chooser_proxy.cc
+++ b/ppapi/proxy/ppb_file_chooser_proxy.cc
@@ -16,6 +16,7 @@
#include "ppapi/proxy/ppb_file_ref_proxy.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/var.h"
+#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
using ppapi::thunk::PPB_FileChooser_API;
@@ -118,77 +119,14 @@ void FileChooser::ChooseComplete(
// DANGER: May delete |this|!
}
-namespace {
-
-PP_Resource Create0_4(PP_Instance instance,
- const PP_FileChooserOptions_0_4_Dev* options) {
- PP_Var accept_var = PP_MakeUndefined();
- if (options->accept_mime_types)
- accept_var = StringVar::StringToPPVar(0, options->accept_mime_types);
- PP_Resource result = thunk::GetPPB_FileChooser_Thunk()->Create(
- instance, options->mode, accept_var);
- if (accept_var.type == PP_VARTYPE_STRING)
- PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(accept_var);
- return result;
-}
-
-PP_Bool IsFileChooser0_4(PP_Resource resource) {
- return thunk::GetPPB_FileChooser_Thunk()->IsFileChooser(resource);
-}
-
-int32_t Show0_4(PP_Resource chooser, PP_CompletionCallback callback) {
- return thunk::GetPPB_FileChooser_Thunk()->Show(chooser, callback);
-}
-
-PP_Resource GetNextChosenFile0_4(PP_Resource chooser) {
- return thunk::GetPPB_FileChooser_Thunk()->GetNextChosenFile(chooser);
-}
-
-PPB_FileChooser_0_4_Dev file_chooser_0_4_interface = {
- &Create0_4,
- &IsFileChooser0_4,
- &Show0_4,
- &GetNextChosenFile0_4
-};
-
-InterfaceProxy* CreateFileChooserProxy(Dispatcher* dispatcher,
- const void* target_interface) {
- return new PPB_FileChooser_Proxy(dispatcher, target_interface);
-}
-
-} // namespace
-
-PPB_FileChooser_Proxy::PPB_FileChooser_Proxy(Dispatcher* dispatcher,
- const void* target_interface)
- : InterfaceProxy(dispatcher, target_interface),
+PPB_FileChooser_Proxy::PPB_FileChooser_Proxy(Dispatcher* dispatcher)
+ : InterfaceProxy(dispatcher),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
PPB_FileChooser_Proxy::~PPB_FileChooser_Proxy() {
}
-const InterfaceProxy::Info* PPB_FileChooser_Proxy::GetInfo() {
- static const Info info = {
- thunk::GetPPB_FileChooser_Thunk(),
- PPB_FILECHOOSER_DEV_INTERFACE,
- INTERFACE_ID_PPB_FILE_CHOOSER,
- false,
- &CreateFileChooserProxy,
- };
- return &info;
-}
-
-const InterfaceProxy::Info* PPB_FileChooser_Proxy::GetInfo0_4() {
- static const Info info = {
- &file_chooser_0_4_interface,
- PPB_FILECHOOSER_DEV_INTERFACE_0_4,
- INTERFACE_ID_NONE,
- false,
- &CreateFileChooserProxy,
- };
- return &info;
-}
-
// static
PP_Resource PPB_FileChooser_Proxy::CreateProxyResource(
PP_Instance instance,
@@ -229,9 +167,12 @@ void PPB_FileChooser_Proxy::OnMsgCreate(
int mode,
SerializedVarReceiveInput accept_mime_types,
HostResource* result) {
- result->SetHostResource(instance, ppb_file_chooser_target()->Create(
- instance, static_cast<PP_FileChooserMode_Dev>(mode),
- accept_mime_types.Get(dispatcher())));
+ thunk::EnterResourceCreation enter(instance);
+ if (enter.succeeded()) {
+ result->SetHostResource(instance, enter.functions()->CreateFileChooser(
+ instance, static_cast<PP_FileChooserMode_Dev>(mode),
+ accept_mime_types.Get(dispatcher())));
+ }
}
void PPB_FileChooser_Proxy::OnMsgShow(const HostResource& chooser) {
@@ -255,19 +196,16 @@ void PPB_FileChooser_Proxy::OnMsgChooseComplete(
void PPB_FileChooser_Proxy::OnShowCallback(int32_t result,
const HostResource& chooser) {
+ EnterHostFromHostResource<PPB_FileChooser_API> enter(chooser);
+
std::vector<PPB_FileRef_CreateInfo> files;
- if (result == PP_OK) {
- // Jump through some hoops to get the FileRef proxy. Since we know we're
- // in the host at this point, we can ask the host dispatcher for it.
- DCHECK(!dispatcher()->IsPlugin());
- HostDispatcher* host_disp = static_cast<HostDispatcher*>(dispatcher());
+ if (enter.succeeded() && result == PP_OK) {
PPB_FileRef_Proxy* file_ref_proxy = static_cast<PPB_FileRef_Proxy*>(
- host_disp->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_FILE_REF));
+ dispatcher()->GetInterfaceProxy(INTERFACE_ID_PPB_FILE_REF));
// Convert the returned files to the serialized info.
while (PP_Resource cur_file_resource =
- ppb_file_chooser_target()->GetNextChosenFile(
- chooser.host_resource())) {
+ enter.object()->GetNextChosenFile()) {
PPB_FileRef_CreateInfo cur_create_info;
file_ref_proxy->SerializeFileRef(cur_file_resource, &cur_create_info);
files.push_back(cur_create_info);