diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-09 18:09:59 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-09 18:09:59 +0000 |
commit | f2a211d23fc4d94ae21bb2efb7a72eff5a9a2457 (patch) | |
tree | 3a74a4bd800ee012a0e851c86f6e1f267673c299 /ppapi/shared_impl/ppb_file_io_shared.h | |
parent | 46fb94424addb322c7dfad1e8eba462baf0cdcb7 (diff) | |
download | chromium_src-f2a211d23fc4d94ae21bb2efb7a72eff5a9a2457.zip chromium_src-f2a211d23fc4d94ae21bb2efb7a72eff5a9a2457.tar.gz chromium_src-f2a211d23fc4d94ae21bb2efb7a72eff5a9a2457.tar.bz2 |
Revert 113817 - Implement a proxy for Pepper FileIO.
[ Reland of 113565 http://codereview.chromium.org/8764003 ]
This splits apart the old in-process implementation into a new object in shared_impl that does most of the general tracking. This alllows that code to be shared by the proxy.
BUG=http://crbug.com/101154
TBR=brettw@chromium.org
Review URL: http://codereview.chromium.org/8898005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/ppb_file_io_shared.h')
-rw-r--r-- | ppapi/shared_impl/ppb_file_io_shared.h | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/ppapi/shared_impl/ppb_file_io_shared.h b/ppapi/shared_impl/ppb_file_io_shared.h deleted file mode 100644 index 341db46..0000000 --- a/ppapi/shared_impl/ppb_file_io_shared.h +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_ -#define PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_ - -#include <deque> - -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_file_io_api.h" - -namespace ppapi { - -namespace thunk { -class PPB_FileRef_API; -} - -class PPAPI_SHARED_EXPORT PPB_FileIO_Shared : public Resource, - public thunk::PPB_FileIO_API { - public: - PPB_FileIO_Shared(PP_Instance instance); - PPB_FileIO_Shared(const HostResource& host_resource); - ~PPB_FileIO_Shared(); - - // Resource overrides. - virtual void LastPluginRefWasDeleted() OVERRIDE; - virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; - - // PPB_FileIO_API implementation. - virtual int32_t Open(PP_Resource file_ref, - int32_t open_flags, - PP_CompletionCallback callback) OVERRIDE; - virtual int32_t Query(PP_FileInfo* info, - PP_CompletionCallback callback) OVERRIDE; - virtual int32_t Touch(PP_Time last_access_time, - PP_Time last_modified_time, - PP_CompletionCallback callback) OVERRIDE; - virtual int32_t Read(int64_t offset, - char* buffer, - int32_t bytes_to_read, - PP_CompletionCallback callback) OVERRIDE; - virtual int32_t Write(int64_t offset, - const char* buffer, - int32_t bytes_to_write, - PP_CompletionCallback callback) OVERRIDE; - virtual int32_t SetLength(int64_t length, - PP_CompletionCallback callback) OVERRIDE; - virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; - - // Callback handler for different types of operations. - void ExecuteGeneralCallback(int32_t pp_error); - void ExecuteOpenFileCallback(int32_t pp_error); - void ExecuteQueryCallback(int32_t pp_error, const PP_FileInfo& info); - void ExecuteReadCallback(int32_t pp_error, const char* data); - - protected: - struct CallbackEntry { - CallbackEntry(); - CallbackEntry(const CallbackEntry& entry); - ~CallbackEntry(); - - PP_CompletionCallback callback; - - // Pointer back to the caller's read buffer; only used by |Read()|, NULL - // for non-read operations. Not owned. - char* read_buffer; - - // Pointer back to the caller's PP_FileInfo structure for Query operations. - // NULL for non-query operations. Not owned. - PP_FileInfo* info; - }; - - enum OperationType { - // There is no pending operation right now. - OPERATION_NONE, - - // If there are pending reads, any other kind of async operation is not - // allowed. - OPERATION_READ, - - // If there are pending writes, any other kind of async operation is not - // allowed. - OPERATION_WRITE, - - // If there is a pending operation that is neither read nor write, no - // further async operation is allowed. - OPERATION_EXCLUSIVE - }; - - // Validated versions of the FileIO API. Subclasses in the proxy and impl - // implement these so the common error checking stays here. - virtual int32_t OpenValidated(PP_Resource file_ref_resource, - thunk::PPB_FileRef_API* file_ref_api, - int32_t open_flags, - PP_CompletionCallback callback) = 0; - virtual int32_t QueryValidated(PP_FileInfo* info, - PP_CompletionCallback callback) = 0; - virtual int32_t TouchValidated(PP_Time last_access_time, - PP_Time last_modified_time, - PP_CompletionCallback callback) = 0; - virtual int32_t ReadValidated(int64_t offset, - char* buffer, - int32_t bytes_to_read, - PP_CompletionCallback callback) = 0; - virtual int32_t WriteValidated(int64_t offset, - const char* buffer, - int32_t bytes_to_write, - PP_CompletionCallback callback) = 0; - virtual int32_t SetLengthValidated(int64_t length, - PP_CompletionCallback callback) = 0; - virtual int32_t FlushValidated(PP_CompletionCallback callback) = 0; - - // Called for every "Validated" function. - // - // This verifies that the callback is valid and that no callback is already - // pending, or it is a read(write) request and currently the pending - // operations are reads(writes). - // - // Returns |PP_OK| to indicate that everything is valid or |PP_ERROR_...| if - // the call should be aborted and that code returned to the plugin. - int32_t CommonCallValidation(bool should_be_open, - OperationType new_op, - PP_CompletionCallback callback); - - // Sets up a pending callback. This should only be called once it is certain - // that |PP_OK_COMPLETIONPENDING| will be returned. - // - // |read_buffer| is only used by read operations, |info| is used only by - // query operations. - void RegisterCallback(OperationType op, - PP_CompletionCallback callback, - char* read_buffer, - PP_FileInfo* info); - - // Pops the oldest callback from the queue and runs it. - void RunAndRemoveFirstPendingCallback(int32_t result); - - // The file system type specified in the Open() call. This will be - // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not - // indicate that the open command actually succeeded. - PP_FileSystemType file_system_type_; - - // Set to true when the file has been successfully opened. - bool file_open_; - - std::deque<CallbackEntry> callbacks_; - OperationType pending_op_; - - DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Shared); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_ |