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

Side by Side Diff: ppapi/proxy/file_io_resource.h

Issue 22646005: Do PPB_FileIO Query and Read in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to final patch. Created 7 years, 4 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
« no previous file with comments | « content/renderer/pepper/pepper_file_io_host.cc ('k') | ppapi/proxy/file_io_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef PPAPI_PROXY_FILE_IO_RESOURCE_H_ 5 #ifndef PPAPI_PROXY_FILE_IO_RESOURCE_H_
6 #define PPAPI_PROXY_FILE_IO_RESOURCE_H_ 6 #define PPAPI_PROXY_FILE_IO_RESOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ppapi/c/private/pp_file_handle.h" 10 #include "ppapi/c/private/pp_file_handle.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 PP_FileHandle* handle, 60 PP_FileHandle* handle,
61 scoped_refptr<TrackedCallback> callback) OVERRIDE; 61 scoped_refptr<TrackedCallback> callback) OVERRIDE;
62 virtual int32_t WillWrite(int64_t offset, 62 virtual int32_t WillWrite(int64_t offset,
63 int32_t bytes_to_write, 63 int32_t bytes_to_write,
64 scoped_refptr<TrackedCallback> callback) OVERRIDE; 64 scoped_refptr<TrackedCallback> callback) OVERRIDE;
65 virtual int32_t WillSetLength( 65 virtual int32_t WillSetLength(
66 int64_t length, 66 int64_t length,
67 scoped_refptr<TrackedCallback> callback) OVERRIDE; 67 scoped_refptr<TrackedCallback> callback) OVERRIDE;
68 68
69 private: 69 private:
70 // Class to perform file query operations across multiple threads.
71 class QueryOp : public base::RefCountedThreadSafe<QueryOp> {
72 public:
73 explicit QueryOp(PP_FileHandle file_handle);
74
75 // Queries the file. Called on the file thread (non-blocking) or the plugin
76 // thread (blocking). This should not be called when we hold the proxy lock.
77 int32_t DoWork();
78
79 const base::PlatformFileInfo& file_info() const { return file_info_; }
80
81 private:
82 friend class base::RefCountedThreadSafe<QueryOp>;
83 ~QueryOp();
84
85 PP_FileHandle file_handle_;
86 base::PlatformFileInfo file_info_;
87 };
88
89 // Class to perform file read operations across multiple threads.
90 class ReadOp : public base::RefCountedThreadSafe<ReadOp> {
91 public:
92 ReadOp(PP_FileHandle file_handle, int64_t offset, int32_t bytes_to_read);
93
94 // Reads the file. Called on the file thread (non-blocking) or the plugin
95 // thread (blocking). This should not be called when we hold the proxy lock.
96 int32_t DoWork();
97
98 char* buffer() const { return buffer_.get(); }
99
100 private:
101 friend class base::RefCountedThreadSafe<ReadOp>;
102 ~ReadOp();
103
104 PP_FileHandle file_handle_;
105 int64_t offset_;
106 int32_t bytes_to_read_;
107 scoped_ptr<char[]> buffer_;
108 };
109
70 int32_t ReadValidated(int64_t offset, 110 int32_t ReadValidated(int64_t offset,
71 int32_t bytes_to_read, 111 int32_t bytes_to_read,
72 const PP_ArrayOutput& array_output, 112 const PP_ArrayOutput& array_output,
73 scoped_refptr<TrackedCallback> callback); 113 scoped_refptr<TrackedCallback> callback);
74 114
75 void CloseFileHandle(); 115 void CloseFileHandle();
76 116
117
118 // Completion tasks for file operations that are done in the plugin.
119 int32_t OnQueryComplete(scoped_refptr<QueryOp> query_op,
120 PP_FileInfo* info,
121 int32_t result);
122 int32_t OnReadComplete(scoped_refptr<ReadOp> read_op,
123 PP_ArrayOutput array_output,
124 int32_t result);
125
77 // Reply message handlers for operations that are done in the host. 126 // Reply message handlers for operations that are done in the host.
78 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback, 127 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback,
79 const ResourceMessageReplyParams& params); 128 const ResourceMessageReplyParams& params);
80 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback, 129 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback,
81 const ResourceMessageReplyParams& params); 130 const ResourceMessageReplyParams& params);
82 void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback,
83 PP_FileInfo* output_info_,
84 const ResourceMessageReplyParams& params,
85 const PP_FileInfo& info);
86 void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback,
87 PP_ArrayOutput array_output,
88 const ResourceMessageReplyParams& params,
89 const std::string& data);
90 void OnPluginMsgRequestOSFileHandleComplete( 131 void OnPluginMsgRequestOSFileHandleComplete(
91 scoped_refptr<TrackedCallback> callback, 132 scoped_refptr<TrackedCallback> callback,
92 PP_FileHandle* output_handle, 133 PP_FileHandle* output_handle,
93 const ResourceMessageReplyParams& params); 134 const ResourceMessageReplyParams& params);
94 135
95 PP_FileHandle file_handle_; 136 PP_FileHandle file_handle_;
96 PP_FileSystemType file_system_type_; 137 PP_FileSystemType file_system_type_;
97 FileIOStateManager state_manager_; 138 FileIOStateManager state_manager_;
98 139
99 DISALLOW_COPY_AND_ASSIGN(FileIOResource); 140 DISALLOW_COPY_AND_ASSIGN(FileIOResource);
100 }; 141 };
101 142
102 } // namespace proxy 143 } // namespace proxy
103 } // namespace ppapi 144 } // namespace ppapi
104 145
105 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ 146 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_file_io_host.cc ('k') | ppapi/proxy/file_io_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698