| 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 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| 11 #include "ppapi/c/dev/ppb_directory_reader_dev.h" | 11 #include "ppapi/c/dev/ppb_directory_reader_dev.h" |
| 12 #include "ppapi/shared_impl/ppapi_globals.h" | 12 #include "ppapi/shared_impl/ppapi_globals.h" |
| 13 #include "ppapi/shared_impl/resource_tracker.h" | 13 #include "ppapi/shared_impl/resource_tracker.h" |
| 14 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
| 15 #include "ppapi/thunk/ppb_file_ref_api.h" | 15 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 16 #include "webkit/plugins/ppapi/common.h" | 16 #include "webkit/plugins/ppapi/common.h" |
| 17 #include "webkit/plugins/ppapi/file_callbacks.h" | 17 #include "webkit/plugins/ppapi/file_callbacks.h" |
| 18 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 19 #include "webkit/plugins/ppapi/plugin_module.h" | 19 #include "webkit/plugins/ppapi/plugin_module.h" |
| 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 21 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 21 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 22 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 22 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
| 23 #include "webkit/plugins/ppapi/resource_helper.h" | 23 #include "webkit/plugins/ppapi/resource_helper.h" |
| 24 | 24 |
| 25 using ::ppapi::PpapiGlobals; | 25 using ::ppapi::PpapiGlobals; |
| 26 using ::ppapi::TrackedCallback; |
| 26 using ::ppapi::thunk::EnterResourceNoLock; | 27 using ::ppapi::thunk::EnterResourceNoLock; |
| 27 using ::ppapi::thunk::PPB_DirectoryReader_API; | 28 using ::ppapi::thunk::PPB_DirectoryReader_API; |
| 28 using ::ppapi::thunk::PPB_FileRef_API; | 29 using ::ppapi::thunk::PPB_FileRef_API; |
| 29 | 30 |
| 30 namespace webkit { | 31 namespace webkit { |
| 31 namespace ppapi { | 32 namespace ppapi { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 std::string FilePathStringToUTF8String(const FilePath::StringType& str) { | 36 std::string FilePathStringToUTF8String(const FilePath::StringType& str) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return (new PPB_DirectoryReader_Impl( | 74 return (new PPB_DirectoryReader_Impl( |
| 74 static_cast<PPB_FileRef_Impl*>(enter.object())))->GetReference(); | 75 static_cast<PPB_FileRef_Impl*>(enter.object())))->GetReference(); |
| 75 } | 76 } |
| 76 | 77 |
| 77 PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() { | 78 PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() { |
| 78 return this; | 79 return this; |
| 79 } | 80 } |
| 80 | 81 |
| 81 int32_t PPB_DirectoryReader_Impl::GetNextEntry( | 82 int32_t PPB_DirectoryReader_Impl::GetNextEntry( |
| 82 PP_DirectoryEntry_Dev* entry, | 83 PP_DirectoryEntry_Dev* entry, |
| 83 PP_CompletionCallback callback) { | 84 scoped_refptr<TrackedCallback> callback) { |
| 84 if (!callback.func) | |
| 85 return PP_ERROR_BLOCKS_MAIN_THREAD; | |
| 86 if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) | 85 if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) |
| 87 return PP_ERROR_FAILED; | 86 return PP_ERROR_FAILED; |
| 88 | 87 |
| 89 entry_ = entry; | 88 entry_ = entry; |
| 90 if (FillUpEntry()) { | 89 if (FillUpEntry()) { |
| 91 entry_ = NULL; | 90 entry_ = NULL; |
| 92 return PP_OK; | 91 return PP_OK; |
| 93 } | 92 } |
| 94 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 93 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 95 if (!plugin_instance) | 94 if (!plugin_instance) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (!has_more_) { | 147 if (!has_more_) { |
| 149 entry_->file_ref = 0; | 148 entry_->file_ref = 0; |
| 150 return true; | 149 return true; |
| 151 } | 150 } |
| 152 | 151 |
| 153 return false; | 152 return false; |
| 154 } | 153 } |
| 155 | 154 |
| 156 } // namespace ppapi | 155 } // namespace ppapi |
| 157 } // namespace webkit | 156 } // namespace webkit |
| OLD | NEW |