| 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 "webkit/fileapi/file_writer_delegate.h" | 5 #include "webkit/fileapi/file_writer_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 void FileWriterDelegate::OnResponseStarted(net::URLRequest* request) { | 174 void FileWriterDelegate::OnResponseStarted(net::URLRequest* request) { |
| 175 DCHECK_EQ(request_, request); | 175 DCHECK_EQ(request_, request); |
| 176 // file_stream_->Seek() blocks the IO thread. | 176 // file_stream_->Seek() blocks the IO thread. |
| 177 // See http://crbug.com/75548. | 177 // See http://crbug.com/75548. |
| 178 base::ThreadRestrictions::ScopedAllowIO allow_io; | 178 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 179 if (!request->status().is_success() || request->GetResponseCode() != 200) { | 179 if (!request->status().is_success() || request->GetResponseCode() != 200) { |
| 180 OnError(base::PLATFORM_FILE_ERROR_FAILED); | 180 OnError(base::PLATFORM_FILE_ERROR_FAILED); |
| 181 return; | 181 return; |
| 182 } | 182 } |
| 183 int64 error = file_stream_->Seek(net::FROM_BEGIN, offset_); | 183 int64 error = file_stream_->SeekSync(net::FROM_BEGIN, offset_); |
| 184 if (error != offset_) { | 184 if (error != offset_) { |
| 185 OnError(base::PLATFORM_FILE_ERROR_FAILED); | 185 OnError(base::PLATFORM_FILE_ERROR_FAILED); |
| 186 return; | 186 return; |
| 187 } | 187 } |
| 188 Read(); | 188 Read(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void FileWriterDelegate::OnReadCompleted(net::URLRequest* request, | 191 void FileWriterDelegate::OnReadCompleted(net::URLRequest* request, |
| 192 int bytes_read) { | 192 int bytes_read) { |
| 193 DCHECK_EQ(request_, request); | 193 DCHECK_EQ(request_, request); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 FileSystemQuotaUtil* FileWriterDelegate::quota_util() const { | 320 FileSystemQuotaUtil* FileWriterDelegate::quota_util() const { |
| 321 DCHECK(file_system_operation_); | 321 DCHECK(file_system_operation_); |
| 322 DCHECK(file_system_operation_->file_system_context()); | 322 DCHECK(file_system_operation_->file_system_context()); |
| 323 DCHECK(file_system_operation_->file_system_operation_context()); | 323 DCHECK(file_system_operation_->file_system_operation_context()); |
| 324 return file_system_operation_->file_system_context()->GetQuotaUtil( | 324 return file_system_operation_->file_system_context()->GetQuotaUtil( |
| 325 path_.type()); | 325 path_.type()); |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace fileapi | 328 } // namespace fileapi |
| OLD | NEW |