| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef FileReader_h | 31 #ifndef FileReader_h |
| 32 #define FileReader_h | 32 #define FileReader_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptWrappable.h" | 34 #include "bindings/v8/ScriptWrappable.h" |
| 35 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
| 36 #include "core/dom/EventTarget.h" | 36 #include "core/dom/EventTarget.h" |
| 37 #include "core/fileapi/FileError.h" | 37 #include "core/fileapi/FileError.h" |
| 38 #include "core/fileapi/FileReaderLoader.h" | 38 #include "core/fileapi/FileReaderLoader.h" |
| 39 #include "core/fileapi/FileReaderLoaderClient.h" | 39 #include "core/fileapi/FileReaderLoaderClient.h" |
| 40 #include "core/fileapi/Stream.h" |
| 40 #include "wtf/Forward.h" | 41 #include "wtf/Forward.h" |
| 41 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
| 42 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 43 | 44 |
| 44 namespace WebCore { | 45 namespace WebCore { |
| 45 | 46 |
| 46 class Blob; | |
| 47 class ScriptExecutionContext; | 47 class ScriptExecutionContext; |
| 48 | 48 |
| 49 typedef int ExceptionCode; | 49 typedef int ExceptionCode; |
| 50 | 50 |
| 51 class FileReader : public RefCounted<FileReader>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget, public FileReaderLoaderClient { | 51 class FileReader : public RefCounted<FileReader>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget, public FileReaderLoaderClient { |
| 52 public: | 52 public: |
| 53 static PassRefPtr<FileReader> create(ScriptExecutionContext*); | 53 static PassRefPtr<FileReader> create(ScriptExecutionContext*); |
| 54 | 54 |
| 55 virtual ~FileReader(); | 55 virtual ~FileReader(); |
| 56 | 56 |
| 57 enum ReadyState { | 57 enum ReadyState { |
| 58 EMPTY = 0, | 58 EMPTY = 0, |
| 59 LOADING = 1, | 59 LOADING = 1, |
| 60 DONE = 2 | 60 DONE = 2 |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 void readAsArrayBuffer(Blob*, ExceptionCode&); | 63 void readAsArrayBuffer(Blob*, ExceptionCode&); |
| 64 void readAsBinaryString(Blob*, ExceptionCode&); | 64 void readAsBinaryString(Blob*, ExceptionCode&); |
| 65 void readAsText(Blob*, const String& encoding, ExceptionCode&); | 65 void readAsText(Blob*, const String& encoding, ExceptionCode&); |
| 66 void readAsText(Blob*, ExceptionCode&); | 66 void readAsText(Blob*, ExceptionCode&); |
| 67 void readAsDataURL(Blob*, ExceptionCode&); | 67 void readAsDataURL(Blob*, ExceptionCode&); |
| 68 void readAsArrayBuffer(Stream*, ExceptionCode&); |
| 68 void abort(); | 69 void abort(); |
| 69 | 70 |
| 70 void doAbort(); | 71 void doAbort(); |
| 71 | 72 |
| 72 ReadyState readyState() const { return m_state; } | 73 ReadyState readyState() const { return m_state; } |
| 73 PassRefPtr<FileError> error() { return m_error; } | 74 PassRefPtr<FileError> error() { return m_error; } |
| 74 FileReaderLoader::ReadType readType() const { return m_readType; } | 75 FileReaderLoader::ReadType readType() const { return m_readType; } |
| 75 PassRefPtr<ArrayBuffer> arrayBufferResult() const; | 76 PassRefPtr<ArrayBuffer> arrayBufferResult() const; |
| 76 String stringResult(); | 77 String stringResult(); |
| 77 | 78 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 102 private: | 103 private: |
| 103 FileReader(ScriptExecutionContext*); | 104 FileReader(ScriptExecutionContext*); |
| 104 | 105 |
| 105 // EventTarget | 106 // EventTarget |
| 106 virtual void refEventTarget() { ref(); } | 107 virtual void refEventTarget() { ref(); } |
| 107 virtual void derefEventTarget() { deref(); } | 108 virtual void derefEventTarget() { deref(); } |
| 108 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } | 109 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; } |
| 109 virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData
; } | 110 virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData
; } |
| 110 | 111 |
| 111 void terminate(); | 112 void terminate(); |
| 112 void readInternal(Blob*, FileReaderLoader::ReadType, ExceptionCode&); | 113 void readInternal(Blob*, Stream*, FileReaderLoader::ReadType, ExceptionCode&
); |
| 113 void fireErrorEvent(int httpStatusCode); | 114 void fireErrorEvent(int httpStatusCode); |
| 114 void fireEvent(const AtomicString& type); | 115 void fireEvent(const AtomicString& type); |
| 115 | 116 |
| 116 ReadyState m_state; | 117 ReadyState m_state; |
| 117 bool m_aborting; | 118 bool m_aborting; |
| 118 EventTargetData m_eventTargetData; | 119 EventTargetData m_eventTargetData; |
| 119 | 120 |
| 120 RefPtr<Blob> m_blob; | 121 RefPtr<Blob> m_blob; |
| 122 RefPtr<Stream> m_stream; |
| 121 FileReaderLoader::ReadType m_readType; | 123 FileReaderLoader::ReadType m_readType; |
| 122 String m_encoding; | 124 String m_encoding; |
| 123 | 125 |
| 124 OwnPtr<FileReaderLoader> m_loader; | 126 OwnPtr<FileReaderLoader> m_loader; |
| 125 RefPtr<FileError> m_error; | 127 RefPtr<FileError> m_error; |
| 126 double m_lastProgressNotificationTimeMS; | 128 double m_lastProgressNotificationTimeMS; |
| 127 }; | 129 }; |
| 128 | 130 |
| 129 } // namespace WebCore | 131 } // namespace WebCore |
| 130 | 132 |
| 131 #endif // FileReader_h | 133 #endif // FileReader_h |
| OLD | NEW |