Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: Source/modules/filesystem/FileWriterSync.cpp

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 "config.h" 31 #include "config.h"
32 32
33 #include "modules/filesystem/FileWriterSync.h" 33 #include "modules/filesystem/FileWriterSync.h"
34 34
35 #include "bindings/v8/ExceptionMessages.h"
36 #include "bindings/v8/ExceptionState.h" 35 #include "bindings/v8/ExceptionState.h"
37 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
38 #include "core/fileapi/Blob.h" 37 #include "core/fileapi/Blob.h"
39 #include "public/platform/WebFileWriter.h" 38 #include "public/platform/WebFileWriter.h"
40 #include "public/platform/WebURL.h" 39 #include "public/platform/WebURL.h"
41 40
42 namespace WebCore { 41 namespace WebCore {
43 42
44 void FileWriterSync::write(Blob* data, ExceptionState& exceptionState) 43 void FileWriterSync::write(Blob* data, ExceptionState& exceptionState)
45 { 44 {
46 ASSERT(writer()); 45 ASSERT(writer());
47 ASSERT(m_complete); 46 ASSERT(m_complete);
48 if (!data) { 47 if (!data) {
49 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::f ailedToExecute("write", "FileReaderSync", FileError::typeMismatchErrorMessage)); 48 exceptionState.throwDOMException(TypeMismatchError, FileError::typeMisma tchErrorMessage);
50 return; 49 return;
51 } 50 }
52 51
53 prepareForWrite(); 52 prepareForWrite();
54 writer()->write(position(), data->uuid()); 53 writer()->write(position(), data->uuid());
55 ASSERT(m_complete); 54 ASSERT(m_complete);
56 if (m_error) { 55 if (m_error) {
57 FileError::throwDOMException(exceptionState, m_error); 56 FileError::throwDOMException(exceptionState, m_error);
58 return; 57 return;
59 } 58 }
60 setPosition(position() + data->size()); 59 setPosition(position() + data->size());
61 if (position() > length()) 60 if (position() > length())
62 setLength(position()); 61 setLength(position());
63 } 62 }
64 63
65 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) 64 void FileWriterSync::seek(long long position, ExceptionState& exceptionState)
66 { 65 {
67 ASSERT(writer()); 66 ASSERT(writer());
68 ASSERT(m_complete); 67 ASSERT(m_complete);
69 seekInternal(position); 68 seekInternal(position);
70 } 69 }
71 70
72 void FileWriterSync::truncate(long long offset, ExceptionState& exceptionState) 71 void FileWriterSync::truncate(long long offset, ExceptionState& exceptionState)
73 { 72 {
74 ASSERT(writer()); 73 ASSERT(writer());
75 ASSERT(m_complete); 74 ASSERT(m_complete);
76 if (offset < 0) { 75 if (offset < 0) {
77 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("truncate", "FileWriterSync", FileError::invalidStateErrorMessage )); 76 exceptionState.throwDOMException(InvalidStateError, FileError::invalidSt ateErrorMessage);
78 return; 77 return;
79 } 78 }
80 prepareForWrite(); 79 prepareForWrite();
81 writer()->truncate(offset); 80 writer()->truncate(offset);
82 ASSERT(m_complete); 81 ASSERT(m_complete);
83 if (m_error) { 82 if (m_error) {
84 FileError::throwDOMException(exceptionState, m_error); 83 FileError::throwDOMException(exceptionState, m_error);
85 return; 84 return;
86 } 85 }
87 if (offset < position()) 86 if (offset < position())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 m_complete = false; 135 m_complete = false;
137 #endif 136 #endif
138 } 137 }
139 138
140 FileWriterSync::~FileWriterSync() 139 FileWriterSync::~FileWriterSync()
141 { 140 {
142 } 141 }
143 142
144 143
145 } // namespace WebCore 144 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/filesystem/DirectoryReaderSync.cpp ('k') | Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698