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

Side by Side Diff: Source/core/dom/MessagePort.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/css/FontFaceSet.cpp ('k') | Source/core/dom/MessagePort.cpp » ('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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 class Event; 43 class Event;
44 class ExceptionState; 44 class ExceptionState;
45 class Frame; 45 class Frame;
46 class MessagePort; 46 class MessagePort;
47 class ScriptExecutionContext; 47 class ScriptExecutionContext;
48 48
49 // The overwhelmingly common case is sending a single port, so handle that effic iently with an inline buffer of size 1. 49 // The overwhelmingly common case is sending a single port, so handle that effic iently with an inline buffer of size 1.
50 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; 50 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
51 51
52 class MessagePort : public RefCounted<MessagePort>, public ScriptWrappable, publ ic EventTarget { 52 class MessagePort : public RefCounted<MessagePort>, public ScriptWrappable, publ ic EventTargetWithInlineData {
53 public: 53 public:
54 static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutio nContext) { return adoptRef(new MessagePort(scriptExecutionContext)); } 54 static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutio nContext) { return adoptRef(new MessagePort(scriptExecutionContext)); }
55 virtual ~MessagePort(); 55 virtual ~MessagePort();
56 56
57 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor tArray*, ExceptionState&); 57 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor tArray*, ExceptionState&);
58 58
59 void start(); 59 void start();
60 void close(); 60 void close();
61 61
62 void entangle(PassRefPtr<MessagePortChannel>); 62 void entangle(PassRefPtr<MessagePortChannel>);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool isEntangled() { return !m_closed && !isNeutered(); } 95 bool isEntangled() { return !m_closed && !isNeutered(); }
96 96
97 // A port gets neutered when it is transferred to a new owner via postMessag e(). 97 // A port gets neutered when it is transferred to a new owner via postMessag e().
98 bool isNeutered() { return !m_entangledChannel; } 98 bool isNeutered() { return !m_entangledChannel; }
99 99
100 private: 100 private:
101 explicit MessagePort(ScriptExecutionContext&); 101 explicit MessagePort(ScriptExecutionContext&);
102 102
103 virtual void refEventTarget() OVERRIDE { ref(); } 103 virtual void refEventTarget() OVERRIDE { ref(); }
104 virtual void derefEventTarget() OVERRIDE { deref(); } 104 virtual void derefEventTarget() OVERRIDE { deref(); }
105 virtual EventTargetData* eventTargetData() OVERRIDE;
106 virtual EventTargetData* ensureEventTargetData() OVERRIDE;
107 105
108 RefPtr<MessagePortChannel> m_entangledChannel; 106 RefPtr<MessagePortChannel> m_entangledChannel;
109 107
110 bool m_started; 108 bool m_started;
111 bool m_closed; 109 bool m_closed;
112 110
113 ScriptExecutionContext* m_scriptExecutionContext; 111 ScriptExecutionContext* m_scriptExecutionContext;
114 EventTargetData m_eventTargetData;
115 }; 112 };
116 113
117 } // namespace WebCore 114 } // namespace WebCore
118 115
119 #endif // MessagePort_h 116 #endif // MessagePort_h
OLDNEW
« no previous file with comments | « Source/core/css/FontFaceSet.cpp ('k') | Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698