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

Side by Side Diff: content/child/fileapi/file_system_dispatcher.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Fix typo breaking a bunch of trybot builds, oops Created 4 years, 1 month 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
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 #include "content/child/fileapi/file_system_dispatcher.h" 5 #include "content/child/fileapi/file_system_dispatcher.h"
6 6
7 #include <memory>
8
7 #include "base/callback.h" 9 #include "base/callback.h"
8 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/process/process.h" 12 #include "base/process/process.h"
11 #include "content/child/child_thread_impl.h" 13 #include "content/child/child_thread_impl.h"
12 #include "content/common/fileapi/file_system_messages.h" 14 #include "content/common/fileapi/file_system_messages.h"
13 #include "storage/common/fileapi/file_system_info.h" 15 #include "storage/common/fileapi/file_system_info.h"
14 16
15 namespace content { 17 namespace content {
16 18
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 IPC_END_MESSAGE_MAP() 165 IPC_END_MESSAGE_MAP()
164 return handled; 166 return handled;
165 } 167 }
166 168
167 void FileSystemDispatcher::OpenFileSystem( 169 void FileSystemDispatcher::OpenFileSystem(
168 const GURL& origin_url, 170 const GURL& origin_url,
169 storage::FileSystemType type, 171 storage::FileSystemType type,
170 const OpenFileSystemCallback& success_callback, 172 const OpenFileSystemCallback& success_callback,
171 const StatusCallback& error_callback) { 173 const StatusCallback& error_callback) {
172 int request_id = dispatchers_.Add( 174 int request_id = dispatchers_.Add(
173 CallbackDispatcher::Create(success_callback, error_callback)); 175 std::unique_ptr<CallbackDispatcher>(
danakj 2016/11/18 00:15:33 can you make the Create methods return unique_ptr?
rlanday 2016/11/18 19:32:10 We can make the Create methods return unique_ptr,
danakj 2016/11/18 21:21:13 Ya that's fine inside the Create methods.
176 CallbackDispatcher::Create(success_callback, error_callback)));
174 ChildThreadImpl::current()->Send(new FileSystemHostMsg_OpenFileSystem( 177 ChildThreadImpl::current()->Send(new FileSystemHostMsg_OpenFileSystem(
175 request_id, origin_url, type)); 178 request_id, origin_url, type));
176 } 179 }
177 180
178 void FileSystemDispatcher::ResolveURL( 181 void FileSystemDispatcher::ResolveURL(
179 const GURL& filesystem_url, 182 const GURL& filesystem_url,
180 const ResolveURLCallback& success_callback, 183 const ResolveURLCallback& success_callback,
181 const StatusCallback& error_callback) { 184 const StatusCallback& error_callback) {
182 int request_id = dispatchers_.Add( 185 int request_id = dispatchers_.Add(
183 CallbackDispatcher::Create(success_callback, error_callback)); 186 std::unique_ptr<CallbackDispatcher>(
187 CallbackDispatcher::Create(success_callback, error_callback)));
184 ChildThreadImpl::current()->Send(new FileSystemHostMsg_ResolveURL( 188 ChildThreadImpl::current()->Send(new FileSystemHostMsg_ResolveURL(
185 request_id, filesystem_url)); 189 request_id, filesystem_url));
186 } 190 }
187 191
188 void FileSystemDispatcher::DeleteFileSystem(const GURL& origin_url, 192 void FileSystemDispatcher::DeleteFileSystem(const GURL& origin_url,
189 storage::FileSystemType type, 193 storage::FileSystemType type,
190 const StatusCallback& callback) { 194 const StatusCallback& callback) {
191 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 195 int request_id = dispatchers_.Add(
196 std::unique_ptr<CallbackDispatcher>(
197 CallbackDispatcher::Create(callback)));
192 ChildThreadImpl::current()->Send(new FileSystemHostMsg_DeleteFileSystem( 198 ChildThreadImpl::current()->Send(new FileSystemHostMsg_DeleteFileSystem(
193 request_id, origin_url, type)); 199 request_id, origin_url, type));
194 } 200 }
195 201
196 void FileSystemDispatcher::Move( 202 void FileSystemDispatcher::Move(
197 const GURL& src_path, 203 const GURL& src_path,
198 const GURL& dest_path, 204 const GURL& dest_path,
199 const StatusCallback& callback) { 205 const StatusCallback& callback) {
200 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 206 int request_id = dispatchers_.Add(
207 std::unique_ptr<CallbackDispatcher>(
208 CallbackDispatcher::Create(callback)));
201 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Move( 209 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Move(
202 request_id, src_path, dest_path)); 210 request_id, src_path, dest_path));
203 } 211 }
204 212
205 void FileSystemDispatcher::Copy( 213 void FileSystemDispatcher::Copy(
206 const GURL& src_path, 214 const GURL& src_path,
207 const GURL& dest_path, 215 const GURL& dest_path,
208 const StatusCallback& callback) { 216 const StatusCallback& callback) {
209 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 217 int request_id = dispatchers_.Add(
218 std::unique_ptr<CallbackDispatcher>(
219 CallbackDispatcher::Create(callback)));
210 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Copy( 220 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Copy(
211 request_id, src_path, dest_path)); 221 request_id, src_path, dest_path));
212 } 222 }
213 223
214 void FileSystemDispatcher::Remove( 224 void FileSystemDispatcher::Remove(
215 const GURL& path, 225 const GURL& path,
216 bool recursive, 226 bool recursive,
217 const StatusCallback& callback) { 227 const StatusCallback& callback) {
218 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 228 int request_id = dispatchers_.Add(
229 std::unique_ptr<CallbackDispatcher>(
230 CallbackDispatcher::Create(callback)));
219 ChildThreadImpl::current()->Send( 231 ChildThreadImpl::current()->Send(
220 new FileSystemHostMsg_Remove(request_id, path, recursive)); 232 new FileSystemHostMsg_Remove(request_id, path, recursive));
221 } 233 }
222 234
223 void FileSystemDispatcher::ReadMetadata( 235 void FileSystemDispatcher::ReadMetadata(
224 const GURL& path, 236 const GURL& path,
225 const MetadataCallback& success_callback, 237 const MetadataCallback& success_callback,
226 const StatusCallback& error_callback) { 238 const StatusCallback& error_callback) {
227 int request_id = dispatchers_.Add( 239 int request_id = dispatchers_.Add(
228 CallbackDispatcher::Create(success_callback, error_callback)); 240 std::unique_ptr<CallbackDispatcher>(
241 CallbackDispatcher::Create(success_callback, error_callback)));
229 ChildThreadImpl::current()->Send( 242 ChildThreadImpl::current()->Send(
230 new FileSystemHostMsg_ReadMetadata(request_id, path)); 243 new FileSystemHostMsg_ReadMetadata(request_id, path));
231 } 244 }
232 245
233 void FileSystemDispatcher::CreateFile( 246 void FileSystemDispatcher::CreateFile(
234 const GURL& path, 247 const GURL& path,
235 bool exclusive, 248 bool exclusive,
236 const StatusCallback& callback) { 249 const StatusCallback& callback) {
237 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 250 int request_id = dispatchers_.Add(
251 std::unique_ptr<CallbackDispatcher>(
252 CallbackDispatcher::Create(callback)));
238 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Create( 253 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Create(
239 request_id, path, exclusive, 254 request_id, path, exclusive,
240 false /* is_directory */, false /* recursive */)); 255 false /* is_directory */, false /* recursive */));
241 } 256 }
242 257
243 void FileSystemDispatcher::CreateDirectory( 258 void FileSystemDispatcher::CreateDirectory(
244 const GURL& path, 259 const GURL& path,
245 bool exclusive, 260 bool exclusive,
246 bool recursive, 261 bool recursive,
247 const StatusCallback& callback) { 262 const StatusCallback& callback) {
248 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 263 int request_id = dispatchers_.Add(
264 std::unique_ptr<CallbackDispatcher>(
265 CallbackDispatcher::Create(callback)));
249 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Create( 266 ChildThreadImpl::current()->Send(new FileSystemHostMsg_Create(
250 request_id, path, exclusive, true /* is_directory */, recursive)); 267 request_id, path, exclusive, true /* is_directory */, recursive));
251 } 268 }
252 269
253 void FileSystemDispatcher::Exists( 270 void FileSystemDispatcher::Exists(
254 const GURL& path, 271 const GURL& path,
255 bool is_directory, 272 bool is_directory,
256 const StatusCallback& callback) { 273 const StatusCallback& callback) {
257 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 274 int request_id = dispatchers_.Add(
275 std::unique_ptr<CallbackDispatcher>(
276 CallbackDispatcher::Create(callback)));
258 ChildThreadImpl::current()->Send( 277 ChildThreadImpl::current()->Send(
259 new FileSystemHostMsg_Exists(request_id, path, is_directory)); 278 new FileSystemHostMsg_Exists(request_id, path, is_directory));
260 } 279 }
261 280
262 void FileSystemDispatcher::ReadDirectory( 281 void FileSystemDispatcher::ReadDirectory(
263 const GURL& path, 282 const GURL& path,
264 const ReadDirectoryCallback& success_callback, 283 const ReadDirectoryCallback& success_callback,
265 const StatusCallback& error_callback) { 284 const StatusCallback& error_callback) {
266 int request_id = dispatchers_.Add( 285 int request_id = dispatchers_.Add(
267 CallbackDispatcher::Create(success_callback, error_callback)); 286 std::unique_ptr<CallbackDispatcher>(
287 CallbackDispatcher::Create(success_callback, error_callback)));
268 ChildThreadImpl::current()->Send( 288 ChildThreadImpl::current()->Send(
269 new FileSystemHostMsg_ReadDirectory(request_id, path)); 289 new FileSystemHostMsg_ReadDirectory(request_id, path));
270 } 290 }
271 291
272 void FileSystemDispatcher::Truncate(const GURL& path, 292 void FileSystemDispatcher::Truncate(const GURL& path,
273 int64_t offset, 293 int64_t offset,
274 int* request_id_out, 294 int* request_id_out,
275 const StatusCallback& callback) { 295 const StatusCallback& callback) {
276 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 296 int request_id = dispatchers_.Add(
297 std::unique_ptr<CallbackDispatcher>(
298 CallbackDispatcher::Create(callback)));
277 ChildThreadImpl::current()->Send( 299 ChildThreadImpl::current()->Send(
278 new FileSystemHostMsg_Truncate(request_id, path, offset)); 300 new FileSystemHostMsg_Truncate(request_id, path, offset));
279 301
280 if (request_id_out) 302 if (request_id_out)
281 *request_id_out = request_id; 303 *request_id_out = request_id;
282 } 304 }
283 305
284 void FileSystemDispatcher::Write(const GURL& path, 306 void FileSystemDispatcher::Write(const GURL& path,
285 const std::string& blob_id, 307 const std::string& blob_id,
286 int64_t offset, 308 int64_t offset,
287 int* request_id_out, 309 int* request_id_out,
288 const WriteCallback& success_callback, 310 const WriteCallback& success_callback,
289 const StatusCallback& error_callback) { 311 const StatusCallback& error_callback) {
290 int request_id = dispatchers_.Add( 312 int request_id = dispatchers_.Add(
291 CallbackDispatcher::Create(success_callback, error_callback)); 313 std::unique_ptr<CallbackDispatcher>(
314 CallbackDispatcher::Create(success_callback, error_callback)));
292 ChildThreadImpl::current()->Send( 315 ChildThreadImpl::current()->Send(
293 new FileSystemHostMsg_Write(request_id, path, blob_id, offset)); 316 new FileSystemHostMsg_Write(request_id, path, blob_id, offset));
294 317
295 if (request_id_out) 318 if (request_id_out)
296 *request_id_out = request_id; 319 *request_id_out = request_id;
297 } 320 }
298 321
299 void FileSystemDispatcher::Cancel( 322 void FileSystemDispatcher::Cancel(
300 int request_id_to_cancel, 323 int request_id_to_cancel,
301 const StatusCallback& callback) { 324 const StatusCallback& callback) {
302 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 325 int request_id = dispatchers_.Add(
326 std::unique_ptr<CallbackDispatcher>(
327 CallbackDispatcher::Create(callback)));
303 ChildThreadImpl::current()->Send(new FileSystemHostMsg_CancelWrite( 328 ChildThreadImpl::current()->Send(new FileSystemHostMsg_CancelWrite(
304 request_id, request_id_to_cancel)); 329 request_id, request_id_to_cancel));
305 } 330 }
306 331
307 void FileSystemDispatcher::TouchFile( 332 void FileSystemDispatcher::TouchFile(
308 const GURL& path, 333 const GURL& path,
309 const base::Time& last_access_time, 334 const base::Time& last_access_time,
310 const base::Time& last_modified_time, 335 const base::Time& last_modified_time,
311 const StatusCallback& callback) { 336 const StatusCallback& callback) {
312 int request_id = dispatchers_.Add(CallbackDispatcher::Create(callback)); 337 int request_id = dispatchers_.Add(
338 std::unique_ptr<CallbackDispatcher>(
339 CallbackDispatcher::Create(callback)));
313 ChildThreadImpl::current()->Send( 340 ChildThreadImpl::current()->Send(
314 new FileSystemHostMsg_TouchFile( 341 new FileSystemHostMsg_TouchFile(
315 request_id, path, last_access_time, last_modified_time)); 342 request_id, path, last_access_time, last_modified_time));
316 } 343 }
317 344
318 void FileSystemDispatcher::CreateSnapshotFile( 345 void FileSystemDispatcher::CreateSnapshotFile(
319 const GURL& file_path, 346 const GURL& file_path,
320 const CreateSnapshotFileCallback& success_callback, 347 const CreateSnapshotFileCallback& success_callback,
321 const StatusCallback& error_callback) { 348 const StatusCallback& error_callback) {
322 int request_id = dispatchers_.Add( 349 int request_id = dispatchers_.Add(
323 CallbackDispatcher::Create(success_callback, error_callback)); 350 std::unique_ptr<CallbackDispatcher>(
351 CallbackDispatcher::Create(success_callback, error_callback)));
324 ChildThreadImpl::current()->Send( 352 ChildThreadImpl::current()->Send(
325 new FileSystemHostMsg_CreateSnapshotFile( 353 new FileSystemHostMsg_CreateSnapshotFile(
326 request_id, file_path)); 354 request_id, file_path));
327 } 355 }
328 356
329 void FileSystemDispatcher::OnDidOpenFileSystem(int request_id, 357 void FileSystemDispatcher::OnDidOpenFileSystem(int request_id,
330 const std::string& name, 358 const std::string& name,
331 const GURL& root) { 359 const GURL& root) {
332 DCHECK(root.is_valid()); 360 DCHECK(root.is_valid());
333 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 361 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 int64_t bytes, 422 int64_t bytes,
395 bool complete) { 423 bool complete) {
396 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); 424 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
397 DCHECK(dispatcher); 425 DCHECK(dispatcher);
398 dispatcher->DidWrite(bytes, complete); 426 dispatcher->DidWrite(bytes, complete);
399 if (complete) 427 if (complete)
400 dispatchers_.Remove(request_id); 428 dispatchers_.Remove(request_id);
401 } 429 }
402 430
403 } // namespace content 431 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698