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/WebKit/chromium/public/WebFileError.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriterClient.h
" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileWriterClient.h
" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
11 #include "webkit/glue/webkit_glue.h" | 11 #include "webkit/fileapi/file_system_util.h" |
12 | 12 |
13 namespace fileapi { | 13 namespace fileapi { |
14 | 14 |
15 WebFileWriterBase::WebFileWriterBase( | 15 WebFileWriterBase::WebFileWriterBase( |
16 const GURL& path, WebKit::WebFileWriterClient* client) | 16 const GURL& path, WebKit::WebFileWriterClient* client) |
17 : path_(path), | 17 : path_(path), |
18 client_(client), | 18 client_(client), |
19 operation_(kOperationNone), | 19 operation_(kOperationNone), |
20 cancel_state_(kCancelNotInProgress) { | 20 cancel_state_(kCancelNotInProgress) { |
21 } | 21 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 void WebFileWriterBase::DidFail(base::PlatformFileError error_code) { | 92 void WebFileWriterBase::DidFail(base::PlatformFileError error_code) { |
93 DCHECK(kOperationNone != operation_); | 93 DCHECK(kOperationNone != operation_); |
94 switch (cancel_state_) { | 94 switch (cancel_state_) { |
95 case kCancelNotInProgress: | 95 case kCancelNotInProgress: |
96 // A write or truncate failed. | 96 // A write or truncate failed. |
97 operation_ = kOperationNone; | 97 operation_ = kOperationNone; |
98 client_->didFail( | 98 client_->didFail( |
99 webkit_glue::PlatformFileErrorToWebFileError(error_code)); | 99 PlatformFileErrorToWebFileError(error_code)); |
100 break; | 100 break; |
101 case kCancelSent: | 101 case kCancelSent: |
102 // This is the failure of a write or truncate; the next message should be | 102 // This is the failure of a write or truncate; the next message should be |
103 // the result of the cancel. We don't assume that it'll be a success, as | 103 // the result of the cancel. We don't assume that it'll be a success, as |
104 // the write/truncate could have failed for other reasons. | 104 // the write/truncate could have failed for other reasons. |
105 cancel_state_ = kCancelReceivedWriteResponse; | 105 cancel_state_ = kCancelReceivedWriteResponse; |
106 break; | 106 break; |
107 case kCancelReceivedWriteResponse: | 107 case kCancelReceivedWriteResponse: |
108 // The cancel reported failure, meaning that the write or truncate | 108 // The cancel reported failure, meaning that the write or truncate |
109 // finished before the cancel got there. But we suppressed the | 109 // finished before the cancel got there. But we suppressed the |
(...skipping 28 matching lines...) Expand all 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 |