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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 base::Bind(&WebFileWriterImpl::DidWrite, AsWeakPtr()), | 155 base::Bind(&WebFileWriterImpl::DidWrite, AsWeakPtr()), |
156 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr()))); | 156 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr()))); |
157 } | 157 } |
158 | 158 |
159 void WebFileWriterImpl::DoCancel() { | 159 void WebFileWriterImpl::DoCancel() { |
160 RunOnMainThread(base::Bind(&WriterBridge::Cancel, bridge_, | 160 RunOnMainThread(base::Bind(&WriterBridge::Cancel, bridge_, |
161 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr()))); | 161 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr()))); |
162 } | 162 } |
163 | 163 |
164 void WebFileWriterImpl::RunOnMainThread(const base::Closure& closure) { | 164 void WebFileWriterImpl::RunOnMainThread(const base::Closure& closure) { |
165 if (main_thread_task_runner_->RunsTasksOnCurrentThread()) { | 165 if (main_thread_task_runner_->RunsTasksInCurrentSequence()) { |
166 DCHECK(!bridge_->waitable_event()); | 166 DCHECK(!bridge_->waitable_event()); |
167 closure.Run(); | 167 closure.Run(); |
168 return; | 168 return; |
169 } | 169 } |
170 main_thread_task_runner_->PostTask(FROM_HERE, closure); | 170 main_thread_task_runner_->PostTask(FROM_HERE, closure); |
171 if (bridge_->waitable_event()) | 171 if (bridge_->waitable_event()) |
172 bridge_->WaitAndRun(); | 172 bridge_->WaitAndRun(); |
173 } | 173 } |
174 | 174 |
175 } // namespace content | 175 } // namespace content |
OLD | NEW |