| 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/events/EventTarget.h" | 36 #include "core/events/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 "heap/Handle.h" |
| 40 #include "wtf/Forward.h" | 41 #include "wtf/Forward.h" |
| 41 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
| 42 #include "wtf/ThreadSpecific.h" | 43 #include "wtf/ThreadSpecific.h" |
| 43 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
| 44 | 45 |
| 45 namespace WebCore { | 46 namespace WebCore { |
| 46 | 47 |
| 47 class Blob; | 48 class Blob; |
| 48 class ExceptionState; | 49 class ExceptionState; |
| 49 class ExecutionContext; | 50 class ExecutionContext; |
| 50 | 51 |
| 51 class FileReader FINAL : public RefCounted<FileReader>, public ScriptWrappable,
public ActiveDOMObject, public EventTargetWithInlineData, public FileReaderLoade
rClient { | 52 class FileReader FINAL : public RefCountedWillBeRefCountedGarbageCollected<FileR
eader>, public ScriptWrappable, public ActiveDOMObject, public FileReaderLoaderC
lient, public EventTargetWithInlineData { |
| 52 REFCOUNTED_EVENT_TARGET(FileReader); | 53 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<F
ileReader>); |
| 53 public: | 54 public: |
| 54 static PassRefPtr<FileReader> create(ExecutionContext*); | 55 static PassRefPtrWillBeRawPtr<FileReader> create(ExecutionContext*); |
| 55 | 56 |
| 56 virtual ~FileReader(); | 57 virtual ~FileReader(); |
| 57 | 58 |
| 58 enum ReadyState { | 59 enum ReadyState { |
| 59 EMPTY = 0, | 60 EMPTY = 0, |
| 60 LOADING = 1, | 61 LOADING = 1, |
| 61 DONE = 2 | 62 DONE = 2 |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 void readAsArrayBuffer(Blob*, ExceptionState&); | 65 void readAsArrayBuffer(Blob*, ExceptionState&); |
| 65 void readAsBinaryString(Blob*, ExceptionState&); | 66 void readAsBinaryString(Blob*, ExceptionState&); |
| 66 void readAsText(Blob*, const String& encoding, ExceptionState&); | 67 void readAsText(Blob*, const String& encoding, ExceptionState&); |
| 67 void readAsText(Blob*, ExceptionState&); | 68 void readAsText(Blob*, ExceptionState&); |
| 68 void readAsDataURL(Blob*, ExceptionState&); | 69 void readAsDataURL(Blob*, ExceptionState&); |
| 69 void abort(); | 70 void abort(); |
| 70 | 71 |
| 71 void doAbort(); | 72 void doAbort(); |
| 72 | 73 |
| 73 ReadyState readyState() const { return m_state; } | 74 ReadyState readyState() const { return m_state; } |
| 74 PassRefPtr<FileError> error() { return m_error; } | 75 PassRefPtrWillBeRawPtr<FileError> error() { return m_error; } |
| 75 FileReaderLoader::ReadType readType() const { return m_readType; } | 76 FileReaderLoader::ReadType readType() const { return m_readType; } |
| 76 PassRefPtr<ArrayBuffer> arrayBufferResult() const; | 77 PassRefPtr<ArrayBuffer> arrayBufferResult() const; |
| 77 String stringResult(); | 78 String stringResult(); |
| 78 | 79 |
| 79 // ActiveDOMObject | 80 // ActiveDOMObject |
| 80 virtual void stop() OVERRIDE; | 81 virtual void stop() OVERRIDE; |
| 81 | 82 |
| 82 // EventTarget | 83 // EventTarget |
| 83 virtual const AtomicString& interfaceName() const OVERRIDE; | 84 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 84 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } | 85 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } |
| 85 | 86 |
| 86 // FileReaderLoaderClient | 87 // FileReaderLoaderClient |
| 87 virtual void didStartLoading() OVERRIDE; | 88 virtual void didStartLoading() OVERRIDE; |
| 88 virtual void didReceiveData() OVERRIDE; | 89 virtual void didReceiveData() OVERRIDE; |
| 89 virtual void didFinishLoading() OVERRIDE; | 90 virtual void didFinishLoading() OVERRIDE; |
| 90 virtual void didFail(FileError::ErrorCode) OVERRIDE; | 91 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 91 | 92 |
| 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); | 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); |
| 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); | 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); |
| 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(load); | 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(load); |
| 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); | 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); |
| 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend); | 98 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend); |
| 98 | 99 |
| 100 void trace(Visitor*); |
| 101 |
| 99 private: | 102 private: |
| 100 class ThrottlingController; | 103 class ThrottlingController; |
| 101 | 104 |
| 102 FileReader(ExecutionContext*); | 105 FileReader(ExecutionContext*); |
| 103 | 106 |
| 104 void terminate(); | 107 void terminate(); |
| 105 void readInternal(Blob*, FileReaderLoader::ReadType, ExceptionState&); | 108 void readInternal(Blob*, FileReaderLoader::ReadType, ExceptionState&); |
| 106 void fireErrorEvent(int httpStatusCode); | 109 void fireErrorEvent(int httpStatusCode); |
| 107 void fireEvent(const AtomicString& type); | 110 void fireEvent(const AtomicString& type); |
| 108 | 111 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 LoadingStateAborted | 123 LoadingStateAborted |
| 121 }; | 124 }; |
| 122 LoadingState m_loadingState; | 125 LoadingState m_loadingState; |
| 123 | 126 |
| 124 String m_blobType; | 127 String m_blobType; |
| 125 RefPtr<BlobDataHandle> m_blobDataHandle; | 128 RefPtr<BlobDataHandle> m_blobDataHandle; |
| 126 FileReaderLoader::ReadType m_readType; | 129 FileReaderLoader::ReadType m_readType; |
| 127 String m_encoding; | 130 String m_encoding; |
| 128 | 131 |
| 129 OwnPtr<FileReaderLoader> m_loader; | 132 OwnPtr<FileReaderLoader> m_loader; |
| 130 RefPtr<FileError> m_error; | 133 RefPtrWillBeMember<FileError> m_error; |
| 131 double m_lastProgressNotificationTimeMS; | 134 double m_lastProgressNotificationTimeMS; |
| 132 }; | 135 }; |
| 133 | 136 |
| 134 } // namespace WebCore | 137 } // namespace WebCore |
| 135 | 138 |
| 136 #endif // FileReader_h | 139 #endif // FileReader_h |
| OLD | NEW |