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

Side by Side Diff: Source/core/dom/CustomElementCallbackDispatcher.h

Issue 14660019: Run Mutation Observer and Custom Element callbacks consistently at microtask checkpoint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Header minimization. Created 7 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer 11 * notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
13 * distribution. 13 * distribution.
14 * 3. Neither the name of Google Inc. nor the names of its contributors 14 * 3. Neither the name of Google Inc. nor the names of its contributors
15 * may be used to endorse or promote products derived from this 15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission. 16 * software without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 RTCConfiguration_h 31 #ifndef CustomElementCallbackDispatcher_h
32 #define RTCConfiguration_h 32 #define CustomElementCallbackDispatcher_h
33 33
34 #include "weborigin/KURL.h" 34 #include "core/dom/CustomElementCallback.h"
35 #include "core/dom/Element.h"
35 #include "wtf/PassRefPtr.h" 36 #include "wtf/PassRefPtr.h"
36 #include "wtf/RefCounted.h" 37 #include "wtf/RefPtr.h"
37 #include "wtf/Vector.h" 38 #include "wtf/Vector.h"
38 #include "wtf/text/WTFString.h"
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 class RTCIceServer : public RefCounted<RTCIceServer> { 42 class CustomElementCallbackDispatcher {
43 WTF_MAKE_NONCOPYABLE(CustomElementCallbackDispatcher);
43 public: 44 public:
44 static PassRefPtr<RTCIceServer> create(const KURL& uri, const String& userna me, const String& credential) 45 static CustomElementCallbackDispatcher& dispatcher();
dglazkov 2013/06/24 19:20:11 instance()?
45 {
46 return adoptRef(new RTCIceServer(uri, username, credential));
47 }
48 virtual ~RTCIceServer() { }
49 46
50 const KURL& uri() { return m_uri; } 47 class CallbackDeliveryScope {
51 const String& username() { return m_username; } 48 public:
52 const String& credential() { return m_credential; } 49 CallbackDeliveryScope() { }
50 ~CallbackDeliveryScope()
51 {
52 CustomElementCallbackDispatcher& dispatcher = CustomElementCallbackD ispatcher::dispatcher();
53 if (dispatcher.hasQueuedCallbacks())
54 dispatcher.dispatch();
55 }
56 };
57
58 void enqueueReadyCallback(CustomElementCallback*, Element*);
59
60 // Returns true if more work may have to be performed at the
61 // checkpoint by this or other workers (for example, this work
62 // invoked author scripts)
63 bool dispatch();
53 64
54 private: 65 private:
55 RTCIceServer(const KURL& uri, const String& username, const String& credenti al) 66 explicit CustomElementCallbackDispatcher() { }
56 : m_uri(uri)
57 , m_username(username)
58 , m_credential(credential)
59 {
60 }
61 67
62 KURL m_uri; 68 bool hasQueuedCallbacks() { return !m_invocations.isEmpty(); }
63 String m_username; 69
64 String m_credential; 70 class ReadyInvocation {
71 public:
72 ReadyInvocation(PassRefPtr<CustomElementCallback>, PassRefPtr<Element>);
73 virtual ~ReadyInvocation() { }
74 void invoke() { m_callback->ready(m_element.get()); }
75
76 private:
77 RefPtr<CustomElementCallback> m_callback;
78 RefPtr<Element> m_element;
79 };
80
81 Vector<ReadyInvocation> m_invocations;
65 }; 82 };
66 83
67 class RTCConfiguration : public RefCounted<RTCConfiguration> { 84 }
68 public:
69 static PassRefPtr<RTCConfiguration> create() { return adoptRef(new RTCConfig uration()); }
70 virtual ~RTCConfiguration() { }
71 85
72 void appendServer(PassRefPtr<RTCIceServer> server) { m_servers.append(server ); } 86 #endif // CustomElementCallbackDispatcher_h
73 size_t numberOfServers() { return m_servers.size(); }
74 RTCIceServer* server(size_t index) { return m_servers[index].get(); }
75
76 private:
77 RTCConfiguration() { }
78
79 Vector<RefPtr<RTCIceServer> > m_servers;
80 };
81
82 } // namespace WebCore
83
84 #endif // RTCConfiguration_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698