| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/base/file_stream_context.h" | 5 #include "net/base/file_stream_context.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 FROM_HERE, | 109 FROM_HERE, |
| 110 base::Bind(&Context::CloseFileImpl, base::Unretained(this)), | 110 base::Bind(&Context::CloseFileImpl, base::Unretained(this)), |
| 111 base::Bind(&Context::OnAsyncCompleted, | 111 base::Bind(&Context::OnAsyncCompleted, |
| 112 base::Unretained(this), | 112 base::Unretained(this), |
| 113 IntToInt64(callback))); | 113 IntToInt64(callback))); |
| 114 DCHECK(posted); | 114 DCHECK(posted); |
| 115 | 115 |
| 116 async_in_progress_ = true; | 116 async_in_progress_ = true; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void FileStream::Context::Seek(base::File::Whence whence, | 119 void FileStream::Context::Seek(int64 offset, |
| 120 int64 offset, | |
| 121 const Int64CompletionCallback& callback) { | 120 const Int64CompletionCallback& callback) { |
| 122 DCHECK(!async_in_progress_); | 121 DCHECK(!async_in_progress_); |
| 123 | 122 |
| 124 bool posted = base::PostTaskAndReplyWithResult( | 123 bool posted = base::PostTaskAndReplyWithResult( |
| 125 task_runner_.get(), | 124 task_runner_.get(), FROM_HERE, |
| 126 FROM_HERE, | 125 base::Bind(&Context::SeekFileImpl, base::Unretained(this), offset), |
| 127 base::Bind( | 126 base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), callback)); |
| 128 &Context::SeekFileImpl, base::Unretained(this), whence, offset), | |
| 129 base::Bind(&Context::OnAsyncCompleted, | |
| 130 base::Unretained(this), | |
| 131 callback)); | |
| 132 DCHECK(posted); | 127 DCHECK(posted); |
| 133 | 128 |
| 134 async_in_progress_ = true; | 129 async_in_progress_ = true; |
| 135 } | 130 } |
| 136 | 131 |
| 137 void FileStream::Context::Flush(const CompletionCallback& callback) { | 132 void FileStream::Context::Flush(const CompletionCallback& callback) { |
| 138 DCHECK(!async_in_progress_); | 133 DCHECK(!async_in_progress_); |
| 139 | 134 |
| 140 bool posted = base::PostTaskAndReplyWithResult( | 135 bool posted = base::PostTaskAndReplyWithResult( |
| 141 task_runner_.get(), | 136 task_runner_.get(), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // should be reset before Close() because it shouldn't run if any async | 231 // should be reset before Close() because it shouldn't run if any async |
| 237 // operation is in progress. | 232 // operation is in progress. |
| 238 async_in_progress_ = false; | 233 async_in_progress_ = false; |
| 239 if (orphaned_) | 234 if (orphaned_) |
| 240 CloseAndDelete(); | 235 CloseAndDelete(); |
| 241 else | 236 else |
| 242 callback.Run(result.result); | 237 callback.Run(result.result); |
| 243 } | 238 } |
| 244 | 239 |
| 245 } // namespace net | 240 } // namespace net |
| OLD | NEW |