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

Unified Diff: ppapi/thunk/ppb_flash_file_fileref_thunk.cc

Issue 10169040: Move the rest of the Flash functions to the thunk system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
Index: ppapi/thunk/ppb_flash_file_fileref_thunk.cc
diff --git a/ppapi/thunk/ppb_flash_file_fileref_thunk.cc b/ppapi/thunk/ppb_flash_file_fileref_thunk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..08cf72cf0d91d5a0ab266b022351e07a2293459b
--- /dev/null
+++ b/ppapi/thunk/ppb_flash_file_fileref_thunk.cc
@@ -0,0 +1,60 @@
+// 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.
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_flash_file.h"
+#include "ppapi/thunk/thunk.h"
yzshen1 2012/04/25 20:50:47 sort this section, please.
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_flash_api.h"
+#include "ppapi/thunk/ppb_file_ref_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+// Returns 0 on failure.
+PP_Instance GetInstanceFromFileRef(PP_Resource file_ref) {
+ thunk::EnterResource<thunk::PPB_FileRef_API> enter(file_ref, true);
+ if (enter.failed())
+ return 0;
+ return enter.resource()->pp_instance();
+}
+
+int32_t OpenFile(PP_Resource file_ref_id, int32_t mode, PP_FileHandle* file) {
+ // TODO(brettw): this function should take an instance.
+ // To work around this, use the PP_Instance from the resource.
+ PP_Instance instance = GetInstanceFromFileRef(file_ref_id);
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_ERROR_BADARGUMENT;
+ return enter.functions()->GetFlashAPI()->OpenFileRef(instance, file_ref_id,
+ mode, file);
+}
+
+int32_t QueryFile(PP_Resource file_ref_id, struct PP_FileInfo* info) {
+ // TODO(brettw): this function should take an instance.
+ // To work around this, use the PP_Instance from the resource.
+ PP_Instance instance = GetInstanceFromFileRef(file_ref_id);
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_ERROR_BADARGUMENT;
+ return enter.functions()->GetFlashAPI()->QueryFileRef(instance, file_ref_id,
+ info);
+}
+
+const PPB_Flash_File_FileRef g_ppb_flash_file_fileref_thunk = {
+ &OpenFile,
+ &QueryFile
+};
+
+} // namespace
+
+const PPB_Flash_File_FileRef* GetPPB_Flash_File_FileRef_Thunk() {
+ return &g_ppb_flash_file_fileref_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698