Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: Source/modules/filesystem/FileWriter.h

Issue 26878003: Reduce repetitive EventTarget subclassing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nit Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/encryptedmedia/MediaKeySession.h ('k') | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 #include "public/platform/WebFileWriterClient.h" 40 #include "public/platform/WebFileWriterClient.h"
41 #include "wtf/PassRefPtr.h" 41 #include "wtf/PassRefPtr.h"
42 #include "wtf/RefPtr.h" 42 #include "wtf/RefPtr.h"
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 class Blob; 46 class Blob;
47 class ExceptionState; 47 class ExceptionState;
48 class ScriptExecutionContext; 48 class ScriptExecutionContext;
49 49
50 class FileWriter : public ScriptWrappable, public FileWriterBase, public ActiveD OMObject, public EventTarget, public WebKit::WebFileWriterClient { 50 class FileWriter : public ScriptWrappable, public FileWriterBase, public ActiveD OMObject, public EventTargetWithInlineData, public WebKit::WebFileWriterClient {
51 public: 51 public:
52 static PassRefPtr<FileWriter> create(ScriptExecutionContext*); 52 static PassRefPtr<FileWriter> create(ScriptExecutionContext*);
53 53
54 enum ReadyState { 54 enum ReadyState {
55 INIT = 0, 55 INIT = 0,
56 WRITING = 1, 56 WRITING = 1,
57 DONE = 2 57 DONE = 2
58 }; 58 };
59 59
60 void write(Blob*, ExceptionState&); 60 void write(Blob*, ExceptionState&);
61 void seek(long long position, ExceptionState&); 61 void seek(long long position, ExceptionState&);
62 void truncate(long long length, ExceptionState&); 62 void truncate(long long length, ExceptionState&);
63 void abort(ExceptionState&); 63 void abort(ExceptionState&);
64 ReadyState readyState() const { return m_readyState; } 64 ReadyState readyState() const { return m_readyState; }
65 FileError* error() const { return m_error.get(); } 65 FileError* error() const { return m_error.get(); }
66 66
67 // WebFileWriterClient 67 // WebFileWriterClient
68 virtual void didWrite(long long bytes, bool complete) OVERRIDE; 68 virtual void didWrite(long long bytes, bool complete) OVERRIDE;
69 virtual void didTruncate() OVERRIDE; 69 virtual void didTruncate() OVERRIDE;
70 virtual void didFail(WebKit::WebFileError) OVERRIDE; 70 virtual void didFail(WebKit::WebFileError) OVERRIDE;
71 71
72 // ActiveDOMObject 72 // ActiveDOMObject
73 virtual bool canSuspend() const; 73 virtual bool canSuspend() const;
74 virtual void stop(); 74 virtual void stop();
75 75
76 // EventTarget 76 // EventTarget
77 virtual const AtomicString& interfaceName() const; 77 virtual const AtomicString& interfaceName() const OVERRIDE;
78 virtual ScriptExecutionContext* scriptExecutionContext() const { return Acti veDOMObject::scriptExecutionContext(); } 78 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re turn ActiveDOMObject::scriptExecutionContext(); }
79 79
80 using RefCounted<FileWriterBase>::ref; 80 using RefCounted<FileWriterBase>::ref;
81 using RefCounted<FileWriterBase>::deref; 81 using RefCounted<FileWriterBase>::deref;
82 82
83 DEFINE_ATTRIBUTE_EVENT_LISTENER(writestart); 83 DEFINE_ATTRIBUTE_EVENT_LISTENER(writestart);
84 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); 84 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress);
85 DEFINE_ATTRIBUTE_EVENT_LISTENER(write); 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(write);
86 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
87 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 87 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
88 DEFINE_ATTRIBUTE_EVENT_LISTENER(writeend); 88 DEFINE_ATTRIBUTE_EVENT_LISTENER(writeend);
89 89
90 private: 90 private:
91 enum Operation { 91 enum Operation {
92 OperationNone, 92 OperationNone,
93 OperationWrite, 93 OperationWrite,
94 OperationTruncate, 94 OperationTruncate,
95 OperationAbort 95 OperationAbort
96 }; 96 };
97 97
98 FileWriter(ScriptExecutionContext*); 98 FileWriter(ScriptExecutionContext*);
99 99
100 virtual ~FileWriter(); 100 virtual ~FileWriter();
101 101
102 // EventTarget 102 // EventTarget
103 virtual void refEventTarget() { ref(); } 103 virtual void refEventTarget() OVERRIDE { ref(); }
104 virtual void derefEventTarget() { deref(); } 104 virtual void derefEventTarget() OVERRIDE { deref(); }
105 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
106 virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData ; }
107 105
108 void completeAbort(); 106 void completeAbort();
109 107
110 void doOperation(Operation); 108 void doOperation(Operation);
111 109
112 void signalCompletion(FileError::ErrorCode); 110 void signalCompletion(FileError::ErrorCode);
113 111
114 void fireEvent(const AtomicString& type); 112 void fireEvent(const AtomicString& type);
115 113
116 void setError(FileError::ErrorCode, ExceptionState&); 114 void setError(FileError::ErrorCode, ExceptionState&);
117 115
118 RefPtr<FileError> m_error; 116 RefPtr<FileError> m_error;
119 EventTargetData m_eventTargetData;
120 ReadyState m_readyState; 117 ReadyState m_readyState;
121 Operation m_operationInProgress; 118 Operation m_operationInProgress;
122 Operation m_queuedOperation; 119 Operation m_queuedOperation;
123 long long m_bytesWritten; 120 long long m_bytesWritten;
124 long long m_bytesToWrite; 121 long long m_bytesToWrite;
125 long long m_truncateLength; 122 long long m_truncateLength;
126 long long m_numAborts; 123 long long m_numAborts;
127 long long m_recursionDepth; 124 long long m_recursionDepth;
128 double m_lastProgressNotificationTimeMS; 125 double m_lastProgressNotificationTimeMS;
129 RefPtr<Blob> m_blobBeingWritten; 126 RefPtr<Blob> m_blobBeingWritten;
130 }; 127 };
131 128
132 } // namespace WebCore 129 } // namespace WebCore
133 130
134 #endif // FileWriter_h 131 #endif // FileWriter_h
OLDNEW
« no previous file with comments | « Source/modules/encryptedmedia/MediaKeySession.h ('k') | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698