| Index: Source/core/dom/CustomElementCallbackDispatcher.h
|
| diff --git a/Source/core/platform/mediastream/RTCConfiguration.h b/Source/core/dom/CustomElementCallbackDispatcher.h
|
| similarity index 51%
|
| copy from Source/core/platform/mediastream/RTCConfiguration.h
|
| copy to Source/core/dom/CustomElementCallbackDispatcher.h
|
| index ddb5adbdfae20b5efb6d41aa63596dd3304b8912..46a4f76b65ae122e3ad47fd8ee66d813103a57c5 100644
|
| --- a/Source/core/platform/mediastream/RTCConfiguration.h
|
| +++ b/Source/core/dom/CustomElementCallbackDispatcher.h
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2012 Google Inc. All rights reserved.
|
| + * Copyright (C) 2013 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions
|
| @@ -28,57 +28,59 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef RTCConfiguration_h
|
| -#define RTCConfiguration_h
|
| +#ifndef CustomElementCallbackDispatcher_h
|
| +#define CustomElementCallbackDispatcher_h
|
|
|
| -#include "weborigin/KURL.h"
|
| +#include "core/dom/CustomElementCallback.h"
|
| +#include "core/dom/Element.h"
|
| #include "wtf/PassRefPtr.h"
|
| -#include "wtf/RefCounted.h"
|
| +#include "wtf/RefPtr.h"
|
| #include "wtf/Vector.h"
|
| -#include "wtf/text/WTFString.h"
|
|
|
| namespace WebCore {
|
|
|
| -class RTCIceServer : public RefCounted<RTCIceServer> {
|
| +class CustomElementCallbackDispatcher {
|
| + WTF_MAKE_NONCOPYABLE(CustomElementCallbackDispatcher);
|
| public:
|
| - static PassRefPtr<RTCIceServer> create(const KURL& uri, const String& username, const String& credential)
|
| - {
|
| - return adoptRef(new RTCIceServer(uri, username, credential));
|
| - }
|
| - virtual ~RTCIceServer() { }
|
| + static CustomElementCallbackDispatcher& instance();
|
|
|
| - const KURL& uri() { return m_uri; }
|
| - const String& username() { return m_username; }
|
| - const String& credential() { return m_credential; }
|
| + class CallbackDeliveryScope {
|
| + public:
|
| + CallbackDeliveryScope() { }
|
| + ~CallbackDeliveryScope()
|
| + {
|
| + CustomElementCallbackDispatcher& dispatcher = CustomElementCallbackDispatcher::instance();
|
| + if (dispatcher.hasQueuedCallbacks())
|
| + dispatcher.dispatch();
|
| + }
|
| + };
|
|
|
| -private:
|
| - RTCIceServer(const KURL& uri, const String& username, const String& credential)
|
| - : m_uri(uri)
|
| - , m_username(username)
|
| - , m_credential(credential)
|
| - {
|
| - }
|
| + void enqueueReadyCallback(CustomElementCallback*, Element*);
|
|
|
| - KURL m_uri;
|
| - String m_username;
|
| - String m_credential;
|
| -};
|
| + // Returns true if more work may have to be performed at the
|
| + // checkpoint by this or other workers (for example, this work
|
| + // invoked author scripts)
|
| + bool dispatch();
|
|
|
| -class RTCConfiguration : public RefCounted<RTCConfiguration> {
|
| -public:
|
| - static PassRefPtr<RTCConfiguration> create() { return adoptRef(new RTCConfiguration()); }
|
| - virtual ~RTCConfiguration() { }
|
| +private:
|
| + explicit CustomElementCallbackDispatcher() { }
|
| +
|
| + bool hasQueuedCallbacks() { return !m_invocations.isEmpty(); }
|
|
|
| - void appendServer(PassRefPtr<RTCIceServer> server) { m_servers.append(server); }
|
| - size_t numberOfServers() { return m_servers.size(); }
|
| - RTCIceServer* server(size_t index) { return m_servers[index].get(); }
|
| + class ReadyInvocation {
|
| + public:
|
| + ReadyInvocation(PassRefPtr<CustomElementCallback>, PassRefPtr<Element>);
|
| + virtual ~ReadyInvocation() { }
|
| + void invoke() { m_callback->ready(m_element.get()); }
|
|
|
| - private:
|
| - RTCConfiguration() { }
|
| + private:
|
| + RefPtr<CustomElementCallback> m_callback;
|
| + RefPtr<Element> m_element;
|
| + };
|
|
|
| - Vector<RefPtr<RTCIceServer> > m_servers;
|
| + Vector<ReadyInvocation> m_invocations;
|
| };
|
|
|
| -} // namespace WebCore
|
| +}
|
|
|
| -#endif // RTCConfiguration_h
|
| +#endif // CustomElementCallbackDispatcher_h
|
|
|