OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
16 #include "content/public/renderer/renderer_ppapi_host.h" | 16 #include "content/public/renderer/renderer_ppapi_host.h" |
17 #include "ipc/ipc_listener.h" | 17 #include "ipc/ipc_listener.h" |
18 #include "ipc/ipc_platform_file.h" | 18 #include "ipc/ipc_platform_file.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 "ppapi/shared_impl/file_ref_detailed_info.h" |
22 #include "ppapi/thunk/ppb_file_ref_api.h" | 23 #include "ppapi/thunk/ppb_file_ref_api.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 #include "webkit/common/quota/quota_types.h" | 25 #include "webkit/common/quota/quota_types.h" |
25 | 26 |
26 using ppapi::host::ReplyMessageContext; | 27 using ppapi::host::ReplyMessageContext; |
27 | 28 |
28 namespace content { | 29 namespace content { |
| 30 class PepperPluginInstanceImpl; |
29 class QuotaFileIO; | 31 class QuotaFileIO; |
| 32 class RendererPpapiHostImpl; |
30 | 33 |
31 class PepperFileIOHost : public ppapi::host::ResourceHost, | 34 class PepperFileIOHost : public ppapi::host::ResourceHost, |
32 public base::SupportsWeakPtr<PepperFileIOHost>, | 35 public base::SupportsWeakPtr<PepperFileIOHost>, |
33 public IPC::Listener { | 36 public IPC::Listener { |
34 public: | 37 public: |
35 typedef base::Callback<void (base::PlatformFileError)> | 38 typedef base::Callback<void (base::PlatformFileError)> |
36 NotifyCloseFileCallback; | 39 NotifyCloseFileCallback; |
37 | 40 |
38 PepperFileIOHost(RendererPpapiHost* host, | 41 PepperFileIOHost(RendererPpapiHostImpl* host, |
39 PP_Instance instance, | 42 PP_Instance instance, |
40 PP_Resource resource); | 43 PP_Resource resource); |
41 virtual ~PepperFileIOHost(); | 44 virtual ~PepperFileIOHost(); |
42 | 45 |
43 // ppapi::host::ResourceHost override. | 46 // ppapi::host::ResourceHost override. |
44 virtual int32_t OnResourceMessageReceived( | 47 virtual int32_t OnResourceMessageReceived( |
45 const IPC::Message& msg, | 48 const IPC::Message& msg, |
46 ppapi::host::HostMessageContext* context) OVERRIDE; | 49 ppapi::host::HostMessageContext* context) OVERRIDE; |
47 | 50 |
48 private: | 51 private: |
(...skipping 27 matching lines...) Expand all Loading... |
76 ppapi::host::HostMessageContext* context); | 79 ppapi::host::HostMessageContext* context); |
77 // Trusted API. | 80 // Trusted API. |
78 int32_t OnHostMsgGetOSFileDescriptor( | 81 int32_t OnHostMsgGetOSFileDescriptor( |
79 ppapi::host::HostMessageContext* context); | 82 ppapi::host::HostMessageContext* context); |
80 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, | 83 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context, |
81 int64_t offset, | 84 int64_t offset, |
82 int32_t bytes_to_write); | 85 int32_t bytes_to_write); |
83 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, | 86 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context, |
84 int64_t length); | 87 int64_t length); |
85 | 88 |
| 89 void DidGetFileRefInfo( |
| 90 ppapi::host::ReplyMessageContext reply_context, |
| 91 int flags, |
| 92 const std::vector<ppapi::FileRefDetailedInfo>& infos); |
| 93 |
86 // Callback handlers. These mostly convert the PlatformFileError to the | 94 // Callback handlers. These mostly convert the PlatformFileError to the |
87 // PP_Error code and send back the reply. Note that the argument | 95 // PP_Error code and send back the reply. Note that the argument |
88 // ReplyMessageContext is copied so that we have a closure containing all | 96 // ReplyMessageContext is copied so that we have a closure containing all |
89 // necessary information to reply. | 97 // necessary information to reply. |
90 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, | 98 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context, |
91 base::PlatformFileError error_code); | 99 base::PlatformFileError error_code); |
92 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, | 100 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context, |
93 base::PlatformFileError error_code, | 101 base::PlatformFileError error_code, |
94 base::PassPlatformFile file); | 102 base::PassPlatformFile file); |
95 void ExecutePlatformOpenFileSystemURLCallback( | 103 void ExecutePlatformOpenFileSystemURLCallback( |
96 ReplyMessageContext reply_context, | 104 ReplyMessageContext reply_context, |
97 base::PlatformFileError error_code, | 105 base::PlatformFileError error_code, |
98 base::PassPlatformFile file, | 106 base::PassPlatformFile file, |
99 quota::QuotaLimitType quota_policy, | 107 quota::QuotaLimitType quota_policy, |
100 const NotifyCloseFileCallback& callback); | 108 const NotifyCloseFileCallback& callback); |
101 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context, | 109 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context, |
102 base::PlatformFileError error_code, | 110 base::PlatformFileError error_code, |
103 const base::PlatformFileInfo& file_info); | 111 const base::PlatformFileInfo& file_info); |
104 void ExecutePlatformReadCallback(ReplyMessageContext reply_context, | 112 void ExecutePlatformReadCallback(ReplyMessageContext reply_context, |
105 base::PlatformFileError error_code, | 113 base::PlatformFileError error_code, |
106 const char* data, int bytes_read); | 114 const char* data, int bytes_read); |
107 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, | 115 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context, |
108 base::PlatformFileError error_code, | 116 base::PlatformFileError error_code, |
109 int bytes_written); | 117 int bytes_written); |
110 | 118 |
| 119 RendererPpapiHostImpl* host_; |
| 120 PepperPluginInstanceImpl* plugin_instance_; |
111 base::PlatformFile file_; | 121 base::PlatformFile file_; |
112 | 122 |
113 // The file system type specified in the Open() call. This will be | 123 // The file system type specified in the Open() call. This will be |
114 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not | 124 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not |
115 // indicate that the open command actually succeeded. | 125 // indicate that the open command actually succeeded. |
116 PP_FileSystemType file_system_type_; | 126 PP_FileSystemType file_system_type_; |
117 | 127 |
118 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. | 128 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. |
119 GURL file_system_url_; | 129 GURL file_system_url_; |
120 | 130 |
(...skipping 21 matching lines...) Expand all Loading... |
142 AsyncOpenFileCallback; | 152 AsyncOpenFileCallback; |
143 | 153 |
144 IDMap<AsyncOpenFileCallback> pending_async_open_files_; | 154 IDMap<AsyncOpenFileCallback> pending_async_open_files_; |
145 | 155 |
146 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); | 156 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost); |
147 }; | 157 }; |
148 | 158 |
149 } // namespace content | 159 } // namespace content |
150 | 160 |
151 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ | 161 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_ |
OLD | NEW |