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: content/child/fileapi/webfilesystem_impl.cc

Issue 102603014: FileAPI: Fix memory leak in WebFileSystemImpl (won't commit) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 6 years, 9 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 | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/webfilesystem_impl.h" 5 #include "content/child/fileapi/webfilesystem_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 24 matching lines...) Expand all
35 35
36 namespace content { 36 namespace content {
37 37
38 namespace { 38 namespace {
39 39
40 base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky 40 base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky
41 g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER; 41 g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER;
42 42
43 class WaitableCallbackResults { 43 class WaitableCallbackResults {
44 public: 44 public:
45 static WaitableCallbackResults* MaybeCreate( 45 static scoped_ptr<WaitableCallbackResults> MaybeCreate(
46 const WebFileSystemCallbacks& callbacks) { 46 const WebFileSystemCallbacks& callbacks) {
47 if (callbacks.shouldBlockUntilCompletion()) 47 if (callbacks.shouldBlockUntilCompletion())
48 return new WaitableCallbackResults; 48 return make_scoped_ptr(new WaitableCallbackResults);
49 return NULL; 49 return scoped_ptr<WaitableCallbackResults>();
50 } 50 }
51 ~WaitableCallbackResults() {} 51 ~WaitableCallbackResults() {}
52 52
53 void SetResultsAndSignal(const base::Closure& results_closure) { 53 void SetResultsAndSignal(const base::Closure& results_closure) {
54 results_closure_ = results_closure; 54 results_closure_ = results_closure;
55 event_->Signal(); 55 event_.Signal();
56 } 56 }
57 57
58 void WaitAndRun() { 58 void WaitAndRun() {
59 { 59 {
60 blink::WebHeap::SafePointScope safe_point; 60 blink::WebHeap::SafePointScope safe_point;
61 event_->Wait(); 61 event_.Wait();
62 } 62 }
63 DCHECK(!results_closure_.is_null()); 63 DCHECK(!results_closure_.is_null());
64 results_closure_.Run(); 64 results_closure_.Run();
65 } 65 }
66 66
67 private: 67 private:
68 WaitableCallbackResults() : event_(new base::WaitableEvent(true, false)) {} 68 WaitableCallbackResults() : event_(true, false) {}
69 69
70 base::WaitableEvent* event_; 70 base::WaitableEvent event_;
71 base::Closure results_closure_; 71 base::Closure results_closure_;
72 DISALLOW_COPY_AND_ASSIGN(WaitableCallbackResults); 72 DISALLOW_COPY_AND_ASSIGN(WaitableCallbackResults);
73 }; 73 };
74 74
75 void DidReceiveSnapshotFile(int request_id) { 75 void DidReceiveSnapshotFile(int request_id) {
76 if (ChildThread::current()) 76 if (ChildThread::current())
77 ChildThread::current()->Send( 77 ChildThread::current()->Send(
78 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); 78 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id));
79 } 79 }
80 80
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 WaitableCallbackResults* waitable_results, 191 WaitableCallbackResults* waitable_results,
192 const base::File::Info& file_info) { 192 const base::File::Info& file_info) {
193 WebFileInfo web_file_info; 193 WebFileInfo web_file_info;
194 FileInfoToWebFileInfo(file_info, &web_file_info); 194 FileInfoToWebFileInfo(file_info, &web_file_info);
195 CallbackFileSystemCallbacks( 195 CallbackFileSystemCallbacks(
196 thread_id, callbacks_id, waitable_results, 196 thread_id, callbacks_id, waitable_results,
197 &WebFileSystemCallbacks::didReadMetadata, 197 &WebFileSystemCallbacks::didReadMetadata,
198 MakeTuple(web_file_info)); 198 MakeTuple(web_file_info));
199 } 199 }
200 200
201 void ReadDirectoryCallbackAdapater( 201 void ReadDirectoryCallbackAdapter(
202 int thread_id, int callbacks_id, WaitableCallbackResults* waitable_results, 202 int thread_id, int callbacks_id, WaitableCallbackResults* waitable_results,
203 const std::vector<fileapi::DirectoryEntry>& entries, 203 const std::vector<fileapi::DirectoryEntry>& entries,
204 bool has_more) { 204 bool has_more) {
205 WebVector<WebFileSystemEntry> file_system_entries(entries.size()); 205 WebVector<WebFileSystemEntry> file_system_entries(entries.size());
206 for (size_t i = 0; i < entries.size(); i++) { 206 for (size_t i = 0; i < entries.size(); i++) {
207 file_system_entries[i].name = 207 file_system_entries[i].name =
208 base::FilePath(entries[i].name).AsUTF16Unsafe(); 208 base::FilePath(entries[i].name).AsUTF16Unsafe();
209 file_system_entries[i].isDirectory = entries[i].is_directory; 209 file_system_entries[i].isDirectory = entries[i].is_directory;
210 } 210 }
211 CallbackFileSystemCallbacks( 211 CallbackFileSystemCallbacks(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 325
326 void WebFileSystemImpl::OnWorkerRunLoopStopped() { 326 void WebFileSystemImpl::OnWorkerRunLoopStopped() {
327 delete this; 327 delete this;
328 } 328 }
329 329
330 void WebFileSystemImpl::openFileSystem( 330 void WebFileSystemImpl::openFileSystem(
331 const blink::WebURL& storage_partition, 331 const blink::WebURL& storage_partition,
332 blink::WebFileSystemType type, 332 blink::WebFileSystemType type,
333 WebFileSystemCallbacks callbacks) { 333 WebFileSystemCallbacks callbacks) {
334 int callbacks_id = RegisterCallbacks(callbacks); 334 int callbacks_id = RegisterCallbacks(callbacks);
335 WaitableCallbackResults* waitable_results = 335 scoped_ptr<WaitableCallbackResults> waitable_results =
336 WaitableCallbackResults::MaybeCreate(callbacks); 336 WaitableCallbackResults::MaybeCreate(callbacks);
337 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
337 CallDispatcherOnMainThread( 338 CallDispatcherOnMainThread(
338 main_thread_loop_.get(), 339 main_thread_loop_.get(),
339 &FileSystemDispatcher::OpenFileSystem, 340 &FileSystemDispatcher::OpenFileSystem,
340 MakeTuple(GURL(storage_partition), 341 MakeTuple(GURL(storage_partition),
341 static_cast<fileapi::FileSystemType>(type), 342 static_cast<fileapi::FileSystemType>(type),
342 base::Bind(&OpenFileSystemCallbackAdapter, 343 base::Bind(&OpenFileSystemCallbackAdapter,
343 CurrentWorkerId(), callbacks_id, 344 CurrentWorkerId(), callbacks_id,
344 base::Unretained(waitable_results)), 345 waitable_results_ptr),
345 base::Bind(&StatusCallbackAdapter, 346 base::Bind(&StatusCallbackAdapter,
346 CurrentWorkerId(), callbacks_id, 347 CurrentWorkerId(), callbacks_id,
347 base::Unretained(waitable_results))), 348 waitable_results_ptr)),
348 make_scoped_ptr(waitable_results)); 349 waitable_results.Pass());
349 } 350 }
350 351
351 void WebFileSystemImpl::resolveURL( 352 void WebFileSystemImpl::resolveURL(
352 const blink::WebURL& filesystem_url, 353 const blink::WebURL& filesystem_url,
353 WebFileSystemCallbacks callbacks) { 354 WebFileSystemCallbacks callbacks) {
354 int callbacks_id = RegisterCallbacks(callbacks); 355 int callbacks_id = RegisterCallbacks(callbacks);
355 WaitableCallbackResults* waitable_results = 356 scoped_ptr<WaitableCallbackResults> waitable_results =
356 WaitableCallbackResults::MaybeCreate(callbacks); 357 WaitableCallbackResults::MaybeCreate(callbacks);
358 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
357 CallDispatcherOnMainThread( 359 CallDispatcherOnMainThread(
358 main_thread_loop_.get(), 360 main_thread_loop_.get(),
359 &FileSystemDispatcher::ResolveURL, 361 &FileSystemDispatcher::ResolveURL,
360 MakeTuple(GURL(filesystem_url), 362 MakeTuple(GURL(filesystem_url),
361 base::Bind(&ResolveURLCallbackAdapter, 363 base::Bind(&ResolveURLCallbackAdapter,
362 CurrentWorkerId(), callbacks_id, 364 CurrentWorkerId(), callbacks_id,
363 base::Unretained(waitable_results)), 365 waitable_results_ptr),
364 base::Bind(&StatusCallbackAdapter, 366 base::Bind(&StatusCallbackAdapter,
365 CurrentWorkerId(), callbacks_id, 367 CurrentWorkerId(), callbacks_id,
366 base::Unretained(waitable_results))), 368 waitable_results_ptr)),
367 make_scoped_ptr(waitable_results)); 369 waitable_results.Pass());
368 } 370 }
369 371
370 void WebFileSystemImpl::deleteFileSystem( 372 void WebFileSystemImpl::deleteFileSystem(
371 const blink::WebURL& storage_partition, 373 const blink::WebURL& storage_partition,
372 blink::WebFileSystemType type, 374 blink::WebFileSystemType type,
373 WebFileSystemCallbacks callbacks) { 375 WebFileSystemCallbacks callbacks) {
374 int callbacks_id = RegisterCallbacks(callbacks); 376 int callbacks_id = RegisterCallbacks(callbacks);
375 WaitableCallbackResults* waitable_results = 377 scoped_ptr<WaitableCallbackResults> waitable_results =
376 WaitableCallbackResults::MaybeCreate(callbacks); 378 WaitableCallbackResults::MaybeCreate(callbacks);
379 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
377 CallDispatcherOnMainThread( 380 CallDispatcherOnMainThread(
378 main_thread_loop_.get(), 381 main_thread_loop_.get(),
379 &FileSystemDispatcher::DeleteFileSystem, 382 &FileSystemDispatcher::DeleteFileSystem,
380 MakeTuple(GURL(storage_partition), 383 MakeTuple(GURL(storage_partition),
381 static_cast<fileapi::FileSystemType>(type), 384 static_cast<fileapi::FileSystemType>(type),
382 base::Bind(&StatusCallbackAdapter, 385 base::Bind(&StatusCallbackAdapter,
383 CurrentWorkerId(), callbacks_id, 386 CurrentWorkerId(), callbacks_id,
384 base::Unretained(waitable_results))), 387 waitable_results_ptr)),
385 make_scoped_ptr(waitable_results)); 388 waitable_results.Pass());
386 } 389 }
387 390
388 void WebFileSystemImpl::move( 391 void WebFileSystemImpl::move(
389 const blink::WebURL& src_path, 392 const blink::WebURL& src_path,
390 const blink::WebURL& dest_path, 393 const blink::WebURL& dest_path,
391 WebFileSystemCallbacks callbacks) { 394 WebFileSystemCallbacks callbacks) {
392 int callbacks_id = RegisterCallbacks(callbacks); 395 int callbacks_id = RegisterCallbacks(callbacks);
393 WaitableCallbackResults* waitable_results = 396 scoped_ptr<WaitableCallbackResults> waitable_results =
394 WaitableCallbackResults::MaybeCreate(callbacks); 397 WaitableCallbackResults::MaybeCreate(callbacks);
398 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
395 CallDispatcherOnMainThread( 399 CallDispatcherOnMainThread(
396 main_thread_loop_.get(), 400 main_thread_loop_.get(),
397 &FileSystemDispatcher::Move, 401 &FileSystemDispatcher::Move,
398 MakeTuple(GURL(src_path), GURL(dest_path), 402 MakeTuple(GURL(src_path), GURL(dest_path),
399 base::Bind(&StatusCallbackAdapter, 403 base::Bind(&StatusCallbackAdapter,
400 CurrentWorkerId(), callbacks_id, 404 CurrentWorkerId(), callbacks_id,
401 base::Unretained(waitable_results))), 405 waitable_results_ptr)),
402 make_scoped_ptr(waitable_results)); 406 waitable_results.Pass());
403 } 407 }
404 408
405 void WebFileSystemImpl::copy( 409 void WebFileSystemImpl::copy(
406 const blink::WebURL& src_path, 410 const blink::WebURL& src_path,
407 const blink::WebURL& dest_path, 411 const blink::WebURL& dest_path,
408 WebFileSystemCallbacks callbacks) { 412 WebFileSystemCallbacks callbacks) {
409 int callbacks_id = RegisterCallbacks(callbacks); 413 int callbacks_id = RegisterCallbacks(callbacks);
410 WaitableCallbackResults* waitable_results = 414 scoped_ptr<WaitableCallbackResults> waitable_results =
411 WaitableCallbackResults::MaybeCreate(callbacks); 415 WaitableCallbackResults::MaybeCreate(callbacks);
416 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
412 CallDispatcherOnMainThread( 417 CallDispatcherOnMainThread(
413 main_thread_loop_.get(), 418 main_thread_loop_.get(),
414 &FileSystemDispatcher::Copy, 419 &FileSystemDispatcher::Copy,
415 MakeTuple(GURL(src_path), GURL(dest_path), 420 MakeTuple(GURL(src_path), GURL(dest_path),
416 base::Bind(&StatusCallbackAdapter, 421 base::Bind(&StatusCallbackAdapter,
417 CurrentWorkerId(), callbacks_id, 422 CurrentWorkerId(), callbacks_id,
418 base::Unretained(waitable_results))), 423 waitable_results_ptr)),
419 make_scoped_ptr(waitable_results)); 424 waitable_results.Pass());
420 } 425 }
421 426
422 void WebFileSystemImpl::remove( 427 void WebFileSystemImpl::remove(
423 const blink::WebURL& path, 428 const blink::WebURL& path,
424 WebFileSystemCallbacks callbacks) { 429 WebFileSystemCallbacks callbacks) {
425 int callbacks_id = RegisterCallbacks(callbacks); 430 int callbacks_id = RegisterCallbacks(callbacks);
426 WaitableCallbackResults* waitable_results = 431 scoped_ptr<WaitableCallbackResults> waitable_results =
427 WaitableCallbackResults::MaybeCreate(callbacks); 432 WaitableCallbackResults::MaybeCreate(callbacks);
433 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
428 CallDispatcherOnMainThread( 434 CallDispatcherOnMainThread(
429 main_thread_loop_.get(), 435 main_thread_loop_.get(),
430 &FileSystemDispatcher::Remove, 436 &FileSystemDispatcher::Remove,
431 MakeTuple(GURL(path), false /* recursive */, 437 MakeTuple(GURL(path), false /* recursive */,
432 base::Bind(&StatusCallbackAdapter, 438 base::Bind(&StatusCallbackAdapter,
433 CurrentWorkerId(), callbacks_id, 439 CurrentWorkerId(), callbacks_id,
434 base::Unretained(waitable_results))), 440 waitable_results_ptr)),
435 make_scoped_ptr(waitable_results)); 441 waitable_results.Pass());
436 } 442 }
437 443
438 void WebFileSystemImpl::removeRecursively( 444 void WebFileSystemImpl::removeRecursively(
439 const blink::WebURL& path, 445 const blink::WebURL& path,
440 WebFileSystemCallbacks callbacks) { 446 WebFileSystemCallbacks callbacks) {
441 int callbacks_id = RegisterCallbacks(callbacks); 447 int callbacks_id = RegisterCallbacks(callbacks);
442 WaitableCallbackResults* waitable_results = 448 scoped_ptr<WaitableCallbackResults> waitable_results =
443 WaitableCallbackResults::MaybeCreate(callbacks); 449 WaitableCallbackResults::MaybeCreate(callbacks);
450 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
444 CallDispatcherOnMainThread( 451 CallDispatcherOnMainThread(
445 main_thread_loop_.get(), 452 main_thread_loop_.get(),
446 &FileSystemDispatcher::Remove, 453 &FileSystemDispatcher::Remove,
447 MakeTuple(GURL(path), true /* recursive */, 454 MakeTuple(GURL(path), true /* recursive */,
448 base::Bind(&StatusCallbackAdapter, 455 base::Bind(&StatusCallbackAdapter,
449 CurrentWorkerId(), callbacks_id, 456 CurrentWorkerId(), callbacks_id,
450 base::Unretained(waitable_results))), 457 waitable_results_ptr)),
451 make_scoped_ptr(waitable_results)); 458 waitable_results.Pass());
452 } 459 }
453 460
454 void WebFileSystemImpl::readMetadata( 461 void WebFileSystemImpl::readMetadata(
455 const blink::WebURL& path, 462 const blink::WebURL& path,
456 WebFileSystemCallbacks callbacks) { 463 WebFileSystemCallbacks callbacks) {
457 int callbacks_id = RegisterCallbacks(callbacks); 464 int callbacks_id = RegisterCallbacks(callbacks);
458 WaitableCallbackResults* waitable_results = 465 scoped_ptr<WaitableCallbackResults> waitable_results =
459 WaitableCallbackResults::MaybeCreate(callbacks); 466 WaitableCallbackResults::MaybeCreate(callbacks);
467 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
460 CallDispatcherOnMainThread( 468 CallDispatcherOnMainThread(
461 main_thread_loop_.get(), 469 main_thread_loop_.get(),
462 &FileSystemDispatcher::ReadMetadata, 470 &FileSystemDispatcher::ReadMetadata,
463 MakeTuple(GURL(path), 471 MakeTuple(GURL(path),
464 base::Bind(&ReadMetadataCallbackAdapter, 472 base::Bind(&ReadMetadataCallbackAdapter,
465 CurrentWorkerId(), callbacks_id, 473 CurrentWorkerId(), callbacks_id,
466 base::Unretained(waitable_results)), 474 waitable_results_ptr),
467 base::Bind(&StatusCallbackAdapter, 475 base::Bind(&StatusCallbackAdapter,
468 CurrentWorkerId(), callbacks_id, 476 CurrentWorkerId(), callbacks_id,
469 base::Unretained(waitable_results))), 477 waitable_results_ptr)),
470 make_scoped_ptr(waitable_results)); 478 waitable_results.Pass());
471 } 479 }
472 480
473 void WebFileSystemImpl::createFile( 481 void WebFileSystemImpl::createFile(
474 const blink::WebURL& path, 482 const blink::WebURL& path,
475 bool exclusive, 483 bool exclusive,
476 WebFileSystemCallbacks callbacks) { 484 WebFileSystemCallbacks callbacks) {
477 int callbacks_id = RegisterCallbacks(callbacks); 485 int callbacks_id = RegisterCallbacks(callbacks);
478 WaitableCallbackResults* waitable_results = 486 scoped_ptr<WaitableCallbackResults> waitable_results =
479 WaitableCallbackResults::MaybeCreate(callbacks); 487 WaitableCallbackResults::MaybeCreate(callbacks);
488 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
480 CallDispatcherOnMainThread( 489 CallDispatcherOnMainThread(
481 main_thread_loop_.get(), 490 main_thread_loop_.get(),
482 &FileSystemDispatcher::CreateFile, 491 &FileSystemDispatcher::CreateFile,
483 MakeTuple(GURL(path), exclusive, 492 MakeTuple(GURL(path), exclusive,
484 base::Bind(&StatusCallbackAdapter, 493 base::Bind(&StatusCallbackAdapter,
485 CurrentWorkerId(), callbacks_id, 494 CurrentWorkerId(), callbacks_id,
486 base::Unretained(waitable_results))), 495 waitable_results_ptr)),
487 make_scoped_ptr(waitable_results)); 496 waitable_results.Pass());
488 } 497 }
489 498
490 void WebFileSystemImpl::createDirectory( 499 void WebFileSystemImpl::createDirectory(
491 const blink::WebURL& path, 500 const blink::WebURL& path,
492 bool exclusive, 501 bool exclusive,
493 WebFileSystemCallbacks callbacks) { 502 WebFileSystemCallbacks callbacks) {
494 int callbacks_id = RegisterCallbacks(callbacks); 503 int callbacks_id = RegisterCallbacks(callbacks);
495 WaitableCallbackResults* waitable_results = 504 scoped_ptr<WaitableCallbackResults> waitable_results =
496 WaitableCallbackResults::MaybeCreate(callbacks); 505 WaitableCallbackResults::MaybeCreate(callbacks);
506 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
497 CallDispatcherOnMainThread( 507 CallDispatcherOnMainThread(
498 main_thread_loop_.get(), 508 main_thread_loop_.get(),
499 &FileSystemDispatcher::CreateDirectory, 509 &FileSystemDispatcher::CreateDirectory,
500 MakeTuple(GURL(path), exclusive, false /* recursive */, 510 MakeTuple(GURL(path), exclusive, false /* recursive */,
501 base::Bind(&StatusCallbackAdapter, 511 base::Bind(&StatusCallbackAdapter,
502 CurrentWorkerId(), callbacks_id, 512 CurrentWorkerId(), callbacks_id,
503 base::Unretained(waitable_results))), 513 waitable_results_ptr)),
504 make_scoped_ptr(waitable_results)); 514 waitable_results.Pass());
505 } 515 }
506 516
507 void WebFileSystemImpl::fileExists( 517 void WebFileSystemImpl::fileExists(
508 const blink::WebURL& path, 518 const blink::WebURL& path,
509 WebFileSystemCallbacks callbacks) { 519 WebFileSystemCallbacks callbacks) {
510 int callbacks_id = RegisterCallbacks(callbacks); 520 int callbacks_id = RegisterCallbacks(callbacks);
511 WaitableCallbackResults* waitable_results = 521 scoped_ptr<WaitableCallbackResults> waitable_results =
512 WaitableCallbackResults::MaybeCreate(callbacks); 522 WaitableCallbackResults::MaybeCreate(callbacks);
523 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
513 CallDispatcherOnMainThread( 524 CallDispatcherOnMainThread(
514 main_thread_loop_.get(), 525 main_thread_loop_.get(),
515 &FileSystemDispatcher::Exists, 526 &FileSystemDispatcher::Exists,
516 MakeTuple(GURL(path), false /* directory */, 527 MakeTuple(GURL(path), false /* directory */,
517 base::Bind(&StatusCallbackAdapter, 528 base::Bind(&StatusCallbackAdapter,
518 CurrentWorkerId(), callbacks_id, 529 CurrentWorkerId(), callbacks_id,
519 base::Unretained(waitable_results))), 530 waitable_results_ptr)),
520 make_scoped_ptr(waitable_results)); 531 waitable_results.Pass());
521 } 532 }
522 533
523 void WebFileSystemImpl::directoryExists( 534 void WebFileSystemImpl::directoryExists(
524 const blink::WebURL& path, 535 const blink::WebURL& path,
525 WebFileSystemCallbacks callbacks) { 536 WebFileSystemCallbacks callbacks) {
526 int callbacks_id = RegisterCallbacks(callbacks); 537 int callbacks_id = RegisterCallbacks(callbacks);
527 WaitableCallbackResults* waitable_results = 538 scoped_ptr<WaitableCallbackResults> waitable_results =
528 WaitableCallbackResults::MaybeCreate(callbacks); 539 WaitableCallbackResults::MaybeCreate(callbacks);
540 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
529 CallDispatcherOnMainThread( 541 CallDispatcherOnMainThread(
530 main_thread_loop_.get(), 542 main_thread_loop_.get(),
531 &FileSystemDispatcher::Exists, 543 &FileSystemDispatcher::Exists,
532 MakeTuple(GURL(path), true /* directory */, 544 MakeTuple(GURL(path), true /* directory */,
533 base::Bind(&StatusCallbackAdapter, 545 base::Bind(&StatusCallbackAdapter,
534 CurrentWorkerId(), callbacks_id, 546 CurrentWorkerId(), callbacks_id,
535 base::Unretained(waitable_results))), 547 waitable_results_ptr)),
536 make_scoped_ptr(waitable_results)); 548 waitable_results.Pass());
537 } 549 }
538 550
539 void WebFileSystemImpl::readDirectory( 551 void WebFileSystemImpl::readDirectory(
540 const blink::WebURL& path, 552 const blink::WebURL& path,
541 WebFileSystemCallbacks callbacks) { 553 WebFileSystemCallbacks callbacks) {
542 int callbacks_id = RegisterCallbacks(callbacks); 554 int callbacks_id = RegisterCallbacks(callbacks);
543 WaitableCallbackResults* waitable_results = 555 scoped_ptr<WaitableCallbackResults> waitable_results =
544 WaitableCallbackResults::MaybeCreate(callbacks); 556 WaitableCallbackResults::MaybeCreate(callbacks);
557 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
545 CallDispatcherOnMainThread( 558 CallDispatcherOnMainThread(
546 main_thread_loop_.get(), 559 main_thread_loop_.get(),
547 &FileSystemDispatcher::ReadDirectory, 560 &FileSystemDispatcher::ReadDirectory,
548 MakeTuple(GURL(path), 561 MakeTuple(GURL(path),
549 base::Bind(&ReadDirectoryCallbackAdapater, 562 base::Bind(&ReadDirectoryCallbackAdapter,
550 CurrentWorkerId(), callbacks_id, 563 CurrentWorkerId(), callbacks_id,
551 base::Unretained(waitable_results)), 564 waitable_results_ptr),
552 base::Bind(&StatusCallbackAdapter, 565 base::Bind(&StatusCallbackAdapter,
553 CurrentWorkerId(), callbacks_id, 566 CurrentWorkerId(), callbacks_id,
554 base::Unretained(waitable_results))), 567 waitable_results_ptr)),
555 make_scoped_ptr(waitable_results)); 568 waitable_results.Pass());
556 } 569 }
557 570
558 void WebFileSystemImpl::createFileWriter( 571 void WebFileSystemImpl::createFileWriter(
559 const WebURL& path, 572 const WebURL& path,
560 blink::WebFileWriterClient* client, 573 blink::WebFileWriterClient* client,
561 WebFileSystemCallbacks callbacks) { 574 WebFileSystemCallbacks callbacks) {
562 int callbacks_id = RegisterCallbacks(callbacks); 575 int callbacks_id = RegisterCallbacks(callbacks);
563 WaitableCallbackResults* waitable_results = 576 scoped_ptr<WaitableCallbackResults> waitable_results =
564 WaitableCallbackResults::MaybeCreate(callbacks); 577 WaitableCallbackResults::MaybeCreate(callbacks);
578 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
565 CallDispatcherOnMainThread( 579 CallDispatcherOnMainThread(
566 main_thread_loop_.get(), 580 main_thread_loop_.get(),
567 &FileSystemDispatcher::ReadMetadata, 581 &FileSystemDispatcher::ReadMetadata,
568 MakeTuple(GURL(path), 582 MakeTuple(GURL(path),
569 base::Bind(&CreateFileWriterCallbackAdapter, 583 base::Bind(&CreateFileWriterCallbackAdapter,
570 CurrentWorkerId(), callbacks_id, 584 CurrentWorkerId(), callbacks_id,
571 base::Unretained(waitable_results), 585 waitable_results_ptr,
572 main_thread_loop_, GURL(path), client), 586 main_thread_loop_, GURL(path), client),
573 base::Bind(&StatusCallbackAdapter, 587 base::Bind(&StatusCallbackAdapter,
574 CurrentWorkerId(), callbacks_id, 588 CurrentWorkerId(), callbacks_id,
575 base::Unretained(waitable_results))), 589 waitable_results_ptr)),
576 make_scoped_ptr(waitable_results)); 590 waitable_results.Pass());
577 } 591 }
578 592
579 void WebFileSystemImpl::createSnapshotFileAndReadMetadata( 593 void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
580 const blink::WebURL& path, 594 const blink::WebURL& path,
581 WebFileSystemCallbacks callbacks) { 595 WebFileSystemCallbacks callbacks) {
582 int callbacks_id = RegisterCallbacks(callbacks); 596 int callbacks_id = RegisterCallbacks(callbacks);
583 WaitableCallbackResults* waitable_results = 597 scoped_ptr<WaitableCallbackResults> waitable_results =
584 WaitableCallbackResults::MaybeCreate(callbacks); 598 WaitableCallbackResults::MaybeCreate(callbacks);
599 WaitableCallbackResults* waitable_results_ptr = waitable_results.get();
585 CallDispatcherOnMainThread( 600 CallDispatcherOnMainThread(
586 main_thread_loop_.get(), 601 main_thread_loop_.get(),
587 &FileSystemDispatcher::CreateSnapshotFile, 602 &FileSystemDispatcher::CreateSnapshotFile,
588 MakeTuple(GURL(path), 603 MakeTuple(GURL(path),
589 base::Bind(&CreateSnapshotFileCallbackAdapter, 604 base::Bind(&CreateSnapshotFileCallbackAdapter,
590 CurrentWorkerId(), callbacks_id, 605 CurrentWorkerId(), callbacks_id,
591 base::Unretained(waitable_results), 606 waitable_results_ptr,
592 main_thread_loop_), 607 main_thread_loop_),
593 base::Bind(&StatusCallbackAdapter, 608 base::Bind(&StatusCallbackAdapter,
594 CurrentWorkerId(), callbacks_id, 609 CurrentWorkerId(), callbacks_id,
595 base::Unretained(waitable_results))), 610 waitable_results_ptr)),
596 make_scoped_ptr(waitable_results)); 611 waitable_results.Pass());
597 } 612 }
598 613
599 int WebFileSystemImpl::RegisterCallbacks( 614 int WebFileSystemImpl::RegisterCallbacks(
600 const WebFileSystemCallbacks& callbacks) { 615 const WebFileSystemCallbacks& callbacks) {
601 DCHECK(CalledOnValidThread()); 616 DCHECK(CalledOnValidThread());
602 int id = next_callbacks_id_++; 617 int id = next_callbacks_id_++;
603 callbacks_[id] = callbacks; 618 callbacks_[id] = callbacks;
604 return id; 619 return id;
605 } 620 }
606 621
607 WebFileSystemCallbacks WebFileSystemImpl::GetAndUnregisterCallbacks( 622 WebFileSystemCallbacks WebFileSystemImpl::GetAndUnregisterCallbacks(
608 int callbacks_id) { 623 int callbacks_id) {
609 DCHECK(CalledOnValidThread()); 624 DCHECK(CalledOnValidThread());
610 CallbacksMap::iterator found = callbacks_.find(callbacks_id); 625 CallbacksMap::iterator found = callbacks_.find(callbacks_id);
611 DCHECK(found != callbacks_.end()); 626 DCHECK(found != callbacks_.end());
612 WebFileSystemCallbacks callbacks = found->second; 627 WebFileSystemCallbacks callbacks = found->second;
613 callbacks_.erase(found); 628 callbacks_.erase(found);
614 return callbacks; 629 return callbacks;
615 } 630 }
616 631
617 } // namespace content 632 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698