| 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 "storage/browser/fileapi/recursive_operation_delegate.h" | 5 #include "storage/browser/fileapi/recursive_operation_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/location.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/message_loop/message_loop_proxy.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | |
| 16 #include "base/thread_task_runner_handle.h" | |
| 17 #include "content/public/test/sandbox_file_system_test_helper.h" | 16 #include "content/public/test/sandbox_file_system_test_helper.h" |
| 18 #include "storage/browser/fileapi/file_system_file_util.h" | 17 #include "storage/browser/fileapi/file_system_file_util.h" |
| 19 #include "storage/browser/fileapi/file_system_operation.h" | 18 #include "storage/browser/fileapi/file_system_operation.h" |
| 20 #include "storage/browser/fileapi/file_system_operation_runner.h" | 19 #include "storage/browser/fileapi/file_system_operation_runner.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 21 |
| 23 using storage::FileSystemContext; | 22 using storage::FileSystemContext; |
| 24 using storage::FileSystemOperationContext; | 23 using storage::FileSystemOperationContext; |
| 25 using storage::FileSystemURL; | 24 using storage::FileSystemURL; |
| 26 | 25 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 base::File::Error error) { | 108 base::File::Error error) { |
| 110 DCHECK(out_error); | 109 DCHECK(out_error); |
| 111 *out_error = error; | 110 *out_error = error; |
| 112 } | 111 } |
| 113 | 112 |
| 114 // To test the Cancel() during operation, calls Cancel() of |operation| | 113 // To test the Cancel() during operation, calls Cancel() of |operation| |
| 115 // after |counter| times message posting. | 114 // after |counter| times message posting. |
| 116 void CallCancelLater(storage::RecursiveOperationDelegate* operation, | 115 void CallCancelLater(storage::RecursiveOperationDelegate* operation, |
| 117 int counter) { | 116 int counter) { |
| 118 if (counter > 0) { | 117 if (counter > 0) { |
| 119 base::ThreadTaskRunnerHandle::Get()->PostTask( | 118 base::MessageLoopProxy::current()->PostTask( |
| 120 FROM_HERE, | 119 FROM_HERE, |
| 121 base::Bind(&CallCancelLater, base::Unretained(operation), counter - 1)); | 120 base::Bind(&CallCancelLater, base::Unretained(operation), counter - 1)); |
| 122 return; | 121 return; |
| 123 } | 122 } |
| 124 | 123 |
| 125 operation->Cancel(); | 124 operation->Cancel(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace | 127 } // namespace |
| 129 | 128 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 base::Bind(&ReportStatus, &error))); | 269 base::Bind(&ReportStatus, &error))); |
| 271 operation->RunRecursively(); | 270 operation->RunRecursively(); |
| 272 | 271 |
| 273 // Invoke Cancel(), after 5 times message posting. | 272 // Invoke Cancel(), after 5 times message posting. |
| 274 CallCancelLater(operation.get(), 5); | 273 CallCancelLater(operation.get(), 5); |
| 275 base::RunLoop().RunUntilIdle(); | 274 base::RunLoop().RunUntilIdle(); |
| 276 ASSERT_EQ(base::File::FILE_ERROR_ABORT, error); | 275 ASSERT_EQ(base::File::FILE_ERROR_ABORT, error); |
| 277 } | 276 } |
| 278 | 277 |
| 279 } // namespace content | 278 } // namespace content |
| OLD | NEW |