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

Unified Diff: content/browser/renderer_host/pepper/pepper_file_io_host.h

Issue 33053002: Pepper: Move FileIO host from renderer to browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for bbudge 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: content/browser/renderer_host/pepper/pepper_file_io_host.h
diff --git a/content/renderer/pepper/pepper_file_io_host.h b/content/browser/renderer_host/pepper/pepper_file_io_host.h
similarity index 69%
rename from content/renderer/pepper/pepper_file_io_host.h
rename to content/browser/renderer_host/pepper/pepper_file_io_host.h
index 95f1d7253aed741721b9958d28dbdeb9ce901000..4607919d7daddb702e6617b79f01965b6f913be5 100644
--- a/content/renderer/pepper/pepper_file_io_host.h
+++ b/content/browser/renderer_host/pepper/pepper_file_io_host.h
@@ -11,7 +11,7 @@
#include "base/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
-#include "content/public/renderer/renderer_ppapi_host.h"
+#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_file_info.h"
@@ -20,6 +20,8 @@
#include "ppapi/host/resource_host.h"
#include "ppapi/shared_impl/file_io_state_manager.h"
#include "url/gurl.h"
+#include "webkit/browser/fileapi/file_system_context.h"
+#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/common/quota/quota_types.h"
using ppapi::host::ReplyMessageContext;
@@ -28,13 +30,12 @@ namespace content {
class QuotaFileIO;
class PepperFileIOHost : public ppapi::host::ResourceHost,
- public base::SupportsWeakPtr<PepperFileIOHost>,
- public IPC::Listener {
+ public base::SupportsWeakPtr<PepperFileIOHost> {
public:
typedef base::Callback<void (base::PlatformFileError)>
NotifyCloseFileCallback;
- PepperFileIOHost(RendererPpapiHost* host,
+ PepperFileIOHost(BrowserPpapiHostImpl* host,
PP_Instance instance,
PP_Resource resource);
virtual ~PepperFileIOHost();
@@ -45,13 +46,6 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
ppapi::host::HostMessageContext* context) OVERRIDE;
private:
- // IPC::Listener implementation.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- void OnAsyncFileOpened(
- base::PlatformFileError error_code,
- IPC::PlatformFileForTransit file_for_transit);
-
int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
PP_Resource file_ref_resource,
int32_t open_flags);
@@ -65,10 +59,12 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
int64_t length);
int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
- // Private API.
int32_t OnHostMsgRequestOSFileHandle(
ppapi::host::HostMessageContext* context);
+ void FinishRequestOSFileHandle(ppapi::host::ReplyMessageContext reply_context,
+ RenderProcessHost* render_process_host);
+
// Callback handlers. These mostly convert the PlatformFileError to the
// PP_Error code and send back the reply. Note that the argument
// ReplyMessageContext is copied so that we have a closure containing all
@@ -77,24 +73,41 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
base::PlatformFileError error_code);
void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context,
base::PlatformFileError error_code,
- base::PassPlatformFile file);
- void ExecutePlatformOpenFileSystemURLCallback(
- ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- base::PassPlatformFile file,
- quota::QuotaLimitType quota_policy,
- const NotifyCloseFileCallback& callback);
- void ExecutePlatformQueryCallback(ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- const base::PlatformFileInfo& file_info);
- void ExecutePlatformReadCallback(ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- const char* data, int bytes_read);
+ base::PassPlatformFile file,
+ bool unused_created);
void ExecutePlatformWriteCallback(ReplyMessageContext reply_context,
base::PlatformFileError error_code,
int bytes_written);
- RendererPpapiHost* renderer_ppapi_host_;
+ // Callback handler for GetFileSystemContext.
+ void GotFileSystemContext(
+ ReplyMessageContext reply_context,
+ int platform_file_flags,
+ scoped_refptr<fileapi::FileSystemContext> fs_context);
kinuko 2013/10/23 07:16:04 nit: indent
teravest 2013/10/23 16:54:27 Done.
+ void DidOpenFile(
+ ReplyMessageContext reply_context,
+ base::PlatformFileError result,
+ base::PlatformFile file,
+ const base::Closure& on_close_callback);
+
+ // Retrieves the RenderProcessHost (from the UI thread, if necessary) and
+ // invokes the specified callback.
+ void GetRenderProcessHost(base::Callback<void(RenderProcessHost*)> callback);
+ // Stores the RenderProcessHost and invokes the callback passed to
+ // GetRenderProcessHost().
+ void GotRenderProcessHost(base::Callback<void(RenderProcessHost*)> callback,
+ RenderProcessHost* host);
+
+ // Adds file_ to |reply_context| with the specified |open_flags|.
+ bool AddFileToReplyContext(
+ int32_t open_flags,
+ ppapi::host::ReplyMessageContext* reply_context) const;
+
+ BrowserPpapiHostImpl* browser_ppapi_host_;
+
+ RenderProcessHost* render_process_host_;
+ int render_process_id_;
+
base::PlatformFile file_;
// The file system type specified in the Open() call. This will be
@@ -103,7 +116,10 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
PP_FileSystemType file_system_type_;
// Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}.
- GURL file_system_url_;
+ scoped_refptr<fileapi::FileSystemContext> file_system_context_;
+ scoped_ptr<fileapi::FileSystemOperationRunner> file_system_operation_runner_;
+ fileapi::FileSystemURL file_system_url_;
+ base::Closure on_close_callback_;
// Used to check if we can pass file handle to plugins.
quota::QuotaLimitType quota_policy_;
@@ -119,10 +135,7 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
ppapi::FileIOStateManager state_manager_;
- int routing_id_;
-
- base::Callback<void(base::PlatformFileError, base::PassPlatformFile)>
- pending_open_callback_;
+ scoped_refptr<base::MessageLoopProxy> file_message_loop_;
base::WeakPtrFactory<PepperFileIOHost> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698