| 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 | 34 |
| 35 #include "bindings/v8/ExceptionMessages.h" | 35 #include "bindings/v8/ExceptionMessages.h" |
| 36 #include "bindings/v8/ExceptionState.h" | 36 #include "bindings/v8/ExceptionState.h" |
| 37 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 38 #include "core/fileapi/Blob.h" | 38 #include "core/fileapi/Blob.h" |
| 39 #include "public/platform/WebFileWriter.h" | 39 #include "public/platform/WebFileWriter.h" |
| 40 #include "public/platform/WebURL.h" | 40 #include "public/platform/WebURL.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 void FileWriterSync::write(Blob* data, ExceptionState& es) | 44 void FileWriterSync::write(Blob* data, ExceptionState& exceptionState) |
| 45 { | 45 { |
| 46 ASSERT(writer()); | 46 ASSERT(writer()); |
| 47 ASSERT(m_complete); | 47 ASSERT(m_complete); |
| 48 if (!data) { | 48 if (!data) { |
| 49 es.throwDOMException(TypeMismatchError, ExceptionMessages::failedToExecu
te("write", "FileReaderSync", FileError::typeMismatchErrorMessage)); | 49 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::f
ailedToExecute("write", "FileReaderSync", FileError::typeMismatchErrorMessage)); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 prepareForWrite(); | 53 prepareForWrite(); |
| 54 writer()->write(position(), data->uuid()); | 54 writer()->write(position(), data->uuid()); |
| 55 ASSERT(m_complete); | 55 ASSERT(m_complete); |
| 56 if (m_error) { | 56 if (m_error) { |
| 57 FileError::throwDOMException(es, m_error); | 57 FileError::throwDOMException(exceptionState, m_error); |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 setPosition(position() + data->size()); | 60 setPosition(position() + data->size()); |
| 61 if (position() > length()) | 61 if (position() > length()) |
| 62 setLength(position()); | 62 setLength(position()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void FileWriterSync::seek(long long position, ExceptionState& es) | 65 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) |
| 66 { | 66 { |
| 67 ASSERT(writer()); | 67 ASSERT(writer()); |
| 68 ASSERT(m_complete); | 68 ASSERT(m_complete); |
| 69 seekInternal(position); | 69 seekInternal(position); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void FileWriterSync::truncate(long long offset, ExceptionState& es) | 72 void FileWriterSync::truncate(long long offset, ExceptionState& exceptionState) |
| 73 { | 73 { |
| 74 ASSERT(writer()); | 74 ASSERT(writer()); |
| 75 ASSERT(m_complete); | 75 ASSERT(m_complete); |
| 76 if (offset < 0) { | 76 if (offset < 0) { |
| 77 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("truncate", "FileWriterSync", FileError::invalidStateErrorMessage)); | 77 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("truncate", "FileWriterSync", FileError::invalidStateErrorMessage
)); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 prepareForWrite(); | 80 prepareForWrite(); |
| 81 writer()->truncate(offset); | 81 writer()->truncate(offset); |
| 82 ASSERT(m_complete); | 82 ASSERT(m_complete); |
| 83 if (m_error) { | 83 if (m_error) { |
| 84 FileError::throwDOMException(es, m_error); | 84 FileError::throwDOMException(exceptionState, m_error); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 if (offset < position()) | 87 if (offset < position()) |
| 88 setPosition(offset); | 88 setPosition(offset); |
| 89 setLength(offset); | 89 setLength(offset); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void FileWriterSync::didWrite(long long bytes, bool complete) | 92 void FileWriterSync::didWrite(long long bytes, bool complete) |
| 93 { | 93 { |
| 94 ASSERT(m_error == FileError::OK); | 94 ASSERT(m_error == FileError::OK); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 m_complete = false; | 136 m_complete = false; |
| 137 #endif | 137 #endif |
| 138 } | 138 } |
| 139 | 139 |
| 140 FileWriterSync::~FileWriterSync() | 140 FileWriterSync::~FileWriterSync() |
| 141 { | 141 { |
| 142 } | 142 } |
| 143 | 143 |
| 144 | 144 |
| 145 } // namespace WebCore | 145 } // namespace WebCore |
| OLD | NEW |