| 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 30 matching lines...) Expand all Loading... |
| 41 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
| 42 #include "wtf/ThreadSpecific.h" | 42 #include "wtf/ThreadSpecific.h" |
| 43 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 class Blob; | 47 class Blob; |
| 48 class ExceptionState; | 48 class ExceptionState; |
| 49 class ExecutionContext; | 49 class ExecutionContext; |
| 50 | 50 |
| 51 class FileReader : public RefCounted<FileReader>, public ScriptWrappable, public
ActiveDOMObject, public EventTargetWithInlineData, public FileReaderLoaderClien
t { | 51 class FileReader FINAL : public RefCounted<FileReader>, public ScriptWrappable,
public ActiveDOMObject, public EventTargetWithInlineData, public FileReaderLoade
rClient { |
| 52 REFCOUNTED_EVENT_TARGET(FileReader); | 52 REFCOUNTED_EVENT_TARGET(FileReader); |
| 53 public: | 53 public: |
| 54 static PassRefPtr<FileReader> create(ExecutionContext*); | 54 static PassRefPtr<FileReader> create(ExecutionContext*); |
| 55 | 55 |
| 56 virtual ~FileReader(); | 56 virtual ~FileReader(); |
| 57 | 57 |
| 58 enum ReadyState { | 58 enum ReadyState { |
| 59 EMPTY = 0, | 59 EMPTY = 0, |
| 60 LOADING = 1, | 60 LOADING = 1, |
| 61 DONE = 2 | 61 DONE = 2 |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 void readAsArrayBuffer(Blob*, ExceptionState&); | 64 void readAsArrayBuffer(Blob*, ExceptionState&); |
| 65 void readAsBinaryString(Blob*, ExceptionState&); | 65 void readAsBinaryString(Blob*, ExceptionState&); |
| 66 void readAsText(Blob*, const String& encoding, ExceptionState&); | 66 void readAsText(Blob*, const String& encoding, ExceptionState&); |
| 67 void readAsText(Blob*, ExceptionState&); | 67 void readAsText(Blob*, ExceptionState&); |
| 68 void readAsDataURL(Blob*, ExceptionState&); | 68 void readAsDataURL(Blob*, ExceptionState&); |
| 69 void abort(); | 69 void abort(); |
| 70 | 70 |
| 71 void doAbort(); | 71 void doAbort(); |
| 72 | 72 |
| 73 ReadyState readyState() const { return m_state; } | 73 ReadyState readyState() const { return m_state; } |
| 74 PassRefPtr<FileError> error() { return m_error; } | 74 PassRefPtr<FileError> error() { return m_error; } |
| 75 FileReaderLoader::ReadType readType() const { return m_readType; } | 75 FileReaderLoader::ReadType readType() const { return m_readType; } |
| 76 PassRefPtr<ArrayBuffer> arrayBufferResult() const; | 76 PassRefPtr<ArrayBuffer> arrayBufferResult() const; |
| 77 String stringResult(); | 77 String stringResult(); |
| 78 | 78 |
| 79 // ActiveDOMObject | 79 // ActiveDOMObject |
| 80 virtual void stop(); | 80 virtual void stop() OVERRIDE; |
| 81 | 81 |
| 82 // EventTarget | 82 // EventTarget |
| 83 virtual const AtomicString& interfaceName() const OVERRIDE; | 83 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 84 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } | 84 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } |
| 85 | 85 |
| 86 // FileReaderLoaderClient | 86 // FileReaderLoaderClient |
| 87 virtual void didStartLoading(); | 87 virtual void didStartLoading() OVERRIDE; |
| 88 virtual void didReceiveData(); | 88 virtual void didReceiveData() OVERRIDE; |
| 89 virtual void didFinishLoading(); | 89 virtual void didFinishLoading() OVERRIDE; |
| 90 virtual void didFail(FileError::ErrorCode); | 90 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 91 | 91 |
| 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); | 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); |
| 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); | 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); |
| 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(load); | 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(load); |
| 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); | 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); |
| 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend); | 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 class ThrottlingController; | 100 class ThrottlingController; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 126 String m_encoding; | 126 String m_encoding; |
| 127 | 127 |
| 128 OwnPtr<FileReaderLoader> m_loader; | 128 OwnPtr<FileReaderLoader> m_loader; |
| 129 RefPtr<FileError> m_error; | 129 RefPtr<FileError> m_error; |
| 130 double m_lastProgressNotificationTimeMS; | 130 double m_lastProgressNotificationTimeMS; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace WebCore | 133 } // namespace WebCore |
| 134 | 134 |
| 135 #endif // FileReader_h | 135 #endif // FileReader_h |
| OLD | NEW |