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 28 matching lines...) Expand all Loading... |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 FileReaderSync::FileReaderSync() | 41 FileReaderSync::FileReaderSync() |
42 { | 42 { |
43 } | 43 } |
44 | 44 |
45 DOMArrayBuffer* FileReaderSync::readAsArrayBuffer(ExecutionContext* executionCon
text, Blob* blob, ExceptionState& exceptionState) | 45 DOMArrayBuffer* FileReaderSync::readAsArrayBuffer(ExecutionContext* executionCon
text, Blob* blob, ExceptionState& exceptionState) |
46 { | 46 { |
47 ASSERT(blob); | 47 ASSERT(blob); |
48 | 48 |
49 FileReaderLoader loader(FileReaderLoader::ReadAsArrayBuffer, nullptr); | 49 std::unique_ptr<FileReaderLoader> loader = FileReaderLoader::create(FileRead
erLoader::ReadAsArrayBuffer, nullptr); |
50 startLoading(executionContext, loader, *blob, exceptionState); | 50 startLoading(executionContext, *loader, *blob, exceptionState); |
51 | 51 |
52 return loader.arrayBufferResult(); | 52 return loader->arrayBufferResult(); |
53 } | 53 } |
54 | 54 |
55 String FileReaderSync::readAsBinaryString(ExecutionContext* executionContext, Bl
ob* blob, ExceptionState& exceptionState) | 55 String FileReaderSync::readAsBinaryString(ExecutionContext* executionContext, Bl
ob* blob, ExceptionState& exceptionState) |
56 { | 56 { |
57 ASSERT(blob); | 57 ASSERT(blob); |
58 | 58 |
59 FileReaderLoader loader(FileReaderLoader::ReadAsBinaryString, 0); | 59 std::unique_ptr<FileReaderLoader> loader = FileReaderLoader::create(FileRead
erLoader::ReadAsBinaryString, nullptr); |
60 startLoading(executionContext, loader, *blob, exceptionState); | 60 startLoading(executionContext, *loader, *blob, exceptionState); |
61 return loader.stringResult(); | 61 return loader->stringResult(); |
62 } | 62 } |
63 | 63 |
64 String FileReaderSync::readAsText(ExecutionContext* executionContext, Blob* blob
, const String& encoding, ExceptionState& exceptionState) | 64 String FileReaderSync::readAsText(ExecutionContext* executionContext, Blob* blob
, const String& encoding, ExceptionState& exceptionState) |
65 { | 65 { |
66 ASSERT(blob); | 66 ASSERT(blob); |
67 | 67 |
68 FileReaderLoader loader(FileReaderLoader::ReadAsText, nullptr); | 68 std::unique_ptr<FileReaderLoader> loader = FileReaderLoader::create(FileRead
erLoader::ReadAsText, nullptr); |
69 loader.setEncoding(encoding); | 69 loader->setEncoding(encoding); |
70 startLoading(executionContext, loader, *blob, exceptionState); | 70 startLoading(executionContext, *loader, *blob, exceptionState); |
71 return loader.stringResult(); | 71 return loader->stringResult(); |
72 } | 72 } |
73 | 73 |
74 String FileReaderSync::readAsDataURL(ExecutionContext* executionContext, Blob* b
lob, ExceptionState& exceptionState) | 74 String FileReaderSync::readAsDataURL(ExecutionContext* executionContext, Blob* b
lob, ExceptionState& exceptionState) |
75 { | 75 { |
76 ASSERT(blob); | 76 ASSERT(blob); |
77 | 77 |
78 FileReaderLoader loader(FileReaderLoader::ReadAsDataURL, nullptr); | 78 std::unique_ptr<FileReaderLoader> loader = FileReaderLoader::create(FileRead
erLoader::ReadAsDataURL, nullptr); |
79 loader.setDataType(blob->type()); | 79 loader->setDataType(blob->type()); |
80 startLoading(executionContext, loader, *blob, exceptionState); | 80 startLoading(executionContext, *loader, *blob, exceptionState); |
81 return loader.stringResult(); | 81 return loader->stringResult(); |
82 } | 82 } |
83 | 83 |
84 void FileReaderSync::startLoading(ExecutionContext* executionContext, FileReader
Loader& loader, const Blob& blob, ExceptionState& exceptionState) | 84 void FileReaderSync::startLoading(ExecutionContext* executionContext, FileReader
Loader& loader, const Blob& blob, ExceptionState& exceptionState) |
85 { | 85 { |
86 loader.start(executionContext, blob.blobDataHandle()); | 86 loader.start(executionContext, blob.blobDataHandle()); |
87 if (loader.errorCode()) | 87 if (loader.errorCode()) |
88 FileError::throwDOMException(exceptionState, loader.errorCode()); | 88 FileError::throwDOMException(exceptionState, loader.errorCode()); |
89 } | 89 } |
90 | 90 |
91 } // namespace blink | 91 } // namespace blink |
OLD | NEW |