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 #if DCHECK_IS_ON() |
|
nhiroki
2016/11/21 03:24:57
Instead of adding DCHECK_IS_ON(), can you complete
Yuta Kitamura
2016/11/21 05:32:06
Ditto. All these changes are wrong.
Yuta Kitamura
2016/11/21 09:26:12
I was wrong. I agree with nhiroki here.
Alexander Alekseev
2016/11/23 09:20:30
Done.
| |
| 45 DCHECK(m_complete); | |
| 46 #endif | |
| 45 | 47 |
| 46 prepareForWrite(); | 48 prepareForWrite(); |
| 47 writer()->write(position(), data->uuid()); | 49 writer()->write(position(), data->uuid()); |
| 48 ASSERT(m_complete); | 50 #if DCHECK_IS_ON() |
| 51 DCHECK(m_complete); | |
| 52 #endif | |
| 49 if (m_error) { | 53 if (m_error) { |
| 50 FileError::throwDOMException(exceptionState, m_error); | 54 FileError::throwDOMException(exceptionState, m_error); |
| 51 return; | 55 return; |
| 52 } | 56 } |
| 53 setPosition(position() + data->size()); | 57 setPosition(position() + data->size()); |
| 54 if (position() > length()) | 58 if (position() > length()) |
| 55 setLength(position()); | 59 setLength(position()); |
| 56 } | 60 } |
| 57 | 61 |
| 58 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) { | 62 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) { |
| 59 ASSERT(writer()); | 63 ASSERT(writer()); |
| 60 ASSERT(m_complete); | 64 #if DCHECK_IS_ON() |
| 65 DCHECK(m_complete); | |
| 66 #endif | |
| 61 seekInternal(position); | 67 seekInternal(position); |
| 62 } | 68 } |
| 63 | 69 |
| 64 void FileWriterSync::truncate(long long offset, | 70 void FileWriterSync::truncate(long long offset, |
| 65 ExceptionState& exceptionState) { | 71 ExceptionState& exceptionState) { |
| 66 ASSERT(writer()); | 72 ASSERT(writer()); |
| 67 ASSERT(m_complete); | 73 #if DCHECK_IS_ON() |
| 74 DCHECK(m_complete); | |
| 75 #endif | |
| 68 if (offset < 0) { | 76 if (offset < 0) { |
| 69 exceptionState.throwDOMException(InvalidStateError, | 77 exceptionState.throwDOMException(InvalidStateError, |
| 70 FileError::invalidStateErrorMessage); | 78 FileError::invalidStateErrorMessage); |
| 71 return; | 79 return; |
| 72 } | 80 } |
| 73 prepareForWrite(); | 81 prepareForWrite(); |
| 74 writer()->truncate(offset); | 82 writer()->truncate(offset); |
| 75 ASSERT(m_complete); | 83 #if DCHECK_IS_ON() |
| 84 DCHECK(m_complete); | |
| 85 #endif | |
| 76 if (m_error) { | 86 if (m_error) { |
| 77 FileError::throwDOMException(exceptionState, m_error); | 87 FileError::throwDOMException(exceptionState, m_error); |
| 78 return; | 88 return; |
| 79 } | 89 } |
| 80 if (offset < position()) | 90 if (offset < position()) |
| 81 setPosition(offset); | 91 setPosition(offset); |
| 82 setLength(offset); | 92 setLength(offset); |
| 83 } | 93 } |
| 84 | 94 |
| 85 void FileWriterSync::didWrite(long long bytes, bool complete) { | 95 void FileWriterSync::didWrite(long long bytes, bool complete) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 #endif | 136 #endif |
| 127 } | 137 } |
| 128 | 138 |
| 129 FileWriterSync::~FileWriterSync() {} | 139 FileWriterSync::~FileWriterSync() {} |
| 130 | 140 |
| 131 DEFINE_TRACE(FileWriterSync) { | 141 DEFINE_TRACE(FileWriterSync) { |
| 132 FileWriterBase::trace(visitor); | 142 FileWriterBase::trace(visitor); |
| 133 } | 143 } |
| 134 | 144 |
| 135 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |