| 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/webfilewriter_base.h" | 5 #include "webkit/fileapi/webfilewriter_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 8 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriterClient.h
" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriterClient.h
" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 void WebFileWriterBase::truncate(long long length) { | 26 void WebFileWriterBase::truncate(long long length) { |
| 27 DCHECK(kOperationNone == operation_); | 27 DCHECK(kOperationNone == operation_); |
| 28 DCHECK(kCancelNotInProgress == cancel_state_); | 28 DCHECK(kCancelNotInProgress == cancel_state_); |
| 29 operation_ = kOperationTruncate; | 29 operation_ = kOperationTruncate; |
| 30 DoTruncate(path_, length); | 30 DoTruncate(path_, length); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void WebFileWriterBase::write( | 33 void WebFileWriterBase::write( |
| 34 long long position, | 34 long long position, |
| 35 const WebKit::WebURL& blob_url) { | 35 const WebKit::WebString& blob_uuid) { |
| 36 DCHECK(kOperationNone == operation_); | 36 DCHECK(kOperationNone == operation_); |
| 37 DCHECK(kCancelNotInProgress == cancel_state_); | 37 DCHECK(kCancelNotInProgress == cancel_state_); |
| 38 operation_ = kOperationWrite; | 38 operation_ = kOperationWrite; |
| 39 DoWrite(path_, blob_url, position); | 39 DoWrite(path_, blob_uuid.utf8(), position); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // When we cancel a write/truncate, we always get back the result of the write | 42 // When we cancel a write/truncate, we always get back the result of the write |
| 43 // before the result of the cancel, no matter what happens. | 43 // before the result of the cancel, no matter what happens. |
| 44 // So we'll get back either | 44 // So we'll get back either |
| 45 // success [of the write/truncate, in a DidWrite(XXX, true)/DidSucceed() call] | 45 // success [of the write/truncate, in a DidWrite(XXX, true)/DidSucceed() call] |
| 46 // followed by failure [of the cancel]; or | 46 // followed by failure [of the cancel]; or |
| 47 // failure [of the write, either from cancel or other reasons] followed by | 47 // failure [of the write, either from cancel or other reasons] followed by |
| 48 // the result of the cancel. | 48 // the result of the cancel. |
| 49 // In the write case, there could also be queued up non-terminal DidWrite calls | 49 // In the write case, there could also be queued up non-terminal DidWrite calls |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 void WebFileWriterBase::FinishCancel() { | 139 void WebFileWriterBase::FinishCancel() { |
| 140 DCHECK(kCancelReceivedWriteResponse == cancel_state_); | 140 DCHECK(kCancelReceivedWriteResponse == cancel_state_); |
| 141 DCHECK(kOperationNone != operation_); | 141 DCHECK(kOperationNone != operation_); |
| 142 cancel_state_ = kCancelNotInProgress; | 142 cancel_state_ = kCancelNotInProgress; |
| 143 operation_ = kOperationNone; | 143 operation_ = kOperationNone; |
| 144 client_->didFail(WebKit::WebFileErrorAbort); | 144 client_->didFail(WebKit::WebFileErrorAbort); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace fileapi | 147 } // namespace fileapi |
| OLD | NEW |