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

Side by Side 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: Rebased Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/platform_file.h" 13 #include "base/platform_file.h"
14 #include "content/public/renderer/renderer_ppapi_host.h" 14 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
15 #include "ipc/ipc_listener.h" 15 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_platform_file.h" 16 #include "ipc/ipc_platform_file.h"
17 #include "ppapi/c/pp_file_info.h" 17 #include "ppapi/c/pp_file_info.h"
18 #include "ppapi/c/pp_time.h" 18 #include "ppapi/c/pp_time.h"
19 #include "ppapi/host/host_message_context.h" 19 #include "ppapi/host/host_message_context.h"
20 #include "ppapi/host/resource_host.h" 20 #include "ppapi/host/resource_host.h"
21 #include "ppapi/shared_impl/file_io_state_manager.h" 21 #include "ppapi/shared_impl/file_io_state_manager.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 #include "webkit/browser/fileapi/file_system_context.h"
24 #include "webkit/browser/fileapi/file_system_operation_runner.h"
23 #include "webkit/common/quota/quota_types.h" 25 #include "webkit/common/quota/quota_types.h"
24 26
25 using ppapi::host::ReplyMessageContext; 27 using ppapi::host::ReplyMessageContext;
26 28
27 namespace content { 29 namespace content {
28 class QuotaFileIO; 30 class QuotaFileIO;
29 31
30 class PepperFileIOHost : public ppapi::host::ResourceHost, 32 class PepperFileIOHost : public ppapi::host::ResourceHost,
31 public base::SupportsWeakPtr<PepperFileIOHost>, 33 public base::SupportsWeakPtr<PepperFileIOHost> {
32 public IPC::Listener {
33 public: 34 public:
34 typedef base::Callback<void (base::PlatformFileError)> 35 typedef base::Callback<void (base::PlatformFileError)>
35 NotifyCloseFileCallback; 36 NotifyCloseFileCallback;
36 37
37 PepperFileIOHost(RendererPpapiHost* host, 38 PepperFileIOHost(BrowserPpapiHostImpl* host,
38 PP_Instance instance, 39 PP_Instance instance,
39 PP_Resource resource); 40 PP_Resource resource);
40 virtual ~PepperFileIOHost(); 41 virtual ~PepperFileIOHost();
41 42
42 // ppapi::host::ResourceHost override. 43 // ppapi::host::ResourceHost override.
43 virtual int32_t OnResourceMessageReceived( 44 virtual int32_t OnResourceMessageReceived(
44 const IPC::Message& msg, 45 const IPC::Message& msg,
45 ppapi::host::HostMessageContext* context) OVERRIDE; 46 ppapi::host::HostMessageContext* context) OVERRIDE;
46 47
48 struct UIThreadStuff {
49 UIThreadStuff();
50 ~UIThreadStuff();
51 base::ProcessId resolved_render_process_id;
52 scoped_refptr<fileapi::FileSystemContext> file_system_context;
53 };
47 private: 54 private:
48 // IPC::Listener implementation.
49 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
50
51 void OnAsyncFileOpened(
52 base::PlatformFileError error_code,
53 IPC::PlatformFileForTransit file_for_transit);
54
55 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, 55 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
56 PP_Resource file_ref_resource, 56 PP_Resource file_ref_resource,
57 int32_t open_flags); 57 int32_t open_flags);
58 int32_t OnHostMsgTouch(ppapi::host::HostMessageContext* context, 58 int32_t OnHostMsgTouch(ppapi::host::HostMessageContext* context,
59 PP_Time last_access_time, 59 PP_Time last_access_time,
60 PP_Time last_modified_time); 60 PP_Time last_modified_time);
61 int32_t OnHostMsgWrite(ppapi::host::HostMessageContext* context, 61 int32_t OnHostMsgWrite(ppapi::host::HostMessageContext* context,
62 int64_t offset, 62 int64_t offset,
63 const std::string& buffer); 63 const std::string& buffer);
64 int32_t OnHostMsgSetLength(ppapi::host::HostMessageContext* context, 64 int32_t OnHostMsgSetLength(ppapi::host::HostMessageContext* context,
65 int64_t length); 65 int64_t length);
66 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); 66 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
67 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); 67 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
68 // Private API.
69 int32_t OnHostMsgRequestOSFileHandle( 68 int32_t OnHostMsgRequestOSFileHandle(
70 ppapi::host::HostMessageContext* context); 69 ppapi::host::HostMessageContext* context);
71 70
71 void GotPluginAllowedToCallRequestOSFileHandle(
72 ppapi::host::ReplyMessageContext reply_context,
73 bool plugin_allowed);
74
72 // Callback handlers. These mostly convert the PlatformFileError to the 75 // Callback handlers. These mostly convert the PlatformFileError to the
73 // PP_Error code and send back the reply. Note that the argument 76 // PP_Error code and send back the reply. Note that the argument
74 // ReplyMessageContext is copied so that we have a closure containing all 77 // ReplyMessageContext is copied so that we have a closure containing all
75 // necessary information to reply. 78 // necessary information to reply.
76 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, 79 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context,
77 base::PlatformFileError error_code); 80 base::PlatformFileError error_code);
78 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, 81 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context,
79 base::PlatformFileError error_code, 82 base::PlatformFileError error_code,
80 base::PassPlatformFile file); 83 base::PassPlatformFile file,
81 void ExecutePlatformOpenFileSystemURLCallback( 84 bool unused_created);
82 ReplyMessageContext reply_context,
83 base::PlatformFileError error_code,
84 base::PassPlatformFile file,
85 quota::QuotaLimitType quota_policy,
86 const NotifyCloseFileCallback& callback);
87 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context,
88 base::PlatformFileError error_code,
89 const base::PlatformFileInfo& file_info);
90 void ExecutePlatformReadCallback(ReplyMessageContext reply_context,
91 base::PlatformFileError error_code,
92 const char* data, int bytes_read);
93 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, 85 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context,
94 base::PlatformFileError error_code, 86 base::PlatformFileError error_code,
95 int bytes_written); 87 int bytes_written);
96 88
97 RendererPpapiHost* renderer_ppapi_host_; 89 void GotUIThreadStuffForInternalFileSystems(
90 ReplyMessageContext reply_context,
91 int platform_file_flags,
92 UIThreadStuff ui_thread_stuff);
93 void DidOpenInternalFile(
94 ReplyMessageContext reply_context,
95 base::PlatformFileError result,
96 base::PlatformFile file,
97 const base::Closure& on_close_callback);
98 void GotResolvedRenderProcessId(
99 ReplyMessageContext reply_context,
100 base::FilePath path,
101 int platform_file_flags,
102 base::ProcessId resolved_render_process_id);
103
104 void DidCloseFile(base::PlatformFileError error);
105
106 // Adds file_ to |reply_context| with the specified |open_flags|.
107 bool AddFileToReplyContext(
108 int32_t open_flags,
109 ppapi::host::ReplyMessageContext* reply_context) const;
110
111 BrowserPpapiHostImpl* browser_ppapi_host_;
112
113 RenderProcessHost* render_process_host_;
114 int render_process_id_;
115 base::ProcessId resolved_render_process_id_;
116
98 base::PlatformFile file_; 117 base::PlatformFile file_;
99 118
100 // The file system type specified in the Open() call. This will be 119 // The file system type specified in the Open() call. This will be
101 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not 120 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not
102 // indicate that the open command actually succeeded. 121 // indicate that the open command actually succeeded.
103 PP_FileSystemType file_system_type_; 122 PP_FileSystemType file_system_type_;
104 123
105 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. 124 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}.
106 GURL file_system_url_; 125 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
126 scoped_ptr<fileapi::FileSystemOperationRunner> file_system_operation_runner_;
127 fileapi::FileSystemURL file_system_url_;
128 base::Closure on_close_callback_;
107 129
108 // Used to check if we can pass file handle to plugins. 130 // Used to check if we can pass file handle to plugins.
109 quota::QuotaLimitType quota_policy_; 131 quota::QuotaLimitType quota_policy_;
110 132
111 // Callback function for notifying when the file handle is closed.
112 NotifyCloseFileCallback notify_close_file_callback_;
113
114 // Pointer to a QuotaFileIO instance, which is valid only while a file 133 // Pointer to a QuotaFileIO instance, which is valid only while a file
115 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. 134 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened.
116 scoped_ptr<QuotaFileIO> quota_file_io_; 135 scoped_ptr<QuotaFileIO> quota_file_io_;
117 136
118 int32_t open_flags_; 137 int32_t open_flags_;
119 138
120 ppapi::FileIOStateManager state_manager_; 139 ppapi::FileIOStateManager state_manager_;
121 140
122 int routing_id_; 141 scoped_refptr<base::MessageLoopProxy> file_message_loop_;
123
124 base::Callback<void(base::PlatformFileError, base::PassPlatformFile)>
125 pending_open_callback_;
126 142
127 base::WeakPtrFactory<PepperFileIOHost> weak_factory_; 143 base::WeakPtrFactory<PepperFileIOHost> weak_factory_;
128 144
129 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); 145 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost);
130 }; 146 };
131 147
132 } // namespace content 148 } // namespace content
133 149
134 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ 150 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698