| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "modules/filesystem/FileWriterBase.h" | 31 #include "modules/filesystem/FileWriterBase.h" |
| 32 | 32 |
| 33 #include "core/events/ProgressEvent.h" | 33 #include "core/events/ProgressEvent.h" |
| 34 #include "core/fileapi/Blob.h" | 34 #include "core/fileapi/Blob.h" |
| 35 #include "core/fileapi/FileError.h" | 35 #include "core/fileapi/FileError.h" |
| 36 #include "public/platform/WebFileWriter.h" | 36 #include "public/platform/WebFileWriter.h" |
| 37 #include <memory> |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 FileWriterBase::~FileWriterBase() | 41 FileWriterBase::~FileWriterBase() |
| 41 { | 42 { |
| 42 } | 43 } |
| 43 | 44 |
| 44 void FileWriterBase::initialize(PassOwnPtr<WebFileWriter> writer, long long leng
th) | 45 void FileWriterBase::initialize(std::unique_ptr<WebFileWriter> writer, long long
length) |
| 45 { | 46 { |
| 46 ASSERT(!m_writer); | 47 ASSERT(!m_writer); |
| 47 ASSERT(length >= 0); | 48 ASSERT(length >= 0); |
| 48 m_writer = std::move(writer); | 49 m_writer = std::move(writer); |
| 49 m_length = length; | 50 m_length = length; |
| 50 } | 51 } |
| 51 | 52 |
| 52 FileWriterBase::FileWriterBase() | 53 FileWriterBase::FileWriterBase() |
| 53 : m_position(0) | 54 : m_position(0) |
| 54 { | 55 { |
| 55 } | 56 } |
| 56 | 57 |
| 57 void FileWriterBase::seekInternal(long long position) | 58 void FileWriterBase::seekInternal(long long position) |
| 58 { | 59 { |
| 59 if (position > m_length) | 60 if (position > m_length) |
| 60 position = m_length; | 61 position = m_length; |
| 61 else if (position < 0) | 62 else if (position < 0) |
| 62 position = m_length + position; | 63 position = m_length + position; |
| 63 if (position < 0) | 64 if (position < 0) |
| 64 position = 0; | 65 position = 0; |
| 65 m_position = position; | 66 m_position = position; |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |