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

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 // PPB_FileIO_Shared implementations.
66 virtual int32_t OpenValidated(PP_Resource file_ref_resource,
67 thunk::PPB_FileRef_API* file_ref_api,
68 int32_t open_flags) OVERRIDE;
69 virtual int32_t QueryValidated() OVERRIDE;
70 virtual int32_t TouchValidated(PP_Time last_access_time,
71 PP_Time last_modified_time) OVERRIDE;
72 virtual int32_t ReadValidated(int64_t offset,
73 int32_t bytes_to_read) OVERRIDE;
74 virtual int32_t WriteValidated(int64_t offset,
75 const char* buffer,
76 int32_t bytes_to_write) OVERRIDE;
77 virtual int32_t SetLengthValidated(int64_t length) OVERRIDE;
78 virtual int32_t FlushValidated() OVERRIDE;
79
80 // Handlers of reply messages. Note that all of them have a callback
81 // parameters bound when call to the host.
82 void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback,
83 const ResourceMessageReplyParams& params);
84 void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback,
85 const ResourceMessageReplyParams& params);
86 void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback,
87 PP_FileInfo* output_info_,
88 const ResourceMessageReplyParams& params,
89 const PP_FileInfo& info);
90 void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback,
91 PP_ArrayOutput array_output,
92 const ResourceMessageReplyParams& params,
93 const std::string& data);
94
95 // Temporary variables just to pass from "OP" (e.g. Open) to "{OP}Validated"
96 // (e.g. QueryValidated). These are short-living data and must be copied in
97 // {OP}Validated immediately. In fact, they are copied to the closure of
98 // OnPluginMsg* handler via Bind.
99 PP_ArrayOutput temp_array_output_;
100 PP_FileInfo* temp_info_;
101 scoped_refptr<TrackedCallback> temp_callback_;
102 };
103
104 } // namespace proxy
105 } // namespace ppapi
106
107 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698