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

Side by Side Diff: Source/core/fileapi/FileReader.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/core/events/EventTarget.cpp ('k') | Source/core/html/MediaController.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 "wtf/Forward.h" 40 #include "wtf/Forward.h"
41 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
42 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.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 FileReader : public RefCounted<FileReader>, public ScriptWrappable, public ActiveDOMObject, public EventTarget, public FileReaderLoaderClient { 50 class FileReader : public RefCounted<FileReader>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInlineData, public FileReaderLoaderClien t {
51 public: 51 public:
52 static PassRefPtr<FileReader> create(ScriptExecutionContext*); 52 static PassRefPtr<FileReader> create(ScriptExecutionContext*);
53 53
54 virtual ~FileReader(); 54 virtual ~FileReader();
55 55
56 enum ReadyState { 56 enum ReadyState {
57 EMPTY = 0, 57 EMPTY = 0,
58 LOADING = 1, 58 LOADING = 1,
59 DONE = 2 59 DONE = 2
60 }; 60 };
(...skipping 11 matching lines...) Expand all
72 PassRefPtr<FileError> error() { return m_error; } 72 PassRefPtr<FileError> error() { return m_error; }
73 FileReaderLoader::ReadType readType() const { return m_readType; } 73 FileReaderLoader::ReadType readType() const { return m_readType; }
74 PassRefPtr<ArrayBuffer> arrayBufferResult() const; 74 PassRefPtr<ArrayBuffer> arrayBufferResult() const;
75 String stringResult(); 75 String stringResult();
76 76
77 // ActiveDOMObject 77 // ActiveDOMObject
78 virtual bool canSuspend() const; 78 virtual bool canSuspend() const;
79 virtual void stop(); 79 virtual void stop();
80 80
81 // EventTarget 81 // EventTarget
82 virtual const AtomicString& interfaceName() const; 82 virtual const AtomicString& interfaceName() const OVERRIDE;
83 virtual ScriptExecutionContext* scriptExecutionContext() const { return Acti veDOMObject::scriptExecutionContext(); } 83 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re turn ActiveDOMObject::scriptExecutionContext(); }
84 84
85 // FileReaderLoaderClient 85 // FileReaderLoaderClient
86 virtual void didStartLoading(); 86 virtual void didStartLoading();
87 virtual void didReceiveData(); 87 virtual void didReceiveData();
88 virtual void didFinishLoading(); 88 virtual void didFinishLoading();
89 virtual void didFail(FileError::ErrorCode); 89 virtual void didFail(FileError::ErrorCode);
90 90
91 using RefCounted<FileReader>::ref; 91 using RefCounted<FileReader>::ref;
92 using RefCounted<FileReader>::deref; 92 using RefCounted<FileReader>::deref;
93 93
94 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart);
95 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress);
96 DEFINE_ATTRIBUTE_EVENT_LISTENER(load); 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(load);
97 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
98 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 98 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
99 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend); 99 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend);
100 100
101 private: 101 private:
102 FileReader(ScriptExecutionContext*); 102 FileReader(ScriptExecutionContext*);
103 103
104 // EventTarget 104 // EventTarget
105 virtual void refEventTarget() { ref(); } 105 virtual void refEventTarget() OVERRIDE { ref(); }
106 virtual void derefEventTarget() { deref(); } 106 virtual void derefEventTarget() OVERRIDE { deref(); }
107 virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
108 virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData ; }
109 107
110 void terminate(); 108 void terminate();
111 void readInternal(Blob*, FileReaderLoader::ReadType, ExceptionState&); 109 void readInternal(Blob*, FileReaderLoader::ReadType, ExceptionState&);
112 void fireErrorEvent(int httpStatusCode); 110 void fireErrorEvent(int httpStatusCode);
113 void fireEvent(const AtomicString& type); 111 void fireEvent(const AtomicString& type);
114 112
115 ReadyState m_state; 113 ReadyState m_state;
116 114
117 // Internal loading state, which could differ from ReadyState as it's 115 // Internal loading state, which could differ from ReadyState as it's
118 // for script-visible state while this one's for internal state. 116 // for script-visible state while this one's for internal state.
119 enum LoadingState { 117 enum LoadingState {
120 LoadingStateNone, 118 LoadingStateNone,
121 LoadingStateLoading, 119 LoadingStateLoading,
122 LoadingStateAborted 120 LoadingStateAborted
123 }; 121 };
124 LoadingState m_loadingState; 122 LoadingState m_loadingState;
125 123
126 EventTargetData m_eventTargetData;
127
128 RefPtr<Blob> m_blob; 124 RefPtr<Blob> m_blob;
129 FileReaderLoader::ReadType m_readType; 125 FileReaderLoader::ReadType m_readType;
130 String m_encoding; 126 String m_encoding;
131 127
132 OwnPtr<FileReaderLoader> m_loader; 128 OwnPtr<FileReaderLoader> m_loader;
133 RefPtr<FileError> m_error; 129 RefPtr<FileError> m_error;
134 double m_lastProgressNotificationTimeMS; 130 double m_lastProgressNotificationTimeMS;
135 }; 131 };
136 132
137 } // namespace WebCore 133 } // namespace WebCore
138 134
139 #endif // FileReader_h 135 #endif // FileReader_h
OLDNEW
« no previous file with comments | « Source/core/events/EventTarget.cpp ('k') | Source/core/html/MediaController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698