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

Side by Side Diff: Source/core/fileapi/File.cpp

Issue 337343002: IDL: make optional arguments (without default) explicit sometimes Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-default-arguments-next
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/core/fileapi/File.h ('k') | Source/core/frame/ConsoleBase.idl » ('j') | 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return m_snapshotSize; 209 return m_snapshotSize;
210 210
211 // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to 211 // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to
212 // come up with an exception to throw if file size is not representable. 212 // come up with an exception to throw if file size is not representable.
213 long long size; 213 long long size;
214 if (!hasBackingFile() || !getFileSize(m_path, size)) 214 if (!hasBackingFile() || !getFileSize(m_path, size))
215 return 0; 215 return 0;
216 return static_cast<unsigned long long>(size); 216 return static_cast<unsigned long long>(size);
217 } 217 }
218 218
219 PassRefPtrWillBeRawPtr<Blob> File::slice(long long start, long long end, const S tring& contentType, ExceptionState& exceptionState) const 219 PassRefPtrWillBeRawPtr<Blob> File::slice(long long start, Optional<long long> op tionalEnd, const String& contentType, ExceptionState& exceptionState) const
220 { 220 {
221 if (hasBeenClosed()) { 221 if (hasBeenClosed()) {
222 exceptionState.throwDOMException(InvalidStateError, "File has been close d."); 222 exceptionState.throwDOMException(InvalidStateError, "File has been close d.");
223 return nullptr; 223 return nullptr;
224 } 224 }
225 225
226 if (!m_hasBackingFile) 226 if (!m_hasBackingFile)
227 return Blob::slice(start, end, contentType, exceptionState); 227 return Blob::slice(start, optionalEnd, contentType, exceptionState);
228
229 long long end = optionalEnd.isMissing() ? std::numeric_limits<long long>::ma x() : optionalEnd.get();
228 230
229 // FIXME: This involves synchronous file operation. We need to figure out ho w to make it asynchronous. 231 // FIXME: This involves synchronous file operation. We need to figure out ho w to make it asynchronous.
230 long long size; 232 long long size;
231 double modificationTime; 233 double modificationTime;
232 captureSnapshot(size, modificationTime); 234 captureSnapshot(size, modificationTime);
233 clampSliceOffsets(size, start, end); 235 clampSliceOffsets(size, start, end);
234 236
235 long long length = end - start; 237 long long length = end - start;
236 OwnPtr<BlobData> blobData = BlobData::create(); 238 OwnPtr<BlobData> blobData = BlobData::create();
237 blobData->setContentType(contentType); 239 blobData->setContentType(contentType);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 captureSnapshot(size, modificationTime); 298 captureSnapshot(size, modificationTime);
297 if (!m_fileSystemURL.isEmpty()) { 299 if (!m_fileSystemURL.isEmpty()) {
298 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime) ; 300 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime) ;
299 return; 301 return;
300 } 302 }
301 ASSERT(!m_path.isEmpty()); 303 ASSERT(!m_path.isEmpty());
302 blobData.appendFile(m_path, 0, size, modificationTime); 304 blobData.appendFile(m_path, 0, size, modificationTime);
303 } 305 }
304 306
305 } // namespace blink 307 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fileapi/File.h ('k') | Source/core/frame/ConsoleBase.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698