| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_file_io.h" | 5 #include "webkit/glue/plugins/pepper_file_io.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "ppapi/c/dev/ppb_file_io_dev.h" | 14 #include "ppapi/c/dev/ppb_file_io_dev.h" |
| 15 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h" | 15 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h" |
| 16 #include "ppapi/c/pp_completion_callback.h" | 16 #include "ppapi/c/pp_completion_callback.h" |
| 17 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
| 18 #include "webkit/glue/plugins/pepper_common.h" |
| 18 #include "webkit/glue/plugins/pepper_file_ref.h" | 19 #include "webkit/glue/plugins/pepper_file_ref.h" |
| 19 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 20 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 20 #include "webkit/glue/plugins/pepper_plugin_module.h" | 21 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 21 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 22 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
| 22 | 23 |
| 23 namespace pepper { | 24 namespace pepper { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 PP_Resource Create(PP_Module module_id) { | 28 PP_Resource Create(PP_Module module_id) { |
| 28 PluginModule* module = ResourceTracker::Get()->GetModule(module_id); | 29 PluginModule* module = ResourceTracker::Get()->GetModule(module_id); |
| 29 if (!module) | 30 if (!module) |
| 30 return 0; | 31 return 0; |
| 31 | 32 |
| 32 FileIO* file_io = new FileIO(module); | 33 FileIO* file_io = new FileIO(module); |
| 33 return file_io->GetReference(); | 34 return file_io->GetReference(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 bool IsFileIO(PP_Resource resource) { | 37 PP_Bool IsFileIO(PP_Resource resource) { |
| 37 return !!Resource::GetAs<FileIO>(resource); | 38 return BoolToPPBool(!!Resource::GetAs<FileIO>(resource)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 int32_t Open(PP_Resource file_io_id, | 41 int32_t Open(PP_Resource file_io_id, |
| 41 PP_Resource file_ref_id, | 42 PP_Resource file_ref_id, |
| 42 int32_t open_flags, | 43 int32_t open_flags, |
| 43 PP_CompletionCallback callback) { | 44 PP_CompletionCallback callback) { |
| 44 scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id)); | 45 scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id)); |
| 45 if (!file_io) | 46 if (!file_io) |
| 46 return PP_ERROR_BADRESOURCE; | 47 return PP_ERROR_BADRESOURCE; |
| 47 | 48 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 424 |
| 424 void FileIO::ReadWriteCallback(base::PlatformFileError error_code, | 425 void FileIO::ReadWriteCallback(base::PlatformFileError error_code, |
| 425 int bytes_read_or_written) { | 426 int bytes_read_or_written) { |
| 426 if (error_code != base::PLATFORM_FILE_OK) | 427 if (error_code != base::PLATFORM_FILE_OK) |
| 427 RunPendingCallback(PlatformFileErrorToPepperError(error_code)); | 428 RunPendingCallback(PlatformFileErrorToPepperError(error_code)); |
| 428 else | 429 else |
| 429 RunPendingCallback(bytes_read_or_written); | 430 RunPendingCallback(bytes_read_or_written); |
| 430 } | 431 } |
| 431 | 432 |
| 432 } // namespace pepper | 433 } // namespace pepper |
| OLD | NEW |