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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 int64 allowed_bytes_growth = | 112 int64 allowed_bytes_growth = |
113 file_system_operation_context()->allowed_bytes_growth(); | 113 file_system_operation_context()->allowed_bytes_growth(); |
114 if (allowed_bytes_growth < 0) | 114 if (allowed_bytes_growth < 0) |
115 allowed_bytes_growth = 0; | 115 allowed_bytes_growth = 0; |
116 int64 overlap = file_info.size - offset_; | 116 int64 overlap = file_info.size - offset_; |
117 allowed_bytes_to_write_ = allowed_bytes_growth; | 117 allowed_bytes_to_write_ = allowed_bytes_growth; |
118 if (kint64max - overlap > allowed_bytes_growth) | 118 if (kint64max - overlap > allowed_bytes_growth) |
119 allowed_bytes_to_write_ += overlap; | 119 allowed_bytes_to_write_ += overlap; |
120 size_ = file_info.size; | 120 size_ = file_info.size; |
121 file_stream_.reset(new net::FileStream(file_, | 121 file_stream_.reset(new net::FileStream( |
| 122 file_, |
122 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | | 123 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | |
123 base::PLATFORM_FILE_ASYNC)); | 124 base::PLATFORM_FILE_ASYNC, |
| 125 NULL)); |
124 request_->Start(); | 126 request_->Start(); |
125 } | 127 } |
126 | 128 |
127 void FileWriterDelegate::Start(base::PlatformFile file, | 129 void FileWriterDelegate::Start(base::PlatformFile file, |
128 net::URLRequest* request) { | 130 net::URLRequest* request) { |
129 file_ = file; | 131 file_ = file; |
130 request_ = request; | 132 request_ = request; |
131 | 133 |
132 scoped_refptr<InitializeTask> relay = new InitializeTask( | 134 scoped_refptr<InitializeTask> relay = new InitializeTask( |
133 file_, file_system_operation_context(), | 135 file_, file_system_operation_context(), |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 319 |
318 FileSystemQuotaUtil* FileWriterDelegate::quota_util() const { | 320 FileSystemQuotaUtil* FileWriterDelegate::quota_util() const { |
319 DCHECK(file_system_operation_); | 321 DCHECK(file_system_operation_); |
320 DCHECK(file_system_operation_->file_system_context()); | 322 DCHECK(file_system_operation_->file_system_context()); |
321 DCHECK(file_system_operation_->file_system_operation_context()); | 323 DCHECK(file_system_operation_->file_system_operation_context()); |
322 return file_system_operation_->file_system_context()->GetQuotaUtil( | 324 return file_system_operation_->file_system_context()->GetQuotaUtil( |
323 file_system_operation_context()->src_type()); | 325 file_system_operation_context()->src_type()); |
324 } | 326 } |
325 | 327 |
326 } // namespace fileapi | 328 } // namespace fileapi |
OLD | NEW |