| Index: webkit/plugins/ppapi/ppb_file_ref_impl.cc
|
| ===================================================================
|
| --- webkit/plugins/ppapi/ppb_file_ref_impl.cc (revision 0)
|
| +++ webkit/plugins/ppapi/ppb_file_ref_impl.cc (working copy)
|
| @@ -2,21 +2,22 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/glue/plugins/pepper_file_ref.h"
|
| +#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
|
|
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "ppapi/c/pp_errors.h"
|
| -#include "webkit/glue/plugins/pepper_common.h"
|
| -#include "webkit/glue/plugins/pepper_directory_reader.h"
|
| -#include "webkit/glue/plugins/pepper_file_callbacks.h"
|
| -#include "webkit/glue/plugins/pepper_file_system.h"
|
| -#include "webkit/glue/plugins/pepper_plugin_delegate.h"
|
| -#include "webkit/glue/plugins/pepper_plugin_instance.h"
|
| -#include "webkit/glue/plugins/pepper_plugin_module.h"
|
| -#include "webkit/glue/plugins/pepper_var.h"
|
| +#include "webkit/plugins/ppapi/common.h"
|
| +#include "webkit/plugins/ppapi/file_callbacks.h"
|
| +#include "webkit/plugins/ppapi/plugin_delegate.h"
|
| +#include "webkit/plugins/ppapi/plugin_instance.h"
|
| +#include "webkit/plugins/ppapi/plugin_module.h"
|
| +#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
|
| +#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
|
| +#include "webkit/plugins/ppapi/var.h"
|
|
|
| -namespace pepper {
|
| +namespace webkit {
|
| +namespace ppapi {
|
|
|
| namespace {
|
|
|
| @@ -40,8 +41,8 @@
|
| }
|
|
|
| PP_Resource Create(PP_Resource file_system_id, const char* path) {
|
| - scoped_refptr<FileSystem> file_system(
|
| - Resource::GetAs<FileSystem>(file_system_id));
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system(
|
| + Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
|
| if (!file_system)
|
| return 0;
|
|
|
| @@ -53,32 +54,35 @@
|
| return 0;
|
| TrimTrailingSlash(&validated_path);
|
|
|
| - FileRef* file_ref = new FileRef(file_system->instance()->module(),
|
| - file_system,
|
| - validated_path);
|
| + PPB_FileRef_Impl* file_ref =
|
| + new PPB_FileRef_Impl(file_system->instance()->module(),
|
| + file_system, validated_path);
|
| return file_ref->GetReference();
|
| }
|
|
|
| PP_Bool IsFileRef(PP_Resource resource) {
|
| - return BoolToPPBool(!!Resource::GetAs<FileRef>(resource));
|
| + return BoolToPPBool(!!Resource::GetAs<PPB_FileRef_Impl>(resource));
|
| }
|
|
|
| PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_FILESYSTEMTYPE_EXTERNAL;
|
| return file_ref->GetFileSystemType();
|
| }
|
|
|
| PP_Var GetName(PP_Resource file_ref_id) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_MakeUndefined();
|
| return StringVar::StringToPPVar(file_ref->module(), file_ref->GetName());
|
| }
|
|
|
| PP_Var GetPath(PP_Resource file_ref_id) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_MakeUndefined();
|
|
|
| @@ -89,14 +93,15 @@
|
| }
|
|
|
| PP_Resource GetParent(PP_Resource file_ref_id) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return 0;
|
|
|
| if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
|
| return 0;
|
|
|
| - scoped_refptr<FileRef> parent_ref(file_ref->GetParent());
|
| + scoped_refptr<PPB_FileRef_Impl> parent_ref(file_ref->GetParent());
|
| if (!parent_ref)
|
| return 0;
|
|
|
| @@ -106,12 +111,12 @@
|
| int32_t MakeDirectory(PP_Resource directory_ref_id,
|
| PP_Bool make_ancestors,
|
| PP_CompletionCallback callback) {
|
| - scoped_refptr<FileRef> directory_ref(
|
| - Resource::GetAs<FileRef>(directory_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> directory_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(directory_ref_id));
|
| if (!directory_ref)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| - scoped_refptr<FileSystem> file_system = directory_ref->GetFileSystem();
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system = directory_ref->GetFileSystem();
|
| if (!file_system || !file_system->opened() ||
|
| (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
|
| return PP_ERROR_NOACCESS;
|
| @@ -129,11 +134,12 @@
|
| int32_t Query(PP_Resource file_ref_id,
|
| PP_FileInfo_Dev* info,
|
| PP_CompletionCallback callback) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| - scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
|
| if (!file_system || !file_system->opened() ||
|
| (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
|
| return PP_ERROR_NOACCESS;
|
| @@ -152,11 +158,12 @@
|
| PP_Time last_access_time,
|
| PP_Time last_modified_time,
|
| PP_CompletionCallback callback) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| - scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
|
| if (!file_system || !file_system->opened() ||
|
| (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
|
| return PP_ERROR_NOACCESS;
|
| @@ -174,11 +181,12 @@
|
|
|
| int32_t Delete(PP_Resource file_ref_id,
|
| PP_CompletionCallback callback) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| - scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
|
| if (!file_system || !file_system->opened() ||
|
| (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
|
| return PP_ERROR_NOACCESS;
|
| @@ -196,16 +204,17 @@
|
| int32_t Rename(PP_Resource file_ref_id,
|
| PP_Resource new_file_ref_id,
|
| PP_CompletionCallback callback) {
|
| - scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
|
| if (!file_ref)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| - scoped_refptr<FileRef> new_file_ref(
|
| - Resource::GetAs<FileRef>(new_file_ref_id));
|
| + scoped_refptr<PPB_FileRef_Impl> new_file_ref(
|
| + Resource::GetAs<PPB_FileRef_Impl>(new_file_ref_id));
|
| if (!new_file_ref)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| - scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
|
| if (!file_system || !file_system->opened() ||
|
| (file_system != new_file_ref->GetFileSystem()) ||
|
| (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
|
| @@ -237,39 +246,39 @@
|
|
|
| } // namespace
|
|
|
| -FileRef::FileRef()
|
| +PPB_FileRef_Impl::PPB_FileRef_Impl()
|
| : Resource(NULL),
|
| file_system_(NULL) {
|
| }
|
|
|
| -FileRef::FileRef(PluginModule* module,
|
| - scoped_refptr<FileSystem> file_system,
|
| +PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
|
| + scoped_refptr<PPB_FileSystem_Impl> file_system,
|
| const std::string& validated_path)
|
| : Resource(module),
|
| file_system_(file_system),
|
| virtual_path_(validated_path) {
|
| }
|
|
|
| -FileRef::FileRef(PluginModule* module,
|
| +PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
|
| const FilePath& external_file_path)
|
| : Resource(module),
|
| file_system_(NULL),
|
| system_path_(external_file_path) {
|
| }
|
|
|
| -FileRef::~FileRef() {
|
| +PPB_FileRef_Impl::~PPB_FileRef_Impl() {
|
| }
|
|
|
| // static
|
| -const PPB_FileRef_Dev* FileRef::GetInterface() {
|
| +const PPB_FileRef_Dev* PPB_FileRef_Impl::GetInterface() {
|
| return &ppb_fileref;
|
| }
|
|
|
| -FileRef* FileRef::AsFileRef() {
|
| +PPB_FileRef_Impl* PPB_FileRef_Impl::AsPPB_FileRef_Impl() {
|
| return this;
|
| }
|
|
|
| -std::string FileRef::GetName() const {
|
| +std::string PPB_FileRef_Impl::GetName() const {
|
| if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) {
|
| FilePath::StringType path = system_path_.value();
|
| size_t pos = path.rfind(FilePath::kSeparators[0]);
|
| @@ -293,9 +302,9 @@
|
| return virtual_path_.substr(pos + 1);
|
| }
|
|
|
| -scoped_refptr<FileRef> FileRef::GetParent() {
|
| +scoped_refptr<PPB_FileRef_Impl> PPB_FileRef_Impl::GetParent() {
|
| if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
|
| - return new FileRef();
|
| + return new PPB_FileRef_Impl();
|
|
|
| // There should always be a leading slash at least!
|
| size_t pos = virtual_path_.rfind('/');
|
| @@ -306,26 +315,27 @@
|
| pos++;
|
| std::string parent_path = virtual_path_.substr(0, pos);
|
|
|
| - FileRef* parent_ref = new FileRef(module(), file_system_, parent_path);
|
| + PPB_FileRef_Impl* parent_ref = new PPB_FileRef_Impl(module(), file_system_,
|
| + parent_path);
|
| return parent_ref;
|
| }
|
|
|
| -scoped_refptr<FileSystem> FileRef::GetFileSystem() const {
|
| +scoped_refptr<PPB_FileSystem_Impl> PPB_FileRef_Impl::GetFileSystem() const {
|
| return file_system_;
|
| }
|
|
|
| -PP_FileSystemType_Dev FileRef::GetFileSystemType() const {
|
| +PP_FileSystemType_Dev PPB_FileRef_Impl::GetFileSystemType() const {
|
| if (!file_system_)
|
| return PP_FILESYSTEMTYPE_EXTERNAL;
|
|
|
| return file_system_->type();
|
| }
|
|
|
| -std::string FileRef::GetPath() const {
|
| +std::string PPB_FileRef_Impl::GetPath() const {
|
| return virtual_path_;
|
| }
|
|
|
| -FilePath FileRef::GetSystemPath() const {
|
| +FilePath PPB_FileRef_Impl::GetSystemPath() const {
|
| if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
|
| return system_path_;
|
|
|
| @@ -344,4 +354,6 @@
|
| return file_system_->root_path().Append(virtual_file_path);
|
| }
|
|
|
| -} // namespace pepper
|
| +} // namespace ppapi
|
| +} // namespace webkit
|
| +
|
|
|