OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/child/fileapi/webfilewriter_base.h" | 5 #include "content/child/fileapi/webfilewriter_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/platform/WebFileError.h" | 8 #include "third_party/WebKit/public/platform/WebFileError.h" |
9 #include "third_party/WebKit/public/platform/WebFileWriterClient.h" | 9 #include "third_party/WebKit/public/platform/WebFileWriterClient.h" |
10 #include "third_party/WebKit/public/platform/WebURL.h" | 10 #include "third_party/WebKit/public/platform/WebURL.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 WebFileWriterBase::~WebFileWriterBase() {} | 24 WebFileWriterBase::~WebFileWriterBase() {} |
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(long long position, | |
34 const WebKit::WebURL& blob_url) { | |
35 DCHECK_EQ(kOperationNone, operation_); | |
36 DCHECK_EQ(kCancelNotInProgress, cancel_state_); | |
37 operation_ = kOperationWrite; | |
38 DoWriteDeprecated(path_, blob_url, position); | |
39 } | |
40 | |
41 void WebFileWriterBase::write( | 33 void WebFileWriterBase::write( |
42 long long position, | 34 long long position, |
43 const WebKit::WebString& id) { | 35 const WebKit::WebString& id) { |
44 DCHECK_EQ(kOperationNone, operation_); | 36 DCHECK_EQ(kOperationNone, operation_); |
45 DCHECK_EQ(kCancelNotInProgress, cancel_state_); | 37 DCHECK_EQ(kCancelNotInProgress, cancel_state_); |
46 operation_ = kOperationWrite; | 38 operation_ = kOperationWrite; |
47 DoWrite(path_, id.utf8(), position); | 39 DoWrite(path_, id.utf8(), position); |
48 } | 40 } |
49 | 41 |
50 // 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 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 144 |
153 void WebFileWriterBase::FinishCancel() { | 145 void WebFileWriterBase::FinishCancel() { |
154 DCHECK(kCancelReceivedWriteResponse == cancel_state_); | 146 DCHECK(kCancelReceivedWriteResponse == cancel_state_); |
155 DCHECK(kOperationNone != operation_); | 147 DCHECK(kOperationNone != operation_); |
156 cancel_state_ = kCancelNotInProgress; | 148 cancel_state_ = kCancelNotInProgress; |
157 operation_ = kOperationNone; | 149 operation_ = kOperationNone; |
158 client_->didFail(WebKit::WebFileErrorAbort); | 150 client_->didFail(WebKit::WebFileErrorAbort); |
159 } | 151 } |
160 | 152 |
161 } // namespace content | 153 } // namespace content |
OLD | NEW |