/* * Copyright (C) 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "third_party/blink/renderer/modules/filesystem/file_writer_base.h" #include <memory> #include "third_party/blink/renderer/core/events/progress_event.h" #include "third_party/blink/renderer/core/fileapi/blob.h" #include "third_party/blink/renderer/core/fileapi/file_error.h" namespace blink { FileWriterBase::~FileWriterBase() = default; void FileWriterBase::Initialize(const KURL& path, int64_t length) { … } FileWriterBase::FileWriterBase() : … { … } void FileWriterBase::SeekInternal(int64_t position) { … } void FileWriterBase::Truncate(int64_t length) { … } void FileWriterBase::Write(int64_t position, const Blob& blob) { … } // When we cancel a write/truncate, we always get back the result of the write // before the result of the cancel, no matter what happens. // So we'll get back either // success [of the write/truncate, in a DidWrite(XXX, true)/DidSucceed() call] // followed by failure [of the cancel]; or // failure [of the write, either from cancel or other reasons] followed by // the result of the cancel. // In the write case, there could also be queued up non-terminal DidWrite calls // before any of that comes back, but there will always be a terminal write // response [success or failure] after them, followed by the cancel result, so // we can ignore non-terminal write responses, take the terminal write success // or the first failure as the last write response, then know that the next // thing to come back is the cancel response. We only notify the // AsyncFileWriterClient when it's all over. void FileWriterBase::Cancel() { … } void FileWriterBase::DidFinish(base::File::Error error_code) { … } void FileWriterBase::DidWrite(int64_t bytes, bool complete) { … } void FileWriterBase::DidSucceed() { … } void FileWriterBase::DidFail(base::File::Error error_code) { … } void FileWriterBase::FinishCancel() { … } } // namespace blink