OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_PROXY_DIRECTORY_READER_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_DIRECTORY_READER_RESOURCE_H_ |
| 7 |
| 8 #include <queue> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "ppapi/proxy/plugin_resource.h" |
| 14 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 15 #include "ppapi/shared_impl/ppb_file_ref_shared.h" |
| 16 #include "ppapi/shared_impl/resource.h" |
| 17 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 18 #include "ppapi/thunk/ppb_directory_reader_api.h" |
| 19 |
| 20 namespace ppapi { |
| 21 |
| 22 class TrackedCallback; |
| 23 |
| 24 namespace proxy { |
| 25 |
| 26 class PPAPI_PROXY_EXPORT DirectoryReaderResource |
| 27 : public PluginResource, |
| 28 public NON_EXPORTED_BASE(thunk::PPB_DirectoryReader_API) { |
| 29 public: |
| 30 DirectoryReaderResource(Connection connection, |
| 31 PP_Instance instance, |
| 32 PP_Resource directory_ref); |
| 33 virtual ~DirectoryReaderResource(); |
| 34 |
| 35 // Resource overrides. |
| 36 virtual thunk::PPB_DirectoryReader_API* AsPPB_DirectoryReader_API() OVERRIDE; |
| 37 |
| 38 // PPB_DirectoryReader_API. |
| 39 virtual int32_t GetNextEntry( |
| 40 PP_DirectoryEntry_Dev* entry, |
| 41 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 42 |
| 43 private: |
| 44 struct DirectoryEntry { |
| 45 ScopedPPResource file_resource; |
| 46 PP_FileType file_type; |
| 47 }; |
| 48 |
| 49 void OnPluginMsgGetEntriesReply( |
| 50 const ResourceMessageReplyParams& params, |
| 51 const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, |
| 52 const std::vector<PP_FileType>& file_types); |
| 53 |
| 54 // Fills up an output with the next entry in the directory. If the plugin |
| 55 // resource did not receive directory entries from the host side, returns |
| 56 // false. |
| 57 bool FillUpEntry(); |
| 58 |
| 59 scoped_refptr<Resource> directory_resource_; |
| 60 std::queue<DirectoryEntry> entries_; |
| 61 |
| 62 PP_DirectoryEntry_Dev* output_; |
| 63 bool did_receive_get_entries_reply_; |
| 64 |
| 65 scoped_refptr<TrackedCallback> callback_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(DirectoryReaderResource); |
| 68 }; |
| 69 |
| 70 } // namespace proxy |
| 71 } // namespace ppapi |
| 72 |
| 73 #endif // PPAPI_PROXY_DIRECTORY_READER_RESOURCE_H_ |
OLD | NEW |