Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: content/renderer/pepper/pepper_file_io_host.h

Issue 11941022: Refactor FileIO to the new resource host system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/public/renderer/renderer_ppapi_host.h"
13 #include "ppapi/host/host_message_context.h"
14 #include "ppapi/host/resource_host.h"
15 #include "ppapi/shared_impl/file_io_state_manager.h"
16 #include "ppapi/thunk/ppb_file_ref_api.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h"
18
19 using ppapi::host::ReplyMessageContext;
20 using webkit::ppapi::PluginDelegate;
21
22 namespace webkit {
23 namespace ppapi {
24 class QuotaFileIO;
25 } // namespace ppapi
26 } // namespace webkit
27
28 namespace content {
29
30 class PepperFileIOHost : public ppapi::host::ResourceHost,
31 public base::SupportsWeakPtr<PepperFileIOHost> {
32 public:
33 PepperFileIOHost(RendererPpapiHost* host,
34 PP_Instance instance,
35 PP_Resource resource);
36 virtual ~PepperFileIOHost();
37
38 // ppapi::host::ResourceHost override.
39 virtual int32_t OnResourceMessageReceived(
40 const IPC::Message& msg,
41 ppapi::host::HostMessageContext* context) OVERRIDE;
42
43 private:
44 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
45 PP_Resource file_ref_resource,
46 int32_t open_flags);
47 int32_t OnHostMsgQuery(ppapi::host::HostMessageContext* context);
48 int32_t OnHostMsgTouch(ppapi::host::HostMessageContext* context,
49 PP_Time last_access_time,
50 PP_Time last_modified_time);
51 int32_t OnHostMsgRead(ppapi::host::HostMessageContext* context,
52 int64_t offset,
53 int32_t bytes_to_read);
54 int32_t OnHostMsgWrite(ppapi::host::HostMessageContext* context,
55 int64_t offset,
56 const std::string& buffer);
57 int32_t OnHostMsgSetLength(ppapi::host::HostMessageContext* context,
58 int64_t length);
59 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
60 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
61 // Trusted API.
62 int32_t OnHostMsgGetOSFileDescriptor(
63 ppapi::host::HostMessageContext* context);
64 int32_t OnHostMsgWillWrite(ppapi::host::HostMessageContext* context,
65 int64_t offset,
66 int32_t bytes_to_write);
67 int32_t OnHostMsgWillSetLength(ppapi::host::HostMessageContext* context,
68 int64_t length);
69
70 // Callback handlers. These mostly convert the PlatformFileError to the
71 // PP_Error code and send back the reply. Note that the argument
72 // ReplyMessageContext is copied so that we have a closure containing all
73 // necessary information to reply.
74 void ExecutePlatformGeneralCallback(ReplyMessageContext reply_context,
75 base::PlatformFileError error_code);
76 void ExecutePlatformOpenFileCallback(ReplyMessageContext reply_context,
77 base::PlatformFileError error_code,
78 base::PassPlatformFile file);
79 void ExecutePlatformOpenFileSystemURLCallback(
80 ReplyMessageContext reply_context,
81 base::PlatformFileError error_code,
82 base::PassPlatformFile file,
83 const PluginDelegate::NotifyCloseFileCallback& callback);
84 void ExecutePlatformQueryCallback(ReplyMessageContext reply_context,
85 base::PlatformFileError error_code,
86 const base::PlatformFileInfo& file_info);
87 void ExecutePlatformReadCallback(ReplyMessageContext reply_context,
88 base::PlatformFileError error_code,
89 const char* data, int bytes_read);
90 void ExecutePlatformWriteCallback(ReplyMessageContext reply_context,
91 base::PlatformFileError error_code,
92 int bytes_written);
93 void ExecutePlatformWillWriteCallback(ReplyMessageContext reply_context,
94 base::PlatformFileError error_code,
95 int bytes_written);
96
97 // TODO(victorhsieh): eliminate plugin_delegate_ as it's no longer needed.
98 webkit::ppapi::PluginDelegate* plugin_delegate_; // Not owned.
99
100 base::PlatformFile file_;
101
102 // The file system type specified in the Open() call. This will be
103 // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not
104 // indicate that the open command actually succeeded.
105 PP_FileSystemType file_system_type_;
106
107 // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}.
108 GURL file_system_url_;
109
110 // Callback function for notifying when the file handle is closed.
111 PluginDelegate::NotifyCloseFileCallback notify_close_file_callback_;
112
113 // Pointer to a QuotaFileIO instance, which is valid only while a file
114 // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened.
115 scoped_ptr<webkit::ppapi::QuotaFileIO> quota_file_io_;
116
117 bool is_running_in_process_;
118
119 base::WeakPtrFactory<PepperFileIOHost> weak_factory_;
120
121 ppapi::FileIOStateManager state_manager_;
122
123 DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost);
124 };
125
126 } // namespace content
127
128 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_IO_HOST_H_
129
OLDNEW
« no previous file with comments | « content/renderer/pepper/content_renderer_pepper_host_factory.cc ('k') | content/renderer/pepper/pepper_file_io_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698