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

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

Issue 17761003: Remove FileException (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile warning Created 7 years, 5 months 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 | Annotate | Revision Log
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 "core/dom/ExceptionCode.h"
35 #include "core/fileapi/Blob.h" 36 #include "core/fileapi/Blob.h"
36 #include "core/fileapi/FileException.h"
37 #include "modules/filesystem/AsyncFileWriter.h" 37 #include "modules/filesystem/AsyncFileWriter.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 void FileWriterSync::write(Blob* data, ExceptionCode& ec) 41 void FileWriterSync::write(Blob* data, ExceptionCode& ec)
42 { 42 {
43 ASSERT(writer()); 43 ASSERT(writer());
44 ASSERT(m_complete); 44 ASSERT(m_complete);
45 ec = 0; 45 ec = 0;
46 if (!data) { 46 if (!data) {
47 ec = FileException::TYPE_MISMATCH_ERR; 47 ec = FSTypeMismatchError;
48 return; 48 return;
49 } 49 }
50 50
51 prepareForWrite(); 51 prepareForWrite();
52 writer()->write(position(), data); 52 writer()->write(position(), data);
53 writer()->waitForOperationToComplete(); 53 writer()->waitForOperationToComplete();
54 ASSERT(m_complete); 54 ASSERT(m_complete);
55 ec = FileException::ErrorCodeToExceptionCode(m_error); 55 ec = FileError::ErrorCodeToExceptionCode(m_error);
56 if (ec) 56 if (ec)
57 return; 57 return;
58 setPosition(position() + data->size()); 58 setPosition(position() + data->size());
59 if (position() > length()) 59 if (position() > length())
60 setLength(position()); 60 setLength(position());
61 } 61 }
62 62
63 void FileWriterSync::seek(long long position, ExceptionCode& ec) 63 void FileWriterSync::seek(long long position, ExceptionCode& ec)
64 { 64 {
65 ASSERT(writer()); 65 ASSERT(writer());
66 ASSERT(m_complete); 66 ASSERT(m_complete);
67 ec = 0; 67 ec = 0;
68 seekInternal(position); 68 seekInternal(position);
69 } 69 }
70 70
71 void FileWriterSync::truncate(long long offset, ExceptionCode& ec) 71 void FileWriterSync::truncate(long long offset, ExceptionCode& ec)
72 { 72 {
73 ASSERT(writer()); 73 ASSERT(writer());
74 ASSERT(m_complete); 74 ASSERT(m_complete);
75 ec = 0; 75 ec = 0;
76 if (offset < 0) { 76 if (offset < 0) {
77 ec = FileException::INVALID_STATE_ERR; 77 ec = FSInvalidStateError;
78 return; 78 return;
79 } 79 }
80 prepareForWrite(); 80 prepareForWrite();
81 writer()->truncate(offset); 81 writer()->truncate(offset);
82 writer()->waitForOperationToComplete(); 82 writer()->waitForOperationToComplete();
83 ASSERT(m_complete); 83 ASSERT(m_complete);
84 ec = FileException::ErrorCodeToExceptionCode(m_error); 84 ec = FileError::ErrorCodeToExceptionCode(m_error);
85 if (ec) 85 if (ec)
86 return; 86 return;
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
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
OLDNEW
« no previous file with comments | « Source/modules/filesystem/FileWriterBase.cpp ('k') | Source/modules/filesystem/SyncCallbackHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698