Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: webkit/fileapi/webfilewriter_base.cc

Issue 9764018: Fix a FileWriter abort race by turning an assert into a soft check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
50 // before any of that comes back, but there will always be a terminal write 50 // before any of that comes back, but there will always be a terminal write
51 // response [success or failure] after them, followed by the cancel result, so 51 // response [success or failure] after them, followed by the cancel result, so
52 // we can ignore non-terminal write responses, take the terminal write success 52 // we can ignore non-terminal write responses, take the terminal write success
53 // or the first failure as the last write response, then know that the next 53 // or the first failure as the last write response, then know that the next
54 // thing to come back is the cancel response. We only notify the 54 // thing to come back is the cancel response. We only notify the
55 // AsyncFileWriterClient when it's all over. 55 // AsyncFileWriterClient when it's all over.
56 void WebFileWriterBase::cancel() { 56 void WebFileWriterBase::cancel() {
57 DCHECK(kOperationWrite == operation_ || kOperationTruncate == operation_); 57 // Check for the cancel passing the previous operation's return in-flight.
58 if (kOperationWrite != operation_ && kOperationTruncate != operation_)
59 return;
58 if (kCancelNotInProgress != cancel_state_) 60 if (kCancelNotInProgress != cancel_state_)
59 return; 61 return;
60 cancel_state_ = kCancelSent; 62 cancel_state_ = kCancelSent;
61 DoCancel(); 63 DoCancel();
62 } 64 }
63 65
64 void WebFileWriterBase::DidSucceed() { 66 void WebFileWriterBase::DidSucceed() {
65 // Write never gets a DidSucceed call, so this is either a cancel or truncate 67 // Write never gets a DidSucceed call, so this is either a cancel or truncate
66 // response. 68 // response.
67 switch (cancel_state_) { 69 switch (cancel_state_) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 138
137 void WebFileWriterBase::FinishCancel() { 139 void WebFileWriterBase::FinishCancel() {
138 DCHECK(kCancelReceivedWriteResponse == cancel_state_); 140 DCHECK(kCancelReceivedWriteResponse == cancel_state_);
139 DCHECK(kOperationNone != operation_); 141 DCHECK(kOperationNone != operation_);
140 cancel_state_ = kCancelNotInProgress; 142 cancel_state_ = kCancelNotInProgress;
141 operation_ = kOperationNone; 143 operation_ = kOperationNone;
142 client_->didFail(WebKit::WebFileErrorAbort); 144 client_->didFail(WebKit::WebFileErrorAbort);
143 } 145 }
144 146
145 } // namespace fileapi 147 } // namespace fileapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698