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

Unified Diff: webkit/plugins/ppapi/ppb_file_io_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | « webkit/plugins/ppapi/ppb_file_io_impl.h ('k') | webkit/plugins/ppapi/ppb_file_ref_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_file_io_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_file_io_impl.cc (revision 0)
+++ webkit/plugins/ppapi/ppb_file_io_impl.cc (working copy)
@@ -2,7 +2,7 @@
// 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_io.h"
+#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
#include "base/callback.h"
#include "base/file_util.h"
@@ -15,13 +15,14 @@
#include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_file_ref.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
-#include "webkit/glue/plugins/pepper_plugin_module.h"
-#include "webkit/glue/plugins/pepper_resource_tracker.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/plugin_instance.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -30,23 +31,24 @@
if (!module)
return 0;
- FileIO* file_io = new FileIO(module);
+ PPB_FileIO_Impl* file_io = new PPB_FileIO_Impl(module);
return file_io->GetReference();
}
PP_Bool IsFileIO(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<FileIO>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_FileIO_Impl>(resource));
}
int32_t Open(PP_Resource file_io_id,
PP_Resource file_ref_id,
int32_t open_flags,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
- 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;
@@ -56,7 +58,7 @@
int32_t Query(PP_Resource file_io_id,
PP_FileInfo_Dev* info,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Query(info, callback);
@@ -66,7 +68,7 @@
PP_Time last_access_time,
PP_Time last_modified_time,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Touch(last_access_time, last_modified_time, callback);
@@ -77,7 +79,7 @@
char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Read(offset, buffer, bytes_to_read, callback);
@@ -88,7 +90,7 @@
const char* buffer,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Write(offset, buffer, bytes_to_write, callback);
@@ -97,7 +99,7 @@
int32_t SetLength(PP_Resource file_io_id,
int64_t length,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->SetLength(length, callback);
@@ -105,14 +107,14 @@
int32_t Flush(PP_Resource file_io_id,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Flush(callback);
}
void Close(PP_Resource file_io_id) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return;
file_io->Close();
@@ -132,7 +134,7 @@
};
int32_t GetOSFileDescriptor(PP_Resource file_io_id) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->GetOSFileDescriptor();
@@ -142,7 +144,7 @@
int64_t offset,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->WillWrite(offset, bytes_to_write, callback);
@@ -151,7 +153,7 @@
int32_t WillSetLength(PP_Resource file_io_id,
int64_t length,
PP_CompletionCallback callback) {
- scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
+ scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->WillSetLength(length, callback);
@@ -187,7 +189,7 @@
} // namespace
-FileIO::FileIO(PluginModule* module)
+PPB_FileIO_Impl::PPB_FileIO_Impl(PluginModule* module)
: Resource(module),
delegate_(module->GetSomeInstance()->delegate()),
ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
@@ -196,27 +198,27 @@
info_(NULL) {
}
-FileIO::~FileIO() {
+PPB_FileIO_Impl::~PPB_FileIO_Impl() {
Close();
}
// static
-const PPB_FileIO_Dev* FileIO::GetInterface() {
+const PPB_FileIO_Dev* PPB_FileIO_Impl::GetInterface() {
return &ppb_fileio;
}
// static
-const PPB_FileIOTrusted_Dev* FileIO::GetTrustedInterface() {
+const PPB_FileIOTrusted_Dev* PPB_FileIO_Impl::GetTrustedInterface() {
return &ppb_fileiotrusted;
}
-FileIO* FileIO::AsFileIO() {
+PPB_FileIO_Impl* PPB_FileIO_Impl::AsPPB_FileIO_Impl() {
return this;
}
-int32_t FileIO::Open(FileRef* file_ref,
- int32_t open_flags,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::Open(PPB_FileRef_Impl* file_ref,
+ int32_t open_flags,
+ PP_CompletionCallback callback) {
if (file_ != base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@@ -245,14 +247,14 @@
file_system_type_ = file_ref->GetFileSystemType();
if (!delegate_->AsyncOpenFile(
file_ref->GetSystemPath(), flags,
- callback_factory_.NewCallback(&FileIO::AsyncOpenFileCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::AsyncOpenFileCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-int32_t FileIO::Query(PP_FileInfo_Dev* info,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::Query(PP_FileInfo_Dev* info,
+ PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@@ -265,13 +267,13 @@
if (!base::FileUtilProxy::GetFileInfoFromPlatformFile(
delegate_->GetFileThreadMessageLoopProxy(), file_,
- callback_factory_.NewCallback(&FileIO::QueryInfoCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::QueryInfoCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-int32_t FileIO::Touch(PP_Time last_access_time,
+int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
@@ -284,16 +286,16 @@
delegate_->GetFileThreadMessageLoopProxy(),
file_, base::Time::FromDoubleT(last_access_time),
base::Time::FromDoubleT(last_modified_time),
- callback_factory_.NewCallback(&FileIO::StatusCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-int32_t FileIO::Read(int64_t offset,
- char* buffer,
- int32_t bytes_to_read,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::Read(int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@@ -303,16 +305,16 @@
if (!base::FileUtilProxy::Read(
delegate_->GetFileThreadMessageLoopProxy(),
file_, offset, buffer, bytes_to_read,
- callback_factory_.NewCallback(&FileIO::ReadWriteCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadWriteCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-int32_t FileIO::Write(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::Write(int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@@ -322,13 +324,13 @@
if (!base::FileUtilProxy::Write(
delegate_->GetFileThreadMessageLoopProxy(),
file_, offset, buffer, bytes_to_write,
- callback_factory_.NewCallback(&FileIO::ReadWriteCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadWriteCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-int32_t FileIO::SetLength(int64_t length,
+int32_t PPB_FileIO_Impl::SetLength(int64_t length,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@@ -339,13 +341,13 @@
if (!base::FileUtilProxy::Truncate(
delegate_->GetFileThreadMessageLoopProxy(),
file_, length,
- callback_factory_.NewCallback(&FileIO::StatusCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-int32_t FileIO::Flush(PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::Flush(PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@@ -354,19 +356,19 @@
if (!base::FileUtilProxy::Flush(
delegate_->GetFileThreadMessageLoopProxy(), file_,
- callback_factory_.NewCallback(&FileIO::StatusCallback)))
+ callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
-void FileIO::Close() {
+void PPB_FileIO_Impl::Close() {
if (file_ != base::kInvalidPlatformFileValue)
base::FileUtilProxy::Close(
delegate_->GetFileThreadMessageLoopProxy(), file_, NULL);
}
-int32_t FileIO::GetOSFileDescriptor() {
+int32_t PPB_FileIO_Impl::GetOSFileDescriptor() {
#if defined(OS_POSIX)
return file_;
#elif defined(OS_WIN)
@@ -376,20 +378,20 @@
#endif
}
-int32_t FileIO::WillWrite(int64_t offset,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::WillWrite(int64_t offset,
+ int32_t bytes_to_write,
+ PP_CompletionCallback callback) {
// TODO(dumi): implement me
return PP_OK;
}
-int32_t FileIO::WillSetLength(int64_t length,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::WillSetLength(int64_t length,
+ PP_CompletionCallback callback) {
// TODO(dumi): implement me
return PP_OK;
}
-void FileIO::RunPendingCallback(int result) {
+void PPB_FileIO_Impl::RunPendingCallback(int result) {
if (!callback_.func)
return;
@@ -398,19 +400,21 @@
PP_RunCompletionCallback(&callback, result);
}
-void FileIO::StatusCallback(base::PlatformFileError error_code) {
+void PPB_FileIO_Impl::StatusCallback(base::PlatformFileError error_code) {
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
}
-void FileIO::AsyncOpenFileCallback(base::PlatformFileError error_code,
- base::PlatformFile file) {
+void PPB_FileIO_Impl::AsyncOpenFileCallback(
+ base::PlatformFileError error_code,
+ base::PlatformFile file) {
DCHECK(file_ == base::kInvalidPlatformFileValue);
file_ = file;
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
}
-void FileIO::QueryInfoCallback(base::PlatformFileError error_code,
- const base::PlatformFileInfo& file_info) {
+void PPB_FileIO_Impl::QueryInfoCallback(
+ base::PlatformFileError error_code,
+ const base::PlatformFileInfo& file_info) {
DCHECK(info_);
if (error_code == base::PLATFORM_FILE_OK) {
info_->size = file_info.size;
@@ -426,12 +430,14 @@
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
}
-void FileIO::ReadWriteCallback(base::PlatformFileError error_code,
- int bytes_read_or_written) {
+void PPB_FileIO_Impl::ReadWriteCallback(base::PlatformFileError error_code,
+ int bytes_read_or_written) {
if (error_code != base::PLATFORM_FILE_OK)
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
else
RunPendingCallback(bytes_read_or_written);
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_io_impl.h ('k') | webkit/plugins/ppapi/ppb_file_ref_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698