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

Unified Diff: ppapi/cpp/file_system.cc

Issue 52233002: [PPAPI] Added VarResource_Dev class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: FileSystem constructor sets resource to null if not a file system on Release build. Created 7 years, 2 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/cpp/file_system.cc
diff --git a/ppapi/cpp/file_system.cc b/ppapi/cpp/file_system.cc
index f993fdaa892459a036ff94192b5fd5460373ba08..a2edef45cad210db73009700023e53b62903c8fd 100644
--- a/ppapi/cpp/file_system.cc
+++ b/ppapi/cpp/file_system.cc
@@ -9,6 +9,7 @@
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
@@ -28,6 +29,15 @@ FileSystem::FileSystem() {
FileSystem::FileSystem(const FileSystem& other) : Resource(other) {
}
+FileSystem::FileSystem(Resource resource) : Resource(resource) {
+ if (!ResourceIsFileSystem(resource)) {
+ PP_NOTREACHED();
+
+ // On release builds, set this to null.
+ Clear();
+ }
+}
+
FileSystem::FileSystem(PassRef, PP_Resource resource)
: Resource(PASS_REF, resource) {
}
@@ -48,4 +58,12 @@ int32_t FileSystem::Open(int64_t expected_size,
pp_resource(), expected_size, cc.pp_completion_callback());
}
+// static
+bool FileSystem::ResourceIsFileSystem(const Resource& resource) {
+ if (!has_interface<PPB_FileSystem_1_0>())
+ return false;
+ return get_interface<PPB_FileSystem_1_0>()->IsFileSystem(
+ resource.pp_resource());
+}
+
} // namespace pp
« ppapi/cpp/file_system.h ('K') | « ppapi/cpp/file_system.h ('k') | ppapi/cpp/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698