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

Unified Diff: ppapi/proxy/ppb_file_chooser_proxy.cc

Issue 7740038: Use macros to define pepper interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New patch Created 9 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/ppb_file_chooser_proxy.h ('k') | ppapi/proxy/ppb_file_ref_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppb_file_chooser_proxy.cc
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc
index f13ea8699fc65e20194a073ac0a7e371ecc4af7e..73f7a6a5b0ba77d2811363f3293e7130f1206b94 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);
« no previous file with comments | « ppapi/proxy/ppb_file_chooser_proxy.h ('k') | ppapi/proxy/ppb_file_ref_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698