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

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: Rough patch. Starting testing. Created 6 years, 11 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/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 virtual int32_t SetLength(int64_t length, 58 virtual int32_t SetLength(int64_t length,
59 scoped_refptr<TrackedCallback> callback) OVERRIDE; 59 scoped_refptr<TrackedCallback> callback) OVERRIDE;
60 virtual int64_t GetMaxWrittenOffset() const OVERRIDE; 60 virtual int64_t GetMaxWrittenOffset() const OVERRIDE;
61 virtual void SetMaxWrittenOffset(int64_t max_written_offset) OVERRIDE; 61 virtual void SetMaxWrittenOffset(int64_t max_written_offset) OVERRIDE;
62 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE; 62 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
63 virtual void Close() OVERRIDE; 63 virtual void Close() OVERRIDE;
64 virtual int32_t RequestOSFileHandle( 64 virtual int32_t RequestOSFileHandle(
65 PP_FileHandle* handle, 65 PP_FileHandle* handle,
66 scoped_refptr<TrackedCallback> callback) OVERRIDE; 66 scoped_refptr<TrackedCallback> callback) OVERRIDE;
67 67
68 private:
69 // FileHandleHolder is used to guarantee that file operations will have a 68 // FileHandleHolder is used to guarantee that file operations will have a
70 // valid FD to operate on, even if they're in a different thread. 69 // valid FD to operate on, even if they're in a different thread.
71 // If instead we just passed the raw FD, the FD could be closed before the 70 // If instead we just passed the raw FD, the FD could be closed before the
72 // file operation has a chance to run. It could interact with an invalid FD, 71 // file operation has a chance to run. It could interact with an invalid FD,
73 // or worse, the FD value could be reused if another file is opened quickly 72 // or worse, the FD value could be reused if another file is opened quickly
74 // (POSIX is required to provide the lowest available value when opening a 73 // (POSIX is required to provide the lowest available value when opening a
75 // file). This could result in strange problems such as writing data to the 74 // file). This could result in strange problems such as writing data to the
76 // wrong file. 75 // wrong file.
77 // 76 //
78 // Operations that run on a background thread should hold one of these to 77 // Operations that run on a background thread should hold one of these to
(...skipping 12 matching lines...) Expand all
91 PP_FileHandle raw_handle() { 90 PP_FileHandle raw_handle() {
92 return raw_handle_; 91 return raw_handle_;
93 } 92 }
94 static bool IsValid( 93 static bool IsValid(
95 const scoped_refptr<FileIOResource::FileHandleHolder>& handle); 94 const scoped_refptr<FileIOResource::FileHandleHolder>& handle);
96 private: 95 private:
97 friend class base::RefCountedThreadSafe<FileHandleHolder>; 96 friend class base::RefCountedThreadSafe<FileHandleHolder>;
98 ~FileHandleHolder(); 97 ~FileHandleHolder();
99 PP_FileHandle raw_handle_; 98 PP_FileHandle raw_handle_;
100 }; 99 };
100 scoped_refptr<FileHandleHolder> file_handle() {
101 return file_handle_;
102 }
101 103
104 private:
102 // Class to perform file query operations across multiple threads. 105 // Class to perform file query operations across multiple threads.
103 class QueryOp : public base::RefCountedThreadSafe<QueryOp> { 106 class QueryOp : public base::RefCountedThreadSafe<QueryOp> {
104 public: 107 public:
105 explicit QueryOp(scoped_refptr<FileHandleHolder> file_handle); 108 explicit QueryOp(scoped_refptr<FileHandleHolder> file_handle);
106 109
107 // Queries the file. Called on the file thread (non-blocking) or the plugin 110 // Queries the file. Called on the file thread (non-blocking) or the plugin
108 // thread (blocking). This should not be called when we hold the proxy lock. 111 // thread (blocking). This should not be called when we hold the proxy lock.
109 int32_t DoWork(); 112 int32_t DoWork();
110 113
111 const base::PlatformFileInfo& file_info() const { return file_info_; } 114 const base::PlatformFileInfo& file_info() const { return file_info_; }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 bool check_quota_; 222 bool check_quota_;
220 bool called_close_; 223 bool called_close_;
221 224
222 DISALLOW_COPY_AND_ASSIGN(FileIOResource); 225 DISALLOW_COPY_AND_ASSIGN(FileIOResource);
223 }; 226 };
224 227
225 } // namespace proxy 228 } // namespace proxy
226 } // namespace ppapi 229 } // namespace ppapi
227 230
228 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ 231 #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