| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "content/child/child_thread_impl.h" | 17 #include "content/child/child_thread_impl.h" |
| 18 #include "content/child/file_info_util.h" | 18 #include "content/child/file_info_util.h" |
| 19 #include "content/child/fileapi/file_system_dispatcher.h" | 19 #include "content/child/fileapi/file_system_dispatcher.h" |
| 20 #include "content/child/fileapi/webfilewriter_impl.h" | 20 #include "content/child/fileapi/webfilewriter_impl.h" |
| 21 #include "content/common/fileapi/file_system_messages.h" | 21 #include "content/common/fileapi/file_system_messages.h" |
| 22 #include "storage/common/fileapi/directory_entry.h" | 22 #include "storage/common/fileapi/directory_entry.h" |
| 23 #include "storage/common/fileapi/file_system_util.h" | 23 #include "storage/common/fileapi/file_system_util.h" |
| 24 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 24 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
| 25 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" | 25 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" |
| 26 #include "third_party/WebKit/public/platform/WebString.h" | 26 #include "third_party/WebKit/public/platform/WebString.h" |
| 27 #include "third_party/WebKit/public/platform/WebURL.h" | 27 #include "third_party/WebKit/public/platform/WebURL.h" |
| 28 #include "third_party/WebKit/public/web/WebHeap.h" | |
| 29 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 30 | 29 |
| 31 using base::MakeTuple; | 30 using base::MakeTuple; |
| 32 using blink::WebFileInfo; | 31 using blink::WebFileInfo; |
| 33 using blink::WebFileSystemCallbacks; | 32 using blink::WebFileSystemCallbacks; |
| 34 using blink::WebFileSystemEntry; | 33 using blink::WebFileSystemEntry; |
| 35 using blink::WebString; | 34 using blink::WebString; |
| 36 using blink::WebURL; | 35 using blink::WebURL; |
| 37 using blink::WebVector; | 36 using blink::WebVector; |
| 38 | 37 |
| 39 namespace content { | 38 namespace content { |
| 40 | 39 |
| 41 class WebFileSystemImpl::WaitableCallbackResults | 40 class WebFileSystemImpl::WaitableCallbackResults |
| 42 : public base::RefCountedThreadSafe<WaitableCallbackResults> { | 41 : public base::RefCountedThreadSafe<WaitableCallbackResults> { |
| 43 public: | 42 public: |
| 44 WaitableCallbackResults() | 43 WaitableCallbackResults() |
| 45 : results_available_event_(true /* manual_reset */, | 44 : results_available_event_(true /* manual_reset */, |
| 46 false /* initially_signaled */) {} | 45 false /* initially_signaled */) {} |
| 47 | 46 |
| 48 void AddResultsAndSignal(const base::Closure& results_closure) { | 47 void AddResultsAndSignal(const base::Closure& results_closure) { |
| 49 base::AutoLock lock(lock_); | 48 base::AutoLock lock(lock_); |
| 50 results_closures_.push_back(results_closure); | 49 results_closures_.push_back(results_closure); |
| 51 results_available_event_.Signal(); | 50 results_available_event_.Signal(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void WaitAndRun() { | 53 void WaitAndRun() { |
| 55 { | 54 results_available_event_.Wait(); |
| 56 blink::WebHeap::SafePointScope safe_point; | |
| 57 results_available_event_.Wait(); | |
| 58 } | |
| 59 Run(); | 55 Run(); |
| 60 } | 56 } |
| 61 | 57 |
| 62 void Run() { | 58 void Run() { |
| 63 std::vector<base::Closure> closures; | 59 std::vector<base::Closure> closures; |
| 64 { | 60 { |
| 65 base::AutoLock lock(lock_); | 61 base::AutoLock lock(lock_); |
| 66 results_closures_.swap(closures); | 62 results_closures_.swap(closures); |
| 67 results_available_event_.Reset(); | 63 results_available_event_.Reset(); |
| 68 } | 64 } |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults( | 698 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults( |
| 703 const WebFileSystemCallbacks& callbacks, int callbacks_id) { | 699 const WebFileSystemCallbacks& callbacks, int callbacks_id) { |
| 704 if (!callbacks.shouldBlockUntilCompletion()) | 700 if (!callbacks.shouldBlockUntilCompletion()) |
| 705 return NULL; | 701 return NULL; |
| 706 WaitableCallbackResults* results = new WaitableCallbackResults(); | 702 WaitableCallbackResults* results = new WaitableCallbackResults(); |
| 707 waitable_results_[callbacks_id] = results; | 703 waitable_results_[callbacks_id] = results; |
| 708 return results; | 704 return results; |
| 709 } | 705 } |
| 710 | 706 |
| 711 } // namespace content | 707 } // namespace content |
| OLD | NEW |