| 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef FileWriter_h | 31 #ifndef FileWriter_h |
| 32 #define FileWriter_h | 32 #define FileWriter_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ActiveScriptWrappable.h" | 34 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 35 #include "core/dom/ActiveDOMObject.h" | |
| 36 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/dom/SuspendableObject.h" |
| 37 #include "core/fileapi/FileError.h" | 37 #include "core/fileapi/FileError.h" |
| 38 #include "modules/EventTargetModules.h" | 38 #include "modules/EventTargetModules.h" |
| 39 #include "modules/filesystem/FileWriterBase.h" | 39 #include "modules/filesystem/FileWriterBase.h" |
| 40 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
| 41 #include "public/platform/WebFileWriterClient.h" | 41 #include "public/platform/WebFileWriterClient.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class Blob; | 45 class Blob; |
| 46 class ExceptionState; | 46 class ExceptionState; |
| 47 class ExecutionContext; | 47 class ExecutionContext; |
| 48 | 48 |
| 49 class FileWriter final : public EventTargetWithInlineData, | 49 class FileWriter final : public EventTargetWithInlineData, |
| 50 public FileWriterBase, | 50 public FileWriterBase, |
| 51 public ActiveScriptWrappable, | 51 public ActiveScriptWrappable, |
| 52 public ActiveDOMObject, | 52 public SuspendableObject, |
| 53 public WebFileWriterClient { | 53 public WebFileWriterClient { |
| 54 DEFINE_WRAPPERTYPEINFO(); | 54 DEFINE_WRAPPERTYPEINFO(); |
| 55 USING_GARBAGE_COLLECTED_MIXIN(FileWriter); | 55 USING_GARBAGE_COLLECTED_MIXIN(FileWriter); |
| 56 | 56 |
| 57 public: | 57 public: |
| 58 static FileWriter* create(ExecutionContext*); | 58 static FileWriter* create(ExecutionContext*); |
| 59 ~FileWriter() override; | 59 ~FileWriter() override; |
| 60 | 60 |
| 61 enum ReadyState { kInit = 0, kWriting = 1, kDone = 2 }; | 61 enum ReadyState { kInit = 0, kWriting = 1, kDone = 2 }; |
| 62 | 62 |
| 63 void write(Blob*, ExceptionState&); | 63 void write(Blob*, ExceptionState&); |
| 64 void seek(long long position, ExceptionState&); | 64 void seek(long long position, ExceptionState&); |
| 65 void truncate(long long length, ExceptionState&); | 65 void truncate(long long length, ExceptionState&); |
| 66 void abort(ExceptionState&); | 66 void abort(ExceptionState&); |
| 67 ReadyState getReadyState() const { return m_readyState; } | 67 ReadyState getReadyState() const { return m_readyState; } |
| 68 DOMException* error() const { return m_error.get(); } | 68 DOMException* error() const { return m_error.get(); } |
| 69 | 69 |
| 70 // WebFileWriterClient | 70 // WebFileWriterClient |
| 71 void didWrite(long long bytes, bool complete) override; | 71 void didWrite(long long bytes, bool complete) override; |
| 72 void didTruncate() override; | 72 void didTruncate() override; |
| 73 void didFail(WebFileError) override; | 73 void didFail(WebFileError) override; |
| 74 | 74 |
| 75 // ActiveDOMObject | 75 // SuspendableObject |
| 76 void contextDestroyed() override; | 76 void contextDestroyed() override; |
| 77 | 77 |
| 78 // ScriptWrappable | 78 // ScriptWrappable |
| 79 bool hasPendingActivity() const final; | 79 bool hasPendingActivity() const final; |
| 80 | 80 |
| 81 // EventTarget | 81 // EventTarget |
| 82 const AtomicString& interfaceName() const override; | 82 const AtomicString& interfaceName() const override; |
| 83 ExecutionContext* getExecutionContext() const override { | 83 ExecutionContext* getExecutionContext() const override { |
| 84 return ActiveDOMObject::getExecutionContext(); | 84 return SuspendableObject::getExecutionContext(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 DEFINE_ATTRIBUTE_EVENT_LISTENER(writestart); | 87 DEFINE_ATTRIBUTE_EVENT_LISTENER(writestart); |
| 88 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); | 88 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); |
| 89 DEFINE_ATTRIBUTE_EVENT_LISTENER(write); | 89 DEFINE_ATTRIBUTE_EVENT_LISTENER(write); |
| 90 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); | 90 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); |
| 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(writeend); | 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(writeend); |
| 93 | 93 |
| 94 DECLARE_VIRTUAL_TRACE(); | 94 DECLARE_VIRTUAL_TRACE(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 122 long long m_truncateLength; | 122 long long m_truncateLength; |
| 123 long long m_numAborts; | 123 long long m_numAborts; |
| 124 long long m_recursionDepth; | 124 long long m_recursionDepth; |
| 125 double m_lastProgressNotificationTimeMS; | 125 double m_lastProgressNotificationTimeMS; |
| 126 Member<Blob> m_blobBeingWritten; | 126 Member<Blob> m_blobBeingWritten; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace blink | 129 } // namespace blink |
| 130 | 130 |
| 131 #endif // FileWriter_h | 131 #endif // FileWriter_h |
| OLD | NEW |