Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "core/fileapi/Blob.h" | 35 #include "core/fileapi/Blob.h" |
| 36 #include "public/platform/WebFileWriter.h" | 36 #include "public/platform/WebFileWriter.h" |
| 37 #include "public/platform/WebURL.h" | 37 #include "public/platform/WebURL.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 void FileWriterSync::write(Blob* data, ExceptionState& exceptionState) { | 41 void FileWriterSync::write(Blob* data, ExceptionState& exceptionState) { |
| 42 ASSERT(data); | 42 ASSERT(data); |
| 43 ASSERT(writer()); | 43 ASSERT(writer()); |
| 44 ASSERT(m_complete); | 44 DCHECK(m_complete); |
|
Alexander Alekseev
2016/11/18 22:32:15
m_copplete is declared only if DCHECK_IS_ON()
| |
| 45 | 45 |
| 46 prepareForWrite(); | 46 prepareForWrite(); |
| 47 writer()->write(position(), data->uuid()); | 47 writer()->write(position(), data->uuid()); |
| 48 ASSERT(m_complete); | 48 DCHECK(m_complete); |
| 49 if (m_error) { | 49 if (m_error) { |
| 50 FileError::throwDOMException(exceptionState, m_error); | 50 FileError::throwDOMException(exceptionState, m_error); |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 setPosition(position() + data->size()); | 53 setPosition(position() + data->size()); |
| 54 if (position() > length()) | 54 if (position() > length()) |
| 55 setLength(position()); | 55 setLength(position()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) { | 58 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) { |
| 59 ASSERT(writer()); | 59 ASSERT(writer()); |
| 60 ASSERT(m_complete); | 60 DCHECK(m_complete); |
| 61 seekInternal(position); | 61 seekInternal(position); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void FileWriterSync::truncate(long long offset, | 64 void FileWriterSync::truncate(long long offset, |
| 65 ExceptionState& exceptionState) { | 65 ExceptionState& exceptionState) { |
| 66 ASSERT(writer()); | 66 ASSERT(writer()); |
| 67 ASSERT(m_complete); | 67 DCHECK(m_complete); |
| 68 if (offset < 0) { | 68 if (offset < 0) { |
| 69 exceptionState.throwDOMException(InvalidStateError, | 69 exceptionState.throwDOMException(InvalidStateError, |
| 70 FileError::invalidStateErrorMessage); | 70 FileError::invalidStateErrorMessage); |
| 71 return; | 71 return; |
| 72 } | 72 } |
| 73 prepareForWrite(); | 73 prepareForWrite(); |
| 74 writer()->truncate(offset); | 74 writer()->truncate(offset); |
| 75 ASSERT(m_complete); | 75 DCHECK(m_complete); |
| 76 if (m_error) { | 76 if (m_error) { |
| 77 FileError::throwDOMException(exceptionState, m_error); | 77 FileError::throwDOMException(exceptionState, m_error); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 if (offset < position()) | 80 if (offset < position()) |
| 81 setPosition(offset); | 81 setPosition(offset); |
| 82 setLength(offset); | 82 setLength(offset); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void FileWriterSync::didWrite(long long bytes, bool complete) { | 85 void FileWriterSync::didWrite(long long bytes, bool complete) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 110 FileWriterSync::FileWriterSync() | 110 FileWriterSync::FileWriterSync() |
| 111 : m_error(FileError::kOK) | 111 : m_error(FileError::kOK) |
| 112 #if DCHECK_IS_ON() | 112 #if DCHECK_IS_ON() |
| 113 , | 113 , |
| 114 m_complete(true) | 114 m_complete(true) |
| 115 #endif | 115 #endif |
| 116 { | 116 { |
| 117 } | 117 } |
| 118 | 118 |
| 119 void FileWriterSync::prepareForWrite() { | 119 void FileWriterSync::prepareForWrite() { |
| 120 #if DCHECK_IS_ON() | |
| 121 DCHECK(m_complete); | 120 DCHECK(m_complete); |
| 122 #endif | |
| 123 m_error = FileError::kOK; | 121 m_error = FileError::kOK; |
| 124 #if DCHECK_IS_ON() | 122 #if DCHECK_IS_ON() |
| 125 m_complete = false; | 123 m_complete = false; |
| 126 #endif | 124 #endif |
| 127 } | 125 } |
| 128 | 126 |
| 129 FileWriterSync::~FileWriterSync() {} | 127 FileWriterSync::~FileWriterSync() {} |
| 130 | 128 |
| 131 DEFINE_TRACE(FileWriterSync) { | 129 DEFINE_TRACE(FileWriterSync) { |
| 132 FileWriterBase::trace(visitor); | 130 FileWriterBase::trace(visitor); |
| 133 } | 131 } |
| 134 | 132 |
| 135 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |