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 CONTENT_RENDERER_PEPPER_PEPPER_DIRECTORY_READER_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_DIRECTORY_READER_HOST_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/files/file_util_proxy.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/common/content_export.h" |
| 15 #include "ppapi/c/pp_file_info.h" |
| 16 #include "ppapi/host/host_message_context.h" |
| 17 #include "ppapi/host/resource_host.h" |
| 18 |
| 19 namespace ppapi { |
| 20 struct PPB_FileRef_CreateInfo; |
| 21 } |
| 22 |
| 23 namespace webkit { |
| 24 namespace ppapi { |
| 25 class PPB_FileRef_Impl; |
| 26 } |
| 27 } |
| 28 |
| 29 namespace content { |
| 30 |
| 31 class RendererPpapiHost; |
| 32 |
| 33 class CONTENT_EXPORT PepperDirectoryReaderHost |
| 34 : public ppapi::host::ResourceHost { |
| 35 public: |
| 36 typedef std::vector<base::FileUtilProxy::Entry> Entries; |
| 37 typedef std::vector<scoped_refptr<webkit::ppapi::PPB_FileRef_Impl> > FileRefs; |
| 38 |
| 39 PepperDirectoryReaderHost(RendererPpapiHost* host, |
| 40 PP_Instance instance, |
| 41 PP_Resource resource); |
| 42 virtual ~PepperDirectoryReaderHost(); |
| 43 |
| 44 virtual int32_t OnResourceMessageReceived( |
| 45 const IPC::Message& msg, |
| 46 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 47 |
| 48 private: |
| 49 int32_t OnGetEntries(ppapi::host::HostMessageContext* host_context, |
| 50 const ppapi::HostResource& resource); |
| 51 void OnReadDirectory(const Entries& entries, bool has_more, int32_t result); |
| 52 bool AddNewEntries(const Entries& entries); |
| 53 |
| 54 // Releases resources which have not been sent to the plugin side. |
| 55 void ReleaseResources(); |
| 56 |
| 57 void SendGetEntriesReply(int32_t result); |
| 58 |
| 59 RendererPpapiHost* renderer_ppapi_host_; |
| 60 ppapi::host::ReplyMessageContext reply_context_; |
| 61 |
| 62 scoped_refptr<webkit::ppapi::PPB_FileRef_Impl> directory_ref_; |
| 63 |
| 64 // Ensures that the resources are alive for as long as the host is. |
| 65 FileRefs file_refs_; |
| 66 |
| 67 std::vector<ppapi::PPB_FileRef_CreateInfo> host_resources_; |
| 68 std::vector<PP_FileType> file_types_; |
| 69 |
| 70 base::WeakPtrFactory<PepperDirectoryReaderHost> weak_factory_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(PepperDirectoryReaderHost); |
| 73 }; |
| 74 |
| 75 } |
| 76 |
| 77 #endif // CONTENT_RENDERER_PEPPER_PEPPER_DIRECTORY_READER_HOST_H_ |
OLD | NEW |