summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppb_flash_file_proxy.h
blob: b0ebb6329c92fb52ba2565cef48c94303842e2da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_PPB_FLASH_FILE_PROXY_H_
#define PPAPI_PPB_FLASH_FILE_PROXY_H_

#include <string>
#include <vector>

#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/proxy/interface_proxy.h"

struct PP_FileInfo;
struct PPB_Flash_File_FileRef;
struct PPB_Flash_File_ModuleLocal;

namespace ppapi {

class HostResource;

namespace proxy {

struct SerializedDirEntry;

class PPB_Flash_File_ModuleLocal_Proxy : public InterfaceProxy {
 public:
  PPB_Flash_File_ModuleLocal_Proxy(Dispatcher* dispatcher);
  virtual ~PPB_Flash_File_ModuleLocal_Proxy();

  static const Info* GetInfo();

  // InterfaceProxy implementation.
  virtual bool OnMessageReceived(const IPC::Message& msg);

 private:
  // Message handlers.
  void OnMsgOpenFile(PP_Instance instance,
                     const std::string& path,
                     int32_t mode,
                     IPC::PlatformFileForTransit* file_handle,
                     int32_t* result);
  void OnMsgRenameFile(PP_Instance instance,
                       const std::string& path_from,
                       const std::string& path_to,
                       int32_t* result);
  void OnMsgDeleteFileOrDir(PP_Instance instance,
                            const std::string& path,
                            PP_Bool recursive,
                            int32_t* result);
  void OnMsgCreateDir(PP_Instance instance,
                      const std::string& path,
                      int32_t* result);
  void OnMsgQueryFile(PP_Instance instance,
                      const std::string& path,
                      PP_FileInfo* info,
                      int32_t* result);
  void OnMsgGetDirContents(PP_Instance instance,
                           const std::string& path,
                           std::vector<SerializedDirEntry>* entries,
                           int32_t* result);

  // When this proxy is in the host side, this value caches the interface
  // pointer so we don't have to retrieve it from the dispatcher each time.
  // In the plugin, this value is always NULL.
  const PPB_Flash_File_ModuleLocal* ppb_flash_file_module_local_impl_;

  DISALLOW_COPY_AND_ASSIGN(PPB_Flash_File_ModuleLocal_Proxy);
};

class PPB_Flash_File_FileRef_Proxy : public InterfaceProxy {
 public:
  PPB_Flash_File_FileRef_Proxy(Dispatcher* dispatcher);
  virtual ~PPB_Flash_File_FileRef_Proxy();

  static const Info* GetInfo();

  // InterfaceProxy implementation.
  virtual bool OnMessageReceived(const IPC::Message& msg);

 private:
  // Message handlers.
  void OnMsgOpenFile(const ppapi::HostResource& host_resource,
                     int32_t mode,
                     IPC::PlatformFileForTransit* file_handle,
                     int32_t* result);
  void OnMsgQueryFile(const ppapi::HostResource& host_resource,
                      PP_FileInfo* info,
                      int32_t* result);

  // When this proxy is in the host side, this value caches the interface
  // pointer so we don't have to retrieve it from the dispatcher each time.
  // In the plugin, this value is always NULL.
  const PPB_Flash_File_FileRef* ppb_flash_file_fileref_impl_;

  DISALLOW_COPY_AND_ASSIGN(PPB_Flash_File_FileRef_Proxy);
};

}  // namespace proxy
}  // namespace ppapi

#endif  // PPAPI_PPB_FLASH_FILE_PROXY_H_