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/webfilewriter_impl.h" | 5 #include "content/child/fileapi/webfilewriter_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "content/child/child_thread_impl.h" | 10 #include "content/child/child_thread_impl.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // on main thread. | 29 // on main thread. |
30 class WebFileWriterImpl::WriterBridge | 30 class WebFileWriterImpl::WriterBridge |
31 : public base::RefCountedThreadSafe<WriterBridge> { | 31 : public base::RefCountedThreadSafe<WriterBridge> { |
32 public: | 32 public: |
33 WriterBridge(WebFileWriterImpl::Type type) | 33 WriterBridge(WebFileWriterImpl::Type type) |
34 : request_id_(0), | 34 : request_id_(0), |
35 running_on_worker_(WorkerThread::GetCurrentId() > 0), | 35 running_on_worker_(WorkerThread::GetCurrentId() > 0), |
36 task_runner_(running_on_worker_ ? base::ThreadTaskRunnerHandle::Get() | 36 task_runner_(running_on_worker_ ? base::ThreadTaskRunnerHandle::Get() |
37 : nullptr), | 37 : nullptr), |
38 written_bytes_(0) { | 38 written_bytes_(0) { |
39 if (type == WebFileWriterImpl::TYPE_SYNC) | 39 if (type == WebFileWriterImpl::TYPE_SYNC) { |
40 waitable_event_.reset(new base::WaitableEvent(false, false)); | 40 waitable_event_.reset(new base::WaitableEvent( |
| 41 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 42 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
| 43 } |
41 } | 44 } |
42 | 45 |
43 void Truncate(const GURL& path, | 46 void Truncate(const GURL& path, |
44 int64_t offset, | 47 int64_t offset, |
45 const StatusCallback& status_callback) { | 48 const StatusCallback& status_callback) { |
46 status_callback_ = status_callback; | 49 status_callback_ = status_callback; |
47 if (!GetFileSystemDispatcher()) | 50 if (!GetFileSystemDispatcher()) |
48 return; | 51 return; |
49 ChildThreadImpl::current()->file_system_dispatcher()->Truncate( | 52 ChildThreadImpl::current()->file_system_dispatcher()->Truncate( |
50 path, offset, &request_id_, | 53 path, offset, &request_id_, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK(!bridge_->waitable_event()); | 166 DCHECK(!bridge_->waitable_event()); |
164 closure.Run(); | 167 closure.Run(); |
165 return; | 168 return; |
166 } | 169 } |
167 main_thread_task_runner_->PostTask(FROM_HERE, closure); | 170 main_thread_task_runner_->PostTask(FROM_HERE, closure); |
168 if (bridge_->waitable_event()) | 171 if (bridge_->waitable_event()) |
169 bridge_->WaitAndRun(); | 172 bridge_->WaitAndRun(); |
170 } | 173 } |
171 | 174 |
172 } // namespace content | 175 } // namespace content |
OLD | NEW |