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

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. 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
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 share file read state between threads.
71 class ReadData : public base::RefCountedThreadSafe<ReadData> {
72 public:
73 explicit ReadData(int32_t bytes_to_read);
74
75 char* buffer() const { return buffer_.get(); }
76 int32_t bytes_read() const { return bytes_read_; }
77 void set_bytes_read(int32_t bytes_read) { bytes_read_ = bytes_read; }
78
79 private:
80 friend class base::RefCountedThreadSafe<ReadData>;
81 virtual ~ReadData();
82
83 // We can't read directly into the plugin's buffer, since we can't be sure
84 // that the call hasn't already aborted. Read into this buffer instead.
85 scoped_ptr<char[]> buffer_;
86 int32_t bytes_read_;
87 };
88
70 int32_t ReadValidated(int64_t offset, 89 int32_t ReadValidated(int64_t offset,
71 int32_t bytes_to_read, 90 int32_t bytes_to_read,
72 const PP_ArrayOutput& array_output, 91 const PP_ArrayOutput& array_output,
73 scoped_refptr<TrackedCallback> callback); 92 scoped_refptr<TrackedCallback> callback);
74 93
75 void CloseFileHandle(); 94 void CloseFileHandle();
76 95
96 // File tasks. These are called on the file thread (for non-blocking calls)
97 // and on the plugin's thread (for blocking calls).
dmichael (off chromium) 2013/08/09 17:37:42 maybe note that they run without the ProxyLock?
bbudge 2013/08/09 21:43:24 I removed these and put them on the ops classes.
98 void DoQuery();
99 void DoRead(int64_t offset,
100 int32_t bytes_to_read,
101 scoped_refptr<ReadData> read_data);
102
103 void OnFileTaskComplete(scoped_refptr<TrackedCallback> callback);
104
105 // Completion tasks for file operations that are done in the plugin.
106 int32_t OnQueryComplete(PP_FileInfo* info, int32_t result);
107 int32_t OnReadComplete(scoped_refptr<ReadData> read_data,
108 PP_ArrayOutput array_output, int32_t result);
109
77 // Reply message handlers for operations that are done in the host. 110 // Reply message handlers for operations that are done in the host.
78 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback, 111 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback,
79 const ResourceMessageReplyParams& params); 112 const ResourceMessageReplyParams& params);
80 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback, 113 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback,
81 const ResourceMessageReplyParams& params); 114 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( 115 void OnPluginMsgRequestOSFileHandleComplete(
91 scoped_refptr<TrackedCallback> callback, 116 scoped_refptr<TrackedCallback> callback,
92 PP_FileHandle* output_handle, 117 PP_FileHandle* output_handle,
93 const ResourceMessageReplyParams& params); 118 const ResourceMessageReplyParams& params);
94 119
95 PP_FileHandle file_handle_; 120 PP_FileHandle file_handle_;
96 PP_FileSystemType file_system_type_; 121 PP_FileSystemType file_system_type_;
97 FileIOStateManager state_manager_; 122 FileIOStateManager state_manager_;
98 123
124 // Temporary state for Query. These are written by the file thread (for
125 // non-blocking calls) or the plugin's thread (for blocking calls), and read
126 // only on the plugin's thread.
127 base::PlatformFileInfo file_info_;
128 int32_t query_result_;
dmichael (off chromium) 2013/08/09 17:37:42 These aren't *that* big. What about making them pa
bbudge 2013/08/09 21:43:24 Added a QueryOp ref counted class to remove these
129
99 DISALLOW_COPY_AND_ASSIGN(FileIOResource); 130 DISALLOW_COPY_AND_ASSIGN(FileIOResource);
100 }; 131 };
101 132
102 } // namespace proxy 133 } // namespace proxy
103 } // namespace ppapi 134 } // namespace ppapi
104 135
105 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ 136 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698