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

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

Issue 2524813003: WebKit: remove DCHECK_IS_ON from FileWriterSync. (Closed)
Patch Set: Reverted "Guard with #ifdefs" Created 4 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
« no previous file with comments | « third_party/WebKit/Source/modules/filesystem/FileWriterSync.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
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 DCHECK(m_complete);
45 45
46 prepareForWrite(); 46 prepareForWrite();
47 writer()->write(position(), data->uuid()); 47 writer()->write(position(), data->uuid());
48 ASSERT(m_complete); 48 DCHECK(m_complete);
49 if (m_error) { 49 if (m_error) {
50 FileError::throwDOMException(exceptionState, m_error); 50 FileError::throwDOMException(exceptionState, m_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& exceptionState) { 58 void FileWriterSync::seek(long long position, ExceptionState& exceptionState) {
59 ASSERT(writer()); 59 ASSERT(writer());
60 ASSERT(m_complete); 60 DCHECK(m_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& exceptionState) { 65 ExceptionState& exceptionState) {
66 ASSERT(writer()); 66 ASSERT(writer());
67 ASSERT(m_complete); 67 DCHECK(m_complete);
68 if (offset < 0) { 68 if (offset < 0) {
69 exceptionState.throwDOMException(InvalidStateError, 69 exceptionState.throwDOMException(InvalidStateError,
70 FileError::invalidStateErrorMessage); 70 FileError::invalidStateErrorMessage);
71 return; 71 return;
72 } 72 }
73 prepareForWrite(); 73 prepareForWrite();
74 writer()->truncate(offset); 74 writer()->truncate(offset);
75 ASSERT(m_complete); 75 DCHECK(m_complete);
76 if (m_error) { 76 if (m_error) {
77 FileError::throwDOMException(exceptionState, m_error); 77 FileError::throwDOMException(exceptionState, m_error);
78 return; 78 return;
79 } 79 }
80 if (offset < position()) 80 if (offset < position())
81 setPosition(offset); 81 setPosition(offset);
82 setLength(offset); 82 setLength(offset);
83 } 83 }
84 84
85 void FileWriterSync::didWrite(long long bytes, bool complete) { 85 void FileWriterSync::didWrite(long long bytes, bool complete) {
86 DCHECK_EQ(FileError::kOK, m_error); 86 DCHECK_EQ(FileError::kOK, m_error);
87 #if DCHECK_IS_ON()
88 DCHECK(!m_complete); 87 DCHECK(!m_complete);
89 m_complete = complete; 88 m_complete = complete;
90 #endif
91 } 89 }
92 90
93 void FileWriterSync::didTruncate() { 91 void FileWriterSync::didTruncate() {
94 DCHECK_EQ(FileError::kOK, m_error); 92 DCHECK_EQ(FileError::kOK, m_error);
95 #if DCHECK_IS_ON()
96 DCHECK(!m_complete); 93 DCHECK(!m_complete);
97 m_complete = true; 94 m_complete = true;
98 #endif
99 } 95 }
100 96
101 void FileWriterSync::didFail(WebFileError error) { 97 void FileWriterSync::didFail(WebFileError error) {
102 DCHECK_EQ(FileError::kOK, m_error); 98 DCHECK_EQ(FileError::kOK, m_error);
103 m_error = static_cast<FileError::ErrorCode>(error); 99 m_error = static_cast<FileError::ErrorCode>(error);
104 #if DCHECK_IS_ON()
105 DCHECK(!m_complete); 100 DCHECK(!m_complete);
106 m_complete = true; 101 m_complete = true;
107 #endif
108 } 102 }
109 103
110 FileWriterSync::FileWriterSync() 104 FileWriterSync::FileWriterSync() : m_error(FileError::kOK), m_complete(true) {}
111 : m_error(FileError::kOK)
112 #if DCHECK_IS_ON()
113 ,
114 m_complete(true)
115 #endif
116 {
117 }
118 105
119 void FileWriterSync::prepareForWrite() { 106 void FileWriterSync::prepareForWrite() {
120 #if DCHECK_IS_ON()
121 DCHECK(m_complete); 107 DCHECK(m_complete);
122 #endif
123 m_error = FileError::kOK; 108 m_error = FileError::kOK;
124 #if DCHECK_IS_ON()
125 m_complete = false; 109 m_complete = false;
126 #endif
127 } 110 }
128 111
129 FileWriterSync::~FileWriterSync() {} 112 FileWriterSync::~FileWriterSync() {}
130 113
131 DEFINE_TRACE(FileWriterSync) { 114 DEFINE_TRACE(FileWriterSync) {
132 FileWriterBase::trace(visitor); 115 FileWriterBase::trace(visitor);
133 } 116 }
134 117
135 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/filesystem/FileWriterSync.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698