Index: Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp |
diff --git a/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp b/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c6745268a8aaad24cd35f8e16b0b733f950d9a55 |
--- /dev/null |
+++ b/Source/modules/mediastream/MediaStreamTrackSourcesRequestImpl.cpp |
@@ -0,0 +1,80 @@ |
+/* |
+ * 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 |
+ * are met: |
+ * 1. Redistributions of source code must retain the above copyright |
+ * notice, this list of conditions and the following disclaimer. |
+ * 2. Redistributions in binary form must reproduce the above copyright |
+ * notice, this list of conditions and the following disclaimer in the |
+ * documentation and/or other materials provided with the distribution. |
+ * |
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY |
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR |
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ */ |
+ |
+#include "config.h" |
+ |
+#include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" |
+ |
+#include "core/dom/ScriptExecutionContext.h" |
+#include "modules/mediastream/MediaStreamTrackSourcesCallback.h" |
+#include "modules/mediastream/RTCErrorCallback.h" |
+#include "modules/mediastream/RTCPeerConnection.h" |
+#include "public/platform/WebSourceInfo.h" |
+#include "weborigin/SecurityOrigin.h" |
+ |
+namespace WebCore { |
+ |
+PassRefPtr<MediaStreamTrackSourcesRequestImpl> MediaStreamTrackSourcesRequestImpl::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackSourcesCallback> callback) |
+{ |
+ RefPtr<MediaStreamTrackSourcesRequestImpl> request = adoptRef(new MediaStreamTrackSourcesRequestImpl(context, callback)); |
+ request->suspendIfNeeded(); |
+ return request.release(); |
+} |
+ |
+MediaStreamTrackSourcesRequestImpl::MediaStreamTrackSourcesRequestImpl(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackSourcesCallback> callback) |
+ : ActiveDOMObject(context) |
+ , m_callback(callback) |
+{ |
+ m_url = context->securityOrigin()->toString(); |
abarth-chromium
2013/06/11 23:50:44
The toString of the securityOrigin isn't a URL....
Tommy Widenflycht
2013/06/12 12:29:34
The name isn't great I agree, but I don't really k
|
+} |
+ |
+MediaStreamTrackSourcesRequestImpl::~MediaStreamTrackSourcesRequestImpl() |
+{ |
+} |
+ |
+void MediaStreamTrackSourcesRequestImpl::requestSucceeded(const WebKit::WebVector<WebKit::WebSourceInfo>& webSourceInfos) |
+{ |
+ if (m_callback) { |
+ SourceInfoVector sourceInfos; |
+ for (size_t i = 0; i < webSourceInfos.size(); ++i) |
+ sourceInfos.append(SourceInfo::create(webSourceInfos[i])); |
+ |
+ m_callback->handleEvent(sourceInfos); |
+ } |
+ |
+ clear(); |
+} |
+ |
+void MediaStreamTrackSourcesRequestImpl::stop() |
+{ |
+ clear(); |
+} |
+ |
+void MediaStreamTrackSourcesRequestImpl::clear() |
+{ |
+ m_callback.clear(); |
abarth-chromium
2013/06/11 23:50:44
You shouldn't need to build this notification path
Tommy Widenflycht
2013/06/12 12:29:34
Done.
|
+} |
+ |
+} // namespace WebCore |