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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 DCHECK(buffer_.get()); | 102 DCHECK(buffer_.get()); |
103 | 103 |
104 PluginDelegate* plugin_delegate = quota_io_->GetPluginDelegate(); | 104 PluginDelegate* plugin_delegate = quota_io_->GetPluginDelegate(); |
105 if (!plugin_delegate) { | 105 if (!plugin_delegate) { |
106 DidFail(base::PLATFORM_FILE_ERROR_FAILED); | 106 DidFail(base::PLATFORM_FILE_ERROR_FAILED); |
107 return; | 107 return; |
108 } | 108 } |
109 | 109 |
110 if (!base::PostTaskAndReplyWithResult( | 110 if (!base::PostTaskAndReplyWithResult( |
111 plugin_delegate->GetFileThreadMessageLoopProxy(), FROM_HERE, | 111 plugin_delegate->GetFileThreadMessageLoopProxy().get(), |
| 112 FROM_HERE, |
112 base::Bind(&WriteAdapter, | 113 base::Bind(&WriteAdapter, |
113 quota_io_->file_, offset_, | 114 quota_io_->file_, |
114 base::Passed(&buffer_), bytes_to_write_), | 115 offset_, |
| 116 base::Passed(&buffer_), |
| 117 bytes_to_write_), |
115 base::Bind(&WriteOperation::DidWrite, | 118 base::Bind(&WriteOperation::DidWrite, |
116 weak_factory_.GetWeakPtr()))) { | 119 weak_factory_.GetWeakPtr()))) { |
117 DidFail(base::PLATFORM_FILE_ERROR_FAILED); | 120 DidFail(base::PLATFORM_FILE_ERROR_FAILED); |
118 return; | 121 return; |
119 } | 122 } |
120 } | 123 } |
121 | 124 |
122 virtual void DidFail(PlatformFileError error) OVERRIDE { | 125 virtual void DidFail(PlatformFileError error) OVERRIDE { |
123 DidFinish(error, 0); | 126 DidFinish(error, 0); |
124 } | 127 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return; | 191 return; |
189 } | 192 } |
190 | 193 |
191 PluginDelegate* plugin_delegate = quota_io_->GetPluginDelegate(); | 194 PluginDelegate* plugin_delegate = quota_io_->GetPluginDelegate(); |
192 if (!plugin_delegate) { | 195 if (!plugin_delegate) { |
193 DidFail(base::PLATFORM_FILE_ERROR_FAILED); | 196 DidFail(base::PLATFORM_FILE_ERROR_FAILED); |
194 return; | 197 return; |
195 } | 198 } |
196 | 199 |
197 if (!base::FileUtilProxy::Truncate( | 200 if (!base::FileUtilProxy::Truncate( |
198 plugin_delegate->GetFileThreadMessageLoopProxy(), | 201 plugin_delegate->GetFileThreadMessageLoopProxy().get(), |
199 quota_io_->file_, length_, | 202 quota_io_->file_, |
| 203 length_, |
200 base::Bind(&SetLengthOperation::DidFinish, | 204 base::Bind(&SetLengthOperation::DidFinish, |
201 weak_factory_.GetWeakPtr()))) { | 205 weak_factory_.GetWeakPtr()))) { |
202 DidFail(base::PLATFORM_FILE_ERROR_FAILED); | 206 DidFail(base::PLATFORM_FILE_ERROR_FAILED); |
203 return; | 207 return; |
204 } | 208 } |
205 } | 209 } |
206 | 210 |
207 virtual void DidFail(PlatformFileError error) OVERRIDE { | 211 virtual void DidFail(PlatformFileError error) OVERRIDE { |
208 DidFinish(error); | 212 DidFinish(error); |
209 } | 213 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 outstanding_quota_queries_ = 0; | 303 outstanding_quota_queries_ = 0; |
300 outstanding_errors_ = 0; | 304 outstanding_errors_ = 0; |
301 | 305 |
302 PluginDelegate* plugin_delegate = GetPluginDelegate(); | 306 PluginDelegate* plugin_delegate = GetPluginDelegate(); |
303 if (!plugin_delegate) | 307 if (!plugin_delegate) |
304 return false; | 308 return false; |
305 | 309 |
306 // Query the file size. | 310 // Query the file size. |
307 ++outstanding_quota_queries_; | 311 ++outstanding_quota_queries_; |
308 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( | 312 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( |
309 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, | 313 plugin_delegate->GetFileThreadMessageLoopProxy().get(), |
| 314 file_, |
310 base::Bind(&QuotaFileIO::DidQueryInfoForQuota, | 315 base::Bind(&QuotaFileIO::DidQueryInfoForQuota, |
311 weak_factory_.GetWeakPtr()))) { | 316 weak_factory_.GetWeakPtr()))) { |
312 // This makes the call fail synchronously; we do not fire the callback | 317 // This makes the call fail synchronously; we do not fire the callback |
313 // here but just delete the operation and return false. | 318 // here but just delete the operation and return false. |
314 return false; | 319 return false; |
315 } | 320 } |
316 | 321 |
317 // Query the current available space. | 322 // Query the current available space. |
318 ++outstanding_quota_queries_; | 323 ++outstanding_quota_queries_; |
319 plugin_delegate->QueryAvailableSpace( | 324 plugin_delegate->QueryAvailableSpace( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 415 |
411 | 416 |
412 PluginDelegate* plugin_delegate = GetPluginDelegate(); | 417 PluginDelegate* plugin_delegate = GetPluginDelegate(); |
413 if (plugin_delegate) | 418 if (plugin_delegate) |
414 plugin_delegate->DidUpdateFile(file_url_, delta); | 419 plugin_delegate->DidUpdateFile(file_url_, delta); |
415 inflight_operations_ = 0; | 420 inflight_operations_ = 0; |
416 } | 421 } |
417 | 422 |
418 } // namespace ppapi | 423 } // namespace ppapi |
419 } // namespace webkit | 424 } // namespace webkit |
OLD | NEW |