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

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

Issue 69663002: PPAPI: Implement PPB_FileMapping on POSIX (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix missing return Created 6 years, 10 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 | « ppapi/ppapi_sources.gypi ('k') | ppapi/proxy/file_mapping_resource.h » ('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 "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 private:
73 // FileHandleHolder is used to guarantee that file operations will have a 72 // FileHandleHolder is used to guarantee that file operations will have a
74 // valid FD to operate on, even if they're in a different thread. 73 // valid FD to operate on, even if they're in a different thread.
75 // 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
76 // 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,
77 // 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
78 // (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
79 // 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
80 // wrong file. 79 // wrong file.
81 // 80 //
82 // Operations that run on a background thread should hold one of these to 81 // Operations that run on a background thread should hold one of these to
(...skipping 12 matching lines...) Expand all
95 PP_FileHandle raw_handle() { 94 PP_FileHandle raw_handle() {
96 return raw_handle_; 95 return raw_handle_;
97 } 96 }
98 static bool IsValid( 97 static bool IsValid(
99 const scoped_refptr<FileIOResource::FileHandleHolder>& handle); 98 const scoped_refptr<FileIOResource::FileHandleHolder>& handle);
100 private: 99 private:
101 friend class base::RefCountedThreadSafe<FileHandleHolder>; 100 friend class base::RefCountedThreadSafe<FileHandleHolder>;
102 ~FileHandleHolder(); 101 ~FileHandleHolder();
103 PP_FileHandle raw_handle_; 102 PP_FileHandle raw_handle_;
104 }; 103 };
104 scoped_refptr<FileHandleHolder> file_handle() {
105 return file_handle_;
106 }
105 107
108 private:
106 // Class to perform file query operations across multiple threads. 109 // Class to perform file query operations across multiple threads.
107 class QueryOp : public base::RefCountedThreadSafe<QueryOp> { 110 class QueryOp : public base::RefCountedThreadSafe<QueryOp> {
108 public: 111 public:
109 explicit QueryOp(scoped_refptr<FileHandleHolder> file_handle); 112 explicit QueryOp(scoped_refptr<FileHandleHolder> file_handle);
110 113
111 // Queries the file. Called on the file thread (non-blocking) or the plugin 114 // Queries the file. Called on the file thread (non-blocking) or the plugin
112 // thread (blocking). This should not be called when we hold the proxy lock. 115 // thread (blocking). This should not be called when we hold the proxy lock.
113 int32_t DoWork(); 116 int32_t DoWork();
114 117
115 const base::File::Info& file_info() const { return file_info_; } 118 const base::File::Info& file_info() const { return file_info_; }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool check_quota_; 227 bool check_quota_;
225 bool called_close_; 228 bool called_close_;
226 229
227 DISALLOW_COPY_AND_ASSIGN(FileIOResource); 230 DISALLOW_COPY_AND_ASSIGN(FileIOResource);
228 }; 231 };
229 232
230 } // namespace proxy 233 } // namespace proxy
231 } // namespace ppapi 234 } // namespace ppapi
232 235
233 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ 236 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/ppapi_sources.gypi ('k') | ppapi/proxy/file_mapping_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698