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

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

Issue 1864293002: Convert //ppapi to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nullptr Created 4 years, 8 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
« no previous file with comments | « ppapi/proxy/dispatcher.h ('k') | ppapi/proxy/file_io_resource.cc » ('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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 12
12 #include "base/files/file.h" 13 #include "base/files/file.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "ppapi/c/private/pp_file_handle.h" 16 #include "ppapi/c/private/pp_file_handle.h"
17 #include "ppapi/proxy/connection.h" 17 #include "ppapi/proxy/connection.h"
18 #include "ppapi/proxy/plugin_resource.h" 18 #include "ppapi/proxy/plugin_resource.h"
19 #include "ppapi/proxy/ppapi_proxy_export.h" 19 #include "ppapi/proxy/ppapi_proxy_export.h"
20 #include "ppapi/shared_impl/file_io_state_manager.h" 20 #include "ppapi/shared_impl/file_io_state_manager.h"
21 #include "ppapi/shared_impl/resource.h" 21 #include "ppapi/shared_impl/resource.h"
22 #include "ppapi/shared_impl/scoped_pp_resource.h" 22 #include "ppapi/shared_impl/scoped_pp_resource.h"
23 #include "ppapi/thunk/ppb_file_io_api.h" 23 #include "ppapi/thunk/ppb_file_io_api.h"
24 24
25 namespace ppapi { 25 namespace ppapi {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 char* buffer() const { return buffer_.get(); } 141 char* buffer() const { return buffer_.get(); }
142 142
143 private: 143 private:
144 friend class base::RefCountedThreadSafe<ReadOp>; 144 friend class base::RefCountedThreadSafe<ReadOp>;
145 ~ReadOp(); 145 ~ReadOp();
146 146
147 scoped_refptr<FileHolder> file_holder_; 147 scoped_refptr<FileHolder> file_holder_;
148 int64_t offset_; 148 int64_t offset_;
149 int32_t bytes_to_read_; 149 int32_t bytes_to_read_;
150 scoped_ptr<char[]> buffer_; 150 std::unique_ptr<char[]> buffer_;
151 }; 151 };
152 152
153 // Class to perform file write operations across multiple threads. 153 // Class to perform file write operations across multiple threads.
154 class WriteOp : public base::RefCountedThreadSafe<WriteOp> { 154 class WriteOp : public base::RefCountedThreadSafe<WriteOp> {
155 public: 155 public:
156 WriteOp(scoped_refptr<FileHolder> file_holder, 156 WriteOp(scoped_refptr<FileHolder> file_holder,
157 int64_t offset, 157 int64_t offset,
158 scoped_ptr<char[]> buffer, 158 std::unique_ptr<char[]> buffer,
159 int32_t bytes_to_write, 159 int32_t bytes_to_write,
160 bool append); 160 bool append);
161 161
162 // Writes the file. Called on the file thread (non-blocking) or the plugin 162 // Writes the file. Called on the file thread (non-blocking) or the plugin
163 // thread (blocking). This should not be called when we hold the proxy lock. 163 // thread (blocking). This should not be called when we hold the proxy lock.
164 int32_t DoWork(); 164 int32_t DoWork();
165 165
166 private: 166 private:
167 friend class base::RefCountedThreadSafe<WriteOp>; 167 friend class base::RefCountedThreadSafe<WriteOp>;
168 ~WriteOp(); 168 ~WriteOp();
169 169
170 scoped_refptr<FileHolder> file_holder_; 170 scoped_refptr<FileHolder> file_holder_;
171 int64_t offset_; 171 int64_t offset_;
172 scoped_ptr<char[]> buffer_; 172 std::unique_ptr<char[]> buffer_;
173 int32_t bytes_to_write_; 173 int32_t bytes_to_write_;
174 bool append_; 174 bool append_;
175 }; 175 };
176 176
177 void OnRequestWriteQuotaComplete(int64_t offset, 177 void OnRequestWriteQuotaComplete(int64_t offset,
178 scoped_ptr<char[]> buffer, 178 std::unique_ptr<char[]> buffer,
179 int32_t bytes_to_write, 179 int32_t bytes_to_write,
180 scoped_refptr<TrackedCallback> callback, 180 scoped_refptr<TrackedCallback> callback,
181 int64_t granted); 181 int64_t granted);
182 void OnRequestSetLengthQuotaComplete(int64_t length, 182 void OnRequestSetLengthQuotaComplete(int64_t length,
183 scoped_refptr<TrackedCallback> callback, 183 scoped_refptr<TrackedCallback> callback,
184 int64_t granted); 184 int64_t granted);
185 185
186 int32_t ReadValidated(int64_t offset, 186 int32_t ReadValidated(int64_t offset,
187 int32_t bytes_to_read, 187 int32_t bytes_to_read,
188 const PP_ArrayOutput& array_output, 188 const PP_ArrayOutput& array_output,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 bool check_quota_; 228 bool check_quota_;
229 bool called_close_; 229 bool called_close_;
230 230
231 DISALLOW_COPY_AND_ASSIGN(FileIOResource); 231 DISALLOW_COPY_AND_ASSIGN(FileIOResource);
232 }; 232 };
233 233
234 } // namespace proxy 234 } // namespace proxy
235 } // namespace ppapi 235 } // namespace ppapi
236 236
237 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_ 237 #endif // PPAPI_PROXY_FILE_IO_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/dispatcher.h ('k') | ppapi/proxy/file_io_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698