OLD | NEW |
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 "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace proxy { | 26 namespace proxy { |
27 | 27 |
28 class PPAPI_PROXY_EXPORT FileIOResource | 28 class PPAPI_PROXY_EXPORT FileIOResource |
29 : public PluginResource, | 29 : public PluginResource, |
30 public thunk::PPB_FileIO_API { | 30 public thunk::PPB_FileIO_API { |
31 public: | 31 public: |
32 FileIOResource(Connection connection, PP_Instance instance); | 32 FileIOResource(Connection connection, PP_Instance instance); |
33 virtual ~FileIOResource(); | 33 virtual ~FileIOResource(); |
34 | 34 |
35 // Resource overrides. | 35 // Resource overrides. |
36 virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; | 36 virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() override; |
37 | 37 |
38 // PPB_FileIO_API implementation. | 38 // PPB_FileIO_API implementation. |
39 virtual int32_t Open(PP_Resource file_ref, | 39 virtual int32_t Open(PP_Resource file_ref, |
40 int32_t open_flags, | 40 int32_t open_flags, |
41 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 41 scoped_refptr<TrackedCallback> callback) override; |
42 virtual int32_t Query(PP_FileInfo* info, | 42 virtual int32_t Query(PP_FileInfo* info, |
43 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 43 scoped_refptr<TrackedCallback> callback) override; |
44 virtual int32_t Touch(PP_Time last_access_time, | 44 virtual int32_t Touch(PP_Time last_access_time, |
45 PP_Time last_modified_time, | 45 PP_Time last_modified_time, |
46 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 46 scoped_refptr<TrackedCallback> callback) override; |
47 virtual int32_t Read(int64_t offset, | 47 virtual int32_t Read(int64_t offset, |
48 char* buffer, | 48 char* buffer, |
49 int32_t bytes_to_read, | 49 int32_t bytes_to_read, |
50 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 50 scoped_refptr<TrackedCallback> callback) override; |
51 virtual int32_t ReadToArray(int64_t offset, | 51 virtual int32_t ReadToArray(int64_t offset, |
52 int32_t max_read_length, | 52 int32_t max_read_length, |
53 PP_ArrayOutput* array_output, | 53 PP_ArrayOutput* array_output, |
54 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 54 scoped_refptr<TrackedCallback> callback) override; |
55 virtual int32_t Write(int64_t offset, | 55 virtual int32_t Write(int64_t offset, |
56 const char* buffer, | 56 const char* buffer, |
57 int32_t bytes_to_write, | 57 int32_t bytes_to_write, |
58 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 58 scoped_refptr<TrackedCallback> callback) override; |
59 virtual int32_t SetLength(int64_t length, | 59 virtual int32_t SetLength(int64_t length, |
60 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 60 scoped_refptr<TrackedCallback> callback) override; |
61 virtual int64_t GetMaxWrittenOffset() const OVERRIDE; | 61 virtual int64_t GetMaxWrittenOffset() const override; |
62 virtual int64_t GetAppendModeWriteAmount() const OVERRIDE; | 62 virtual int64_t GetAppendModeWriteAmount() const override; |
63 virtual void SetMaxWrittenOffset(int64_t max_written_offset) OVERRIDE; | 63 virtual void SetMaxWrittenOffset(int64_t max_written_offset) override; |
64 virtual void SetAppendModeWriteAmount( | 64 virtual void SetAppendModeWriteAmount( |
65 int64_t append_mode_write_amount) OVERRIDE; | 65 int64_t append_mode_write_amount) override; |
66 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE; | 66 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) override; |
67 virtual void Close() OVERRIDE; | 67 virtual void Close() override; |
68 virtual int32_t RequestOSFileHandle( | 68 virtual int32_t RequestOSFileHandle( |
69 PP_FileHandle* handle, | 69 PP_FileHandle* handle, |
70 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 70 scoped_refptr<TrackedCallback> callback) override; |
71 | 71 |
72 // FileHolder is used to guarantee that file operations will have a valid FD | 72 // FileHolder is used to guarantee that file operations will have a valid FD |
73 // to operate on, even if they're in a different thread. | 73 // to operate on, even if they're in a different thread. |
74 // If instead we just passed the raw FD, the FD could be closed before the | 74 // If instead we just passed the raw FD, the FD could be closed before the |
75 // file operation has a chance to run. It could interact with an invalid FD, | 75 // file operation has a chance to run. It could interact with an invalid FD, |
76 // or worse, the FD value could be reused if another file is opened quickly | 76 // or worse, the FD value could be reused if another file is opened quickly |
77 // (POSIX is required to provide the lowest available value when opening a | 77 // (POSIX is required to provide the lowest available value when opening a |
78 // file). This could result in strange problems such as writing data to the | 78 // file). This could result in strange problems such as writing data to the |
79 // wrong file. | 79 // wrong file. |
80 // | 80 // |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 bool check_quota_; | 227 bool check_quota_; |
228 bool called_close_; | 228 bool called_close_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(FileIOResource); | 230 DISALLOW_COPY_AND_ASSIGN(FileIOResource); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace proxy | 233 } // namespace proxy |
234 } // namespace ppapi | 234 } // namespace ppapi |
235 | 235 |
236 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ | 236 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ |
OLD | NEW |