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

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 30 matching lines...) Expand all
41 #include "modules/filesystem/Entry.h" 41 #include "modules/filesystem/Entry.h"
42 #include "modules/filesystem/EntryBase.h" 42 #include "modules/filesystem/EntryBase.h"
43 #include "modules/filesystem/EntryCallback.h" 43 #include "modules/filesystem/EntryCallback.h"
44 #include "modules/filesystem/ErrorCallback.h" 44 #include "modules/filesystem/ErrorCallback.h"
45 #include "modules/filesystem/FileSystemCallbacks.h" 45 #include "modules/filesystem/FileSystemCallbacks.h"
46 #include "modules/filesystem/MetadataCallback.h" 46 #include "modules/filesystem/MetadataCallback.h"
47 #include "platform/weborigin/SecurityOrigin.h" 47 #include "platform/weborigin/SecurityOrigin.h"
48 #include "public/platform/Platform.h" 48 #include "public/platform/Platform.h"
49 #include "public/platform/WebFileSystem.h" 49 #include "public/platform/WebFileSystem.h"
50 #include "public/platform/WebFileSystemCallbacks.h" 50 #include "public/platform/WebFileSystemCallbacks.h"
51 #include "wtf/OwnPtr.h"
52 #include "wtf/text/StringBuilder.h" 51 #include "wtf/text/StringBuilder.h"
53 #include "wtf/text/TextEncoding.h" 52 #include "wtf/text/TextEncoding.h"
53 #include <memory>
54 54
55 namespace blink { 55 namespace blink {
56 56
57 const char DOMFileSystemBase::persistentPathPrefix[] = "persistent"; 57 const char DOMFileSystemBase::persistentPathPrefix[] = "persistent";
58 const char DOMFileSystemBase::temporaryPathPrefix[] = "temporary"; 58 const char DOMFileSystemBase::temporaryPathPrefix[] = "temporary";
59 const char DOMFileSystemBase::isolatedPathPrefix[] = "isolated"; 59 const char DOMFileSystemBase::isolatedPathPrefix[] = "isolated";
60 const char DOMFileSystemBase::externalPathPrefix[] = "external"; 60 const char DOMFileSystemBase::externalPathPrefix[] = "external";
61 61
62 DOMFileSystemBase::DOMFileSystemBase(ExecutionContext* context, const String& na me, FileSystemType type, const KURL& rootURL) 62 DOMFileSystemBase::DOMFileSystemBase(ExecutionContext* context, const String& na me, FileSystemType type, const KURL& rootURL)
63 : m_context(context) 63 : m_context(context)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 } 216 }
217 217
218 void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* su ccessCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) 218 void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* su ccessCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
219 { 219 {
220 if (!fileSystem()) { 220 if (!fileSystem()) {
221 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 221 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
222 return; 222 return;
223 } 223 }
224 224
225 OwnPtr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::create(success Callback, errorCallback, m_context, this)); 225 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::creat e(successCallback, errorCallback, m_context, this));
226 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 226 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
227 fileSystem()->readMetadata(createFileSystemURL(entry), std::move(callbacks)) ; 227 fileSystem()->readMetadata(createFileSystemURL(entry), std::move(callbacks)) ;
228 } 228 }
229 229
230 static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En tryBase* parent, const String& newName, String& destinationPath) 230 static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En tryBase* parent, const String& newName, String& destinationPath)
231 { 231 {
232 ASSERT(source); 232 ASSERT(source);
233 233
234 if (!parent || !parent->isDirectory()) 234 if (!parent || !parent->isDirectory())
235 return false; 235 return false;
(...skipping 26 matching lines...) Expand all
262 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 262 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
263 return; 263 return;
264 } 264 }
265 265
266 String destinationPath; 266 String destinationPath;
267 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti nationPath)) { 267 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti nationPath)) {
268 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR)); 268 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR));
269 return; 269 return;
270 } 270 }
271 271
272 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal lback, errorCallback, m_context, parent->filesystem(), destinationPath, source-> isDirectory())); 272 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s uccessCallback, errorCallback, m_context, parent->filesystem(), destinationPath, source->isDirectory()));
273 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 273 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
274 274
275 fileSystem()->move(createFileSystemURL(source), parent->filesystem()->create FileSystemURL(destinationPath), std::move(callbacks)); 275 fileSystem()->move(createFileSystemURL(source), parent->filesystem()->create FileSystemURL(destinationPath), std::move(callbacks));
276 } 276 }
277 277
278 void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy nchronousType synchronousType) 278 void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy nchronousType synchronousType)
279 { 279 {
280 if (!fileSystem()) { 280 if (!fileSystem()) {
281 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 281 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
282 return; 282 return;
283 } 283 }
284 284
285 String destinationPath; 285 String destinationPath;
286 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti nationPath)) { 286 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti nationPath)) {
287 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR)); 287 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR));
288 return; 288 return;
289 } 289 }
290 290
291 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal lback, errorCallback, m_context, parent->filesystem(), destinationPath, source-> isDirectory())); 291 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s uccessCallback, errorCallback, m_context, parent->filesystem(), destinationPath, source->isDirectory()));
292 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 292 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
293 293
294 fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->create FileSystemURL(destinationPath), std::move(callbacks)); 294 fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->create FileSystemURL(destinationPath), std::move(callbacks));
295 } 295 }
296 296
297 void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCall back, ErrorCallback* errorCallback, SynchronousType synchronousType) 297 void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCall back, ErrorCallback* errorCallback, SynchronousType synchronousType)
298 { 298 {
299 if (!fileSystem()) { 299 if (!fileSystem()) {
300 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 300 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
301 return; 301 return;
302 } 302 }
303 303
304 ASSERT(entry); 304 ASSERT(entry);
305 // We don't allow calling remove() on the root directory. 305 // We don't allow calling remove() on the root directory.
306 if (entry->fullPath() == String(DOMFilePath::root)) { 306 if (entry->fullPath() == String(DOMFilePath::root)) {
307 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR)); 307 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR));
308 return; 308 return;
309 } 309 }
310 310
311 OwnPtr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCall back, errorCallback, m_context, this)); 311 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(su ccessCallback, errorCallback, m_context, this));
312 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 312 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
313 313
314 fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks)); 314 fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks));
315 } 315 }
316 316
317 void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) 317 void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback* successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType)
318 { 318 {
319 if (!fileSystem()) { 319 if (!fileSystem()) {
320 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 320 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
321 return; 321 return;
322 } 322 }
323 323
324 ASSERT(entry && entry->isDirectory()); 324 ASSERT(entry && entry->isDirectory());
325 // We don't allow calling remove() on the root directory. 325 // We don't allow calling remove() on the root directory.
326 if (entry->fullPath() == String(DOMFilePath::root)) { 326 if (entry->fullPath() == String(DOMFilePath::root)) {
327 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR)); 327 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR));
328 return; 328 return;
329 } 329 }
330 330
331 OwnPtr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCall back, errorCallback, m_context, this)); 331 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(su ccessCallback, errorCallback, m_context, this));
332 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 332 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
333 333
334 fileSystem()->removeRecursively(createFileSystemURL(entry), std::move(callba cks)); 334 fileSystem()->removeRecursively(createFileSystemURL(entry), std::move(callba cks));
335 } 335 }
336 336
337 void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* success Callback, ErrorCallback* errorCallback) 337 void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* success Callback, ErrorCallback* errorCallback)
338 { 338 {
339 if (!fileSystem()) { 339 if (!fileSystem()) {
340 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 340 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
341 return; 341 return;
(...skipping 11 matching lines...) Expand all
353 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 353 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
354 return; 354 return;
355 } 355 }
356 356
357 String absolutePath; 357 String absolutePath;
358 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { 358 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) {
359 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR)); 359 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR));
360 return; 360 return;
361 } 361 }
362 362
363 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal lback, errorCallback, m_context, this, absolutePath, false)); 363 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s uccessCallback, errorCallback, m_context, this, absolutePath, false));
364 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 364 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
365 365
366 if (flags.createFlag()) 366 if (flags.createFlag())
367 fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclus ive(), std::move(callbacks)); 367 fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclus ive(), std::move(callbacks));
368 else 368 else
369 fileSystem()->fileExists(createFileSystemURL(absolutePath), std::move(ca llbacks)); 369 fileSystem()->fileExists(createFileSystemURL(absolutePath), std::move(ca llbacks));
370 } 370 }
371 371
372 void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* er rorCallback, SynchronousType synchronousType) 372 void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path, const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* er rorCallback, SynchronousType synchronousType)
373 { 373 {
374 if (!fileSystem()) { 374 if (!fileSystem()) {
375 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 375 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
376 return; 376 return;
377 } 377 }
378 378
379 String absolutePath; 379 String absolutePath;
380 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { 380 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) {
381 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR)); 381 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA TION_ERR));
382 return; 382 return;
383 } 383 }
384 384
385 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal lback, errorCallback, m_context, this, absolutePath, true)); 385 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s uccessCallback, errorCallback, m_context, this, absolutePath, true));
386 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 386 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
387 387
388 if (flags.createFlag()) 388 if (flags.createFlag())
389 fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.e xclusive(), std::move(callbacks)); 389 fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.e xclusive(), std::move(callbacks));
390 else 390 else
391 fileSystem()->directoryExists(createFileSystemURL(absolutePath), std::mo ve(callbacks)); 391 fileSystem()->directoryExists(createFileSystemURL(absolutePath), std::mo ve(callbacks));
392 } 392 }
393 393
394 int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String& path, EntriesCallback* successCallback, ErrorCallback* errorCallback, Synchronou sType synchronousType) 394 int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String& path, EntriesCallback* successCallback, ErrorCallback* errorCallback, Synchronou sType synchronousType)
395 { 395 {
396 if (!fileSystem()) { 396 if (!fileSystem()) {
397 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); 397 reportError(errorCallback, FileError::create(FileError::ABORT_ERR));
398 return 0; 398 return 0;
399 } 399 }
400 400
401 ASSERT(DOMFilePath::isAbsolute(path)); 401 ASSERT(DOMFilePath::isAbsolute(path));
402 402
403 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create(successC allback, errorCallback, m_context, reader, path)); 403 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create (successCallback, errorCallback, m_context, reader, path));
404 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 404 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
405 405
406 return fileSystem()->readDirectory(createFileSystemURL(path), std::move(call backs)); 406 return fileSystem()->readDirectory(createFileSystemURL(path), std::move(call backs));
407 } 407 }
408 408
409 bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId) 409 bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId)
410 { 410 {
411 if (!fileSystem()) 411 if (!fileSystem())
412 return false; 412 return false;
413 return fileSystem()->waitForAdditionalResult(callbacksId); 413 return fileSystem()->waitForAdditionalResult(callbacksId);
414 } 414 }
415 415
416 } // namespace blink 416 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698