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

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

Issue 11419131: Refactor FileIO to the new design (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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
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 PPAPI_PROXY_FILE_IO_RESOURCE_H_
6 #define PPAPI_PROXY_FILE_IO_RESOURCE_H_
7
8 #include "ppapi/proxy/connection.h"
9 #include "ppapi/proxy/plugin_resource.h"
10 #include "ppapi/proxy/ppapi_proxy_export.h"
11 #include "ppapi/shared_impl/ppb_file_io_shared.h"
12 #include "ppapi/thunk/ppb_file_io_api.h"
13
14 namespace ppapi {
15
16 class TrackedCallback;
17
18 namespace proxy {
19
20 class PPAPI_PROXY_EXPORT FileIOResource
21 : public PluginResource,
22 public ppapi::PPB_FileIO_Shared,
23 public thunk::PPB_FileIO_API {
24 public:
25 FileIOResource(Connection connection, PP_Instance instance);
26 virtual ~FileIOResource();
27
28 // Resource overrides.
29 virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE;
30
31 // PPB_FileIO_API implementation.
32 virtual int32_t Open(PP_Resource file_ref,
33 int32_t open_flags,
34 scoped_refptr<TrackedCallback> callback) OVERRIDE;
35 virtual int32_t Query(PP_FileInfo* info,
36 scoped_refptr<TrackedCallback> callback) OVERRIDE;
37 virtual int32_t Touch(PP_Time last_access_time,
38 PP_Time last_modified_time,
39 scoped_refptr<TrackedCallback> callback) OVERRIDE;
40 virtual int32_t Read(int64_t offset,
41 char* buffer,
42 int32_t bytes_to_read,
43 scoped_refptr<TrackedCallback> callback) OVERRIDE;
44 virtual int32_t ReadToArray(int64_t offset,
45 int32_t max_read_length,
46 PP_ArrayOutput* array_output,
47 scoped_refptr<TrackedCallback> callback) OVERRIDE;
48 virtual int32_t Write(int64_t offset,
49 const char* buffer,
50 int32_t bytes_to_write,
51 scoped_refptr<TrackedCallback> callback) OVERRIDE;
52 virtual int32_t SetLength(int64_t length,
53 scoped_refptr<TrackedCallback> callback) OVERRIDE;
54 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
55 virtual void Close() OVERRIDE;
56 virtual int32_t GetOSFileDescriptor() OVERRIDE;
57 virtual int32_t WillWrite(int64_t offset,
58 int32_t bytes_to_write,
59 scoped_refptr<TrackedCallback> callback) OVERRIDE;
60 virtual int32_t WillSetLength(
61 int64_t length,
62 scoped_refptr<TrackedCallback> callback) OVERRIDE;
63
64 private:
65 int32_t OpenValidated(Resource* file_ref_resource,
66 thunk::PPB_FileRef_API* file_ref_api,
67 int32_t open_flags,
68 scoped_refptr<TrackedCallback> callback);
69 int32_t QueryValidated(PP_FileInfo* info,
70 scoped_refptr<TrackedCallback> callback);
71 int32_t TouchValidated(PP_Time last_access_time,
72 PP_Time last_modified_time,
73 scoped_refptr<TrackedCallback> callback);
74 int32_t ReadValidated(int64_t offset,
75 int32_t bytes_to_read,
76 const PP_ArrayOutput& array_output,
77 scoped_refptr<TrackedCallback> callback);
78 int32_t WriteValidated(int64_t offset,
79 const char* buffer,
80 int32_t bytes_to_write,
81 scoped_refptr<TrackedCallback> callback);
82 int32_t SetLengthValidated(int64_t length,
83 scoped_refptr<TrackedCallback> callback);
84 int32_t FlushValidated(scoped_refptr<TrackedCallback> callback);
85
86 // Handlers of reply messages. Note that all of them have a callback
87 // parameters bound when call to the host.
88 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback,
89 const ResourceMessageReplyParams& params);
90 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback,
91 const ResourceMessageReplyParams& params);
92 void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback,
93 PP_FileInfo* output_info_,
94 const ResourceMessageReplyParams& params,
95 const PP_FileInfo& info);
96 void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback,
97 PP_ArrayOutput array_output,
98 const ResourceMessageReplyParams& params,
99 const std::string& data);
100 };
101
102 } // namespace proxy
103 } // namespace ppapi
104
105 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698