OLD | NEW |
1 // Copyright 2013 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 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h" | 5 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/storage_partition.h" | 21 #include "content/public/browser/storage_partition.h" |
22 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
23 #include "ppapi/c/pp_errors.h" | 23 #include "ppapi/c/pp_errors.h" |
24 #include "ppapi/c/ppb_file_io.h" | 24 #include "ppapi/c/ppb_file_io.h" |
25 #include "ppapi/host/dispatch_host_message.h" | 25 #include "ppapi/host/dispatch_host_message.h" |
26 #include "ppapi/host/ppapi_host.h" | 26 #include "ppapi/host/ppapi_host.h" |
27 #include "ppapi/proxy/ppapi_messages.h" | 27 #include "ppapi/proxy/ppapi_messages.h" |
28 #include "ppapi/shared_impl/file_system_util.h" | 28 #include "ppapi/shared_impl/file_system_util.h" |
29 #include "ppapi/shared_impl/file_type_conversion.h" | 29 #include "ppapi/shared_impl/file_type_conversion.h" |
30 #include "ppapi/shared_impl/time_conversion.h" | 30 #include "ppapi/shared_impl/time_conversion.h" |
31 #include "webkit/browser/fileapi/file_observers.h" | 31 #include "storage/browser/fileapi/file_observers.h" |
32 #include "webkit/browser/fileapi/file_system_context.h" | 32 #include "storage/browser/fileapi/file_system_context.h" |
33 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 33 #include "storage/browser/fileapi/file_system_operation_runner.h" |
34 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" | 34 #include "storage/browser/fileapi/task_runner_bound_observer_list.h" |
35 #include "webkit/common/fileapi/file_system_util.h" | 35 #include "storage/common/fileapi/file_system_util.h" |
36 | 36 |
37 namespace content { | 37 namespace content { |
38 | 38 |
39 using ppapi::FileIOStateManager; | 39 using ppapi::FileIOStateManager; |
40 using ppapi::PPTimeToTime; | 40 using ppapi::PPTimeToTime; |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 PepperFileIOHost::UIThreadStuff GetUIThreadStuffForInternalFileSystems( | 44 PepperFileIOHost::UIThreadStuff GetUIThreadStuffForInternalFileSystems( |
45 int render_process_id) { | 45 int render_process_id) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 void FileCloser(base::File auto_close) { | 81 void FileCloser(base::File auto_close) { |
82 } | 82 } |
83 | 83 |
84 void DidCloseFile(const base::Closure& on_close_callback) { | 84 void DidCloseFile(const base::Closure& on_close_callback) { |
85 if (!on_close_callback.is_null()) | 85 if (!on_close_callback.is_null()) |
86 on_close_callback.Run(); | 86 on_close_callback.Run(); |
87 } | 87 } |
88 | 88 |
89 void DidOpenFile(base::WeakPtr<PepperFileIOHost> file_host, | 89 void DidOpenFile(base::WeakPtr<PepperFileIOHost> file_host, |
90 fileapi::FileSystemOperation::OpenFileCallback callback, | 90 storage::FileSystemOperation::OpenFileCallback callback, |
91 base::File file, | 91 base::File file, |
92 const base::Closure& on_close_callback) { | 92 const base::Closure& on_close_callback) { |
93 if (file_host) { | 93 if (file_host) { |
94 callback.Run(file.Pass(), on_close_callback); | 94 callback.Run(file.Pass(), on_close_callback); |
95 } else { | 95 } else { |
96 BrowserThread::PostTaskAndReply( | 96 BrowserThread::PostTaskAndReply( |
97 BrowserThread::FILE, | 97 BrowserThread::FILE, |
98 FROM_HERE, | 98 FROM_HERE, |
99 base::Bind(&FileCloser, base::Passed(&file)), | 99 base::Bind(&FileCloser, base::Passed(&file)), |
100 base::Bind(&DidCloseFile, on_close_callback)); | 100 base::Bind(&DidCloseFile, on_close_callback)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // it like internal file systems and access it via the FileSystemURL. | 179 // it like internal file systems and access it via the FileSystemURL. |
180 bool is_internal_type = (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) || | 180 bool is_internal_type = (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) || |
181 file_system_url_.is_valid(); | 181 file_system_url_.is_valid(); |
182 | 182 |
183 if (is_internal_type) { | 183 if (is_internal_type) { |
184 if (!file_system_url_.is_valid()) | 184 if (!file_system_url_.is_valid()) |
185 return PP_ERROR_BADARGUMENT; | 185 return PP_ERROR_BADARGUMENT; |
186 | 186 |
187 // Not all external file systems are fully supported yet. | 187 // Not all external file systems are fully supported yet. |
188 // Whitelist the supported ones. | 188 // Whitelist the supported ones. |
189 if (file_system_url_.mount_type() == fileapi::kFileSystemTypeExternal) { | 189 if (file_system_url_.mount_type() == storage::kFileSystemTypeExternal) { |
190 switch (file_system_url_.type()) { | 190 switch (file_system_url_.type()) { |
191 case fileapi::kFileSystemTypeNativeMedia: | 191 case storage::kFileSystemTypeNativeMedia: |
192 case fileapi::kFileSystemTypeDeviceMedia: | 192 case storage::kFileSystemTypeDeviceMedia: |
193 case fileapi::kFileSystemTypePicasa: | 193 case storage::kFileSystemTypePicasa: |
194 case fileapi::kFileSystemTypeItunes: | 194 case storage::kFileSystemTypeItunes: |
195 case fileapi::kFileSystemTypeIphoto: | 195 case storage::kFileSystemTypeIphoto: |
196 break; | 196 break; |
197 default: | 197 default: |
198 return PP_ERROR_NOACCESS; | 198 return PP_ERROR_NOACCESS; |
199 } | 199 } |
200 } | 200 } |
201 if (!CanOpenFileSystemURLWithPepperFlags( | 201 if (!CanOpenFileSystemURLWithPepperFlags( |
202 open_flags, render_process_id_, file_system_url_)) | 202 open_flags, render_process_id_, file_system_url_)) |
203 return PP_ERROR_NOACCESS; | 203 return PP_ERROR_NOACCESS; |
204 BrowserThread::PostTaskAndReplyWithResult( | 204 BrowserThread::PostTaskAndReplyWithResult( |
205 BrowserThread::UI, | 205 BrowserThread::UI, |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 488 |
489 ppapi::proxy::SerializedHandle file_handle; | 489 ppapi::proxy::SerializedHandle file_handle; |
490 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. | 490 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. |
491 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; | 491 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; |
492 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); | 492 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); |
493 reply_context->params.AppendHandle(file_handle); | 493 reply_context->params.AppendHandle(file_handle); |
494 return true; | 494 return true; |
495 } | 495 } |
496 | 496 |
497 } // namespace content | 497 } // namespace content |
OLD | NEW |