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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
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& exception_state) { | 41 void FileWriterSync::write(Blob* data, ExceptionState& exception_state) { |
42 ASSERT(data); | 42 DCHECK(data); |
43 ASSERT(Writer()); | 43 DCHECK(Writer()); |
44 DCHECK(complete_); | 44 DCHECK(complete_); |
45 | 45 |
46 PrepareForWrite(); | 46 PrepareForWrite(); |
47 Writer()->Write(position(), data->Uuid()); | 47 Writer()->Write(position(), data->Uuid()); |
48 DCHECK(complete_); | 48 DCHECK(complete_); |
49 if (error_) { | 49 if (error_) { |
50 FileError::ThrowDOMException(exception_state, error_); | 50 FileError::ThrowDOMException(exception_state, 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& exception_state) { | 58 void FileWriterSync::seek(long long position, ExceptionState& exception_state) { |
59 ASSERT(Writer()); | 59 DCHECK(Writer()); |
60 DCHECK(complete_); | 60 DCHECK(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& exception_state) { | 65 ExceptionState& exception_state) { |
66 ASSERT(Writer()); | 66 DCHECK(Writer()); |
67 DCHECK(complete_); | 67 DCHECK(complete_); |
68 if (offset < 0) { | 68 if (offset < 0) { |
69 exception_state.ThrowDOMException(kInvalidStateError, | 69 exception_state.ThrowDOMException(kInvalidStateError, |
70 FileError::kInvalidStateErrorMessage); | 70 FileError::kInvalidStateErrorMessage); |
71 return; | 71 return; |
72 } | 72 } |
73 PrepareForWrite(); | 73 PrepareForWrite(); |
74 Writer()->Truncate(offset); | 74 Writer()->Truncate(offset); |
75 DCHECK(complete_); | 75 DCHECK(complete_); |
76 if (error_) { | 76 if (error_) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 complete_ = false; | 109 complete_ = false; |
110 } | 110 } |
111 | 111 |
112 FileWriterSync::~FileWriterSync() {} | 112 FileWriterSync::~FileWriterSync() {} |
113 | 113 |
114 DEFINE_TRACE(FileWriterSync) { | 114 DEFINE_TRACE(FileWriterSync) { |
115 FileWriterBase::Trace(visitor); | 115 FileWriterBase::Trace(visitor); |
116 } | 116 } |
117 | 117 |
118 } // namespace blink | 118 } // namespace blink |
OLD | NEW |