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/plugins/ppapi/quota_file_io.h" | 5 #include "webkit/plugins/ppapi/quota_file_io.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 const char* buffer, | 72 const char* buffer, |
73 int32_t bytes_to_write, | 73 int32_t bytes_to_write, |
74 const WriteCallback& callback) | 74 const WriteCallback& callback) |
75 : PendingOperationBase(quota_io, is_will_operation), | 75 : PendingOperationBase(quota_io, is_will_operation), |
76 offset_(offset), | 76 offset_(offset), |
77 bytes_to_write_(bytes_to_write), | 77 bytes_to_write_(bytes_to_write), |
78 callback_(callback), | 78 callback_(callback), |
79 finished_(false), | 79 finished_(false), |
80 status_(base::PLATFORM_FILE_OK), | 80 status_(base::PLATFORM_FILE_OK), |
81 bytes_written_(0), | 81 bytes_written_(0), |
82 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 82 weak_factory_(this) { |
83 if (!is_will_operation) { | 83 if (!is_will_operation) { |
84 // TODO(kinuko): Check the API convention if we really need to keep a copy | 84 // TODO(kinuko): Check the API convention if we really need to keep a copy |
85 // of the buffer during the async write operations. | 85 // of the buffer during the async write operations. |
86 buffer_.reset(new char[bytes_to_write]); | 86 buffer_.reset(new char[bytes_to_write]); |
87 memcpy(buffer_.get(), buffer, bytes_to_write); | 87 memcpy(buffer_.get(), buffer, bytes_to_write); |
88 } | 88 } |
89 } | 89 } |
90 virtual ~WriteOperation() {} | 90 virtual ~WriteOperation() {} |
91 virtual void Run() OVERRIDE { | 91 virtual void Run() OVERRIDE { |
92 DCHECK(quota_io_); | 92 DCHECK(quota_io_); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 class QuotaFileIO::SetLengthOperation : public PendingOperationBase { | 167 class QuotaFileIO::SetLengthOperation : public PendingOperationBase { |
168 public: | 168 public: |
169 SetLengthOperation(QuotaFileIO* quota_io, | 169 SetLengthOperation(QuotaFileIO* quota_io, |
170 bool is_will_operation, | 170 bool is_will_operation, |
171 int64_t length, | 171 int64_t length, |
172 const StatusCallback& callback) | 172 const StatusCallback& callback) |
173 : PendingOperationBase(quota_io, is_will_operation), | 173 : PendingOperationBase(quota_io, is_will_operation), |
174 length_(length), | 174 length_(length), |
175 callback_(callback), | 175 callback_(callback), |
176 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} | 176 weak_factory_(this) {} |
177 | 177 |
178 virtual ~SetLengthOperation() {} | 178 virtual ~SetLengthOperation() {} |
179 | 179 |
180 virtual void Run() OVERRIDE { | 180 virtual void Run() OVERRIDE { |
181 DCHECK(quota_io_); | 181 DCHECK(quota_io_); |
182 if (quota_io_->CheckIfExceedsQuota(length_)) { | 182 if (quota_io_->CheckIfExceedsQuota(length_)) { |
183 DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); | 183 DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); |
184 return; | 184 return; |
185 } | 185 } |
186 if (is_will_operation_) { | 186 if (is_will_operation_) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 : pp_instance_(instance), | 231 : pp_instance_(instance), |
232 file_(file), | 232 file_(file), |
233 file_url_(file_url), | 233 file_url_(file_url), |
234 storage_type_(PPFileSystemTypeToQuotaStorageType(type)), | 234 storage_type_(PPFileSystemTypeToQuotaStorageType(type)), |
235 cached_file_size_(0), | 235 cached_file_size_(0), |
236 cached_available_space_(0), | 236 cached_available_space_(0), |
237 outstanding_quota_queries_(0), | 237 outstanding_quota_queries_(0), |
238 outstanding_errors_(0), | 238 outstanding_errors_(0), |
239 max_written_offset_(0), | 239 max_written_offset_(0), |
240 inflight_operations_(0), | 240 inflight_operations_(0), |
241 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 241 weak_factory_(this) { |
242 DCHECK_NE(base::kInvalidPlatformFileValue, file_); | 242 DCHECK_NE(base::kInvalidPlatformFileValue, file_); |
243 DCHECK_NE(quota::kStorageTypeUnknown, storage_type_); | 243 DCHECK_NE(quota::kStorageTypeUnknown, storage_type_); |
244 } | 244 } |
245 | 245 |
246 QuotaFileIO::~QuotaFileIO() { | 246 QuotaFileIO::~QuotaFileIO() { |
247 // Note that this doesn't dispatch pending callbacks. | 247 // Note that this doesn't dispatch pending callbacks. |
248 STLDeleteContainerPointers(pending_operations_.begin(), | 248 STLDeleteContainerPointers(pending_operations_.begin(), |
249 pending_operations_.end()); | 249 pending_operations_.end()); |
250 STLDeleteContainerPointers(pending_callbacks_.begin(), | 250 STLDeleteContainerPointers(pending_callbacks_.begin(), |
251 pending_callbacks_.end()); | 251 pending_callbacks_.end()); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 | 411 |
412 PluginDelegate* plugin_delegate = GetPluginDelegate(); | 412 PluginDelegate* plugin_delegate = GetPluginDelegate(); |
413 if (plugin_delegate) | 413 if (plugin_delegate) |
414 plugin_delegate->DidUpdateFile(file_url_, delta); | 414 plugin_delegate->DidUpdateFile(file_url_, delta); |
415 inflight_operations_ = 0; | 415 inflight_operations_ = 0; |
416 } | 416 } |
417 | 417 |
418 } // namespace ppapi | 418 } // namespace ppapi |
419 } // namespace webkit | 419 } // namespace webkit |
OLD | NEW |