Source/WebCore/Android.mk

@@LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
435435 page/GroupSettings.cpp \
436436 page/History.cpp \
437437 page/Location.cpp \
 438 page/MediaStreamContext.cpp \
 439 page/MediaStreamController.cpp \
438440 page/MouseEventWithHitTestResults.cpp \
439441 page/Navigator.cpp \
440442 page/NavigatorBase.cpp \

Source/WebCore/CMakeLists.txt

@@ENDIF ()
19511951IF (ENABLE_MEDIA_STREAM)
19521952 LIST(APPEND WebCore_SOURCES
19531953 bindings/js/JSNavigatorCustom.cpp
 1954 page/MediaStreamContext.cpp
 1955 page/MediaStreamController.cpp
19541956 )
19551957
19561958 LIST(APPEND WebCore_IDL_FILES

Source/WebCore/ChangeLog

 12011-04-08 Leandro Gracia Gil <leandrogracia@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Media Stream API: add the skeleton of the frame context, the page controller and the embedder client.
 6 https://bugs.webkit.org/show_bug.cgi?id=56922
 7
 8 Add the basic outlines of the page controller, the per-frame context and the embedder
 9 client interface for the Media Stream API. Provide methods to handle the situations
 10 where a frame is detached from the page or transferred between pages.
 11
 12 Tests for the Media Stream API will be provided by the bug 56587.
 13
 14 * Android.mk:
 15 * CMakeLists.txt:
 16 * GNUmakefile.list.am:
 17 * WebCore.gypi:
 18 * WebCore.pro:
 19 * WebCore.vcproj/WebCore.vcproj:
 20 * WebCore.xcodeproj/project.pbxproj:
 21 * page/DOMWindow.cpp:
 22 (WebCore::DOMWindow::DOMWindow):
 23 (WebCore::DOMWindow::clear):
 24 (WebCore::DOMWindow::mediaStreamPageDetached):
 25 (WebCore::DOMWindow::mediaStreamTransferToNewPage):
 26 * page/DOMWindow.h:
 27 (WebCore::DOMWindow::mediaStreamContext):
 28 * page/Frame.cpp:
 29 (WebCore::Frame::pageDestroyed):
 30 (WebCore::Frame::transferChildFrameToNewDocument):
 31 * page/MediaStreamClient.h: Added.
 32 (WebCore::MediaStreamClient::~MediaStreamClient):
 33 * page/MediaStreamContext.cpp: Added.
 34 (WebCore::MediaStreamContext::Request::Request):
 35 (WebCore::MediaStreamContext::Request::~Request):
 36 (WebCore::MediaStreamContext::Request::scriptContext):
 37 (WebCore::MediaStreamContext::RequestMap::abort):
 38 (WebCore::MediaStreamContext::RequestMap::abortAll):
 39 (WebCore::MediaStreamContext::MediaStreamContext):
 40 (WebCore::MediaStreamContext::~MediaStreamContext):
 41 (WebCore::MediaStreamContext::securityOrigin):
 42 (WebCore::MediaStreamContext::scriptExecutionContext):
 43 (WebCore::MediaStreamContext::pageController):
 44 (WebCore::MediaStreamContext::enterDetachedState):
 45 (WebCore::MediaStreamContext::pageDetached):
 46 (WebCore::MediaStreamContext::disconnectFrame):
 47 (WebCore::MediaStreamContext::controllerDestroyed):
 48 (WebCore::MediaStreamContext::transferToNewPage):
 49 * page/MediaStreamContext.h: Added.
 50 (WebCore::MediaStreamContext::IdGenerator::IdGenerator):
 51 (WebCore::MediaStreamContext::IdGenerator::getNextId):
 52 * page/MediaStreamController.cpp: Added.
 53 (WebCore::MediaStreamController::MediaStreamController):
 54 (WebCore::MediaStreamController::~MediaStreamController):
 55 (WebCore::MediaStreamController::unregisterContext):
 56 (WebCore::MediaStreamController::unregisterController):
 57 (WebCore::MediaStreamController::contextDestroyed):
 58 (WebCore::MediaStreamController::contextDetached):
 59 (WebCore::MediaStreamController::transferContext):
 60 (WebCore::MediaStreamController::registerRequest):
 61 * page/MediaStreamController.h: Added.
 62 (WebCore::MediaStreamController::RequestContext::RequestContext):
 63 (WebCore::MediaStreamController::RequestContext::id):
 64 (WebCore::MediaStreamController::RequestContext::context):
 65 * page/Page.cpp:
 66 (WebCore::Page::Page):
 67 (WebCore::Page::PageClients::PageClients):
 68 * page/Page.h:
 69 (WebCore::Page::mediaStreamController):
 70
1712011-04-08 Pavel Feldman <pfeldman@chromium.org>
272
373 Reviewed by Yury Semikhatsky.

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
22032203 Source/WebCore/page/Location.cpp \
22042204 Source/WebCore/page/Location.h \
22052205 Source/WebCore/page/MediaCanStartListener.h \
 2206 Source/WebCore/page/MediaStreamClient.h \
 2207 Source/WebCore/page/MediaStreamContext.cpp \
 2208 Source/WebCore/page/MediaStreamContext.h \
 2209 Source/WebCore/page/MediaStreamController.cpp \
 2210 Source/WebCore/page/MediaStreamController.h \
22062211 Source/WebCore/page/MemoryInfo.cpp \
22072212 Source/WebCore/page/MemoryInfo.h \
22082213 Source/WebCore/page/MouseEventWithHitTestResults.cpp \

Source/WebCore/WebCore.gypi

34463446 'page/SpeechInputResult.h',
34473447 'page/SpeechInputResultList.cpp',
34483448 'page/SpeechInputResultList.h',
 3449 'page/MediaStreamClient.h',
 3450 'page/MediaStreamContext.cpp',
 3451 'page/MediaStreamContext.h',
 3452 'page/MediaStreamController.cpp',
 3453 'page/MediaStreamController.h',
34493454 'page/SuspendableTimer.cpp',
34503455 'page/SuspendableTimer.h',
34513456 'page/UserContentURLPattern.cpp',

Source/WebCore/WebCore.pro

@@contains(DEFINES, ENABLE_GEOLOCATION=1) {
31243124
31253125contains(DEFINES, ENABLE_MEDIA_STREAM=1) {
31263126 HEADERS += \
 3127 page/MediaStreamClient.h \
 3128 page/MediaStreamContext.h \
 3129 page/MediaStreamController.h \
31273130 page/NavigatorUserMediaError.h \
31283131 page/NavigatorUserMediaErrorCallback.h \
31293132 page/NavigatorUserMediaSuccessCallback.h
31303133
 3134 SOURCES += \
 3135 page/MediaStreamContext.cpp \
 3136 page/MediaStreamController.cpp
 3137
31313138 v8 {
31323139 SOURCES += \
31333140 bindings/v8/custom/V8NavigatorCustom.cpp

Source/WebCore/WebCore.vcproj/WebCore.vcproj

2502625026 >
2502725027 </File>
2502825028 <File
 25029 RelativePath="..\page\MediaStreamClient.h"
 25030 >
 25031 </File>
 25032 <File
 25033 RelativePath="..\page\MediaStreamContext.cpp"
 25034 >
 25035 </File>
 25036 <File
 25037 RelativePath="..\page\MediaStreamContext.h"
 25038 >
 25039 </File>
 25040 <File
 25041 RelativePath="..\page\MediaStreamController.cpp"
 25042 >
 25043 </File>
 25044 <File
 25045 RelativePath="..\page\MediaStreamController.h"
 25046 >
 25047 </File>
 25048 <File
2502925049 RelativePath="..\page\MouseEventWithHitTestResults.cpp"
2503025050 >
2503125051 </File>

Source/WebCore/WebCore.xcodeproj/project.pbxproj

41014101 B0149E8011A4B21500196A7B /* ImageResizerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = B0149E7C11A4B21500196A7B /* ImageResizerThread.h */; };
41024102 B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1827492134CA4C100B98C2D /* CallbackFunction.cpp */; };
41034103 B1D5ECB5134B58DA0087C78F /* CallbackFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */; };
 4104 B1E54594134629C10092A545 /* MediaStreamClient.h in Headers */ = {isa = PBXBuildFile; fileRef = B1E54588134629C10092A545 /* MediaStreamClient.h */; };
 4105 B1E54595134629C10092A545 /* MediaStreamContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1E54589134629C10092A545 /* MediaStreamContext.cpp */; };
 4106 B1E54596134629C10092A545 /* MediaStreamContext.h in Headers */ = {isa = PBXBuildFile; fileRef = B1E5458A134629C10092A545 /* MediaStreamContext.h */; };
 4107 B1E54597134629C10092A545 /* MediaStreamController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1E5458B134629C10092A545 /* MediaStreamController.cpp */; };
 4108 B1E54598134629C10092A545 /* MediaStreamController.h in Headers */ = {isa = PBXBuildFile; fileRef = B1E5458C134629C10092A545 /* MediaStreamController.h */; };
41044109 B1E54599134629C10092A545 /* NavigatorUserMediaError.h in Headers */ = {isa = PBXBuildFile; fileRef = B1E5458D134629C10092A545 /* NavigatorUserMediaError.h */; };
41054110 B1E5459B134629C10092A545 /* NavigatorUserMediaErrorCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B1E5458F134629C10092A545 /* NavigatorUserMediaErrorCallback.h */; };
41064111 B1E5459D134629C10092A545 /* NavigatorUserMediaSuccessCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B1E54591134629C10092A545 /* NavigatorUserMediaSuccessCallback.h */; };

1039210397 B0149E7C11A4B21500196A7B /* ImageResizerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageResizerThread.h; sourceTree = "<group>"; };
1039310398 B1827492134CA4C100B98C2D /* CallbackFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CallbackFunction.cpp; sourceTree = "<group>"; };
1039410399 B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallbackFunction.h; sourceTree = "<group>"; };
 10400 B1E54588134629C10092A545 /* MediaStreamClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamClient.h; sourceTree = "<group>"; };
 10401 B1E54589134629C10092A545 /* MediaStreamContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamContext.cpp; sourceTree = "<group>"; };
 10402 B1E5458A134629C10092A545 /* MediaStreamContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamContext.h; sourceTree = "<group>"; };
 10403 B1E5458B134629C10092A545 /* MediaStreamController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamController.cpp; sourceTree = "<group>"; };
 10404 B1E5458C134629C10092A545 /* MediaStreamController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamController.h; sourceTree = "<group>"; };
1039510405 B1E5458D134629C10092A545 /* NavigatorUserMediaError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorUserMediaError.h; sourceTree = "<group>"; };
1039610406 B1E5458E134629C10092A545 /* NavigatorUserMediaError.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorUserMediaError.idl; sourceTree = "<group>"; };
1039710407 B1E5458F134629C10092A545 /* NavigatorUserMediaErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorUserMediaErrorCallback.h; sourceTree = "<group>"; };

1429114301 BCE1C4190D982980003B02F2 /* Location.h */,
1429214302 BCE1C4220D9829F2003B02F2 /* Location.idl */,
1429314303 931BCC601124DFCB00BE70DD /* MediaCanStartListener.h */,
 14304 B1E54588134629C10092A545 /* MediaStreamClient.h */,
 14305 B1E54589134629C10092A545 /* MediaStreamContext.cpp */,
 14306 B1E5458A134629C10092A545 /* MediaStreamContext.h */,
 14307 B1E5458B134629C10092A545 /* MediaStreamController.cpp */,
 14308 B1E5458C134629C10092A545 /* MediaStreamController.h */,
1429414309 9FFE3E7811B59C5D0037874E /* MemoryInfo.cpp */,
1429514310 9FFE3E7911B59C5D0037874E /* MemoryInfo.h */,
1429614311 9FFE3E7C11B59C6E0037874E /* MemoryInfo.idl */,

2288522900 93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
2288622901 E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
2288722902 977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */,
 22903 B1E54594134629C10092A545 /* MediaStreamClient.h in Headers */,
 22904 B1E54596134629C10092A545 /* MediaStreamContext.h in Headers */,
 22905 B1E54598134629C10092A545 /* MediaStreamController.h in Headers */,
2288822906 B1E54599134629C10092A545 /* NavigatorUserMediaError.h in Headers */,
2288922907 B1E5459B134629C10092A545 /* NavigatorUserMediaErrorCallback.h in Headers */,
2289022908 B1E5459D134629C10092A545 /* NavigatorUserMediaSuccessCallback.h in Headers */,

2558525603 93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
2558625604 E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
2558725605 977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
 25606 B1E54595134629C10092A545 /* MediaStreamContext.cpp in Sources */,
 25607 B1E54597134629C10092A545 /* MediaStreamController.cpp in Sources */,
2558825608 B1E545DF13462B0B0092A545 /* JSNavigatorUserMediaError.cpp in Sources */,
2558925609 B1E545E113462B0B0092A545 /* JSNavigatorUserMediaErrorCallback.cpp in Sources */,
2559025610 B1E545E313462B0B0092A545 /* JSNavigatorUserMediaSuccessCallback.cpp in Sources */,

Source/WebCore/page/DOMWindow.cpp

7171#include "Location.h"
7272#include "MediaQueryList.h"
7373#include "MediaQueryMatcher.h"
 74#include "MediaStreamContext.h"
7475#include "MessageEvent.h"
7576#include "Navigator.h"
7677#include "NotificationCenter.h"

8081#include "Performance.h"
8182#include "PlatformScreen.h"
8283#include "PlatformString.h"
 84#include "RuntimeEnabledFeatures.h"
8385#include "Screen.h"
8486#include "SecurityOrigin.h"
8587#include "SerializedScriptValue.h"

@@DOMWindow::DOMWindow(Frame* frame)
395397 : m_shouldPrintWhenFinishedLoading(false)
396398 , m_frame(frame)
397399 , m_printTimer(this, &DOMWindow::printTimerFired)
 400#if ENABLE(MEDIA_STREAM)
 401 , m_mediaStreamContext(RuntimeEnabledFeatures::mediaStreamEnabled() ? new MediaStreamContext(frame) : 0)
 402#endif
398403{
399404}
400405

@@void DOMWindow::clear()
510515#if ENABLE(INDEXED_DATABASE)
511516 m_idbFactory = 0;
512517#endif
 518
 519#if ENABLE(MEDIA_STREAM)
 520 if (m_mediaStreamContext)
 521 m_mediaStreamContext->disconnectFrame();
 522#endif
513523}
514524
515525#if ENABLE(ORIENTATION_EVENTS)

@@DOMURL* DOMWindow::webkitURL() const
18581868}
18591869#endif
18601870
 1871#if ENABLE(MEDIA_STREAM)
 1872void DOMWindow::mediaStreamPageDetached()
 1873{
 1874 if (m_mediaStreamContext)
 1875 m_mediaStreamContext->pageDetached();
 1876}
 1877
 1878void DOMWindow::mediaStreamTransferToNewPage(Page* newPage)
 1879{
 1880 if (m_mediaStreamContext)
 1881 m_mediaStreamContext->transferToNewPage(newPage);
 1882}
 1883#endif
 1884
18611885} // namespace WebCore

Source/WebCore/page/DOMWindow.h

@@namespace WebCore {
5555 class IDBFactory;
5656 class Location;
5757 class MediaQueryList;
 58 class MediaStreamContext;
5859 class Navigator;
5960 class Node;
6061 class NotificationCenter;

@@namespace WebCore {
425426 Performance* optionalPerformance() const { return m_performance.get(); }
426427#endif
427428
 429#if ENABLE(MEDIA_STREAM)
 430 void mediaStreamPageDetached();
 431 void mediaStreamTransferToNewPage(Page*);
 432 MediaStreamContext* mediaStreamContext() const { return m_mediaStreamContext.get(); }
 433#endif
 434
428435 private:
429436 DOMWindow(Frame*);
430437

@@namespace WebCore {
491498#if ENABLE(BLOB)
492499 mutable RefPtr<DOMURL> m_domURL;
493500#endif
 501
 502#if ENABLE(MEDIA_STREAM)
 503 OwnPtr<MediaStreamContext> m_mediaStreamContext;
 504#endif
494505 };
495506
496507 inline String DOMWindow::status() const

Source/WebCore/page/Frame.cpp

@@void Frame::pageDestroyed()
688688
689689 if (m_domWindow) {
690690 m_domWindow->resetGeolocation();
 691#if ENABLE(MEDIA_STREAM)
 692 m_domWindow->mediaStreamPageDetached();
 693#endif
691694 m_domWindow->pageDestroyed();
692695 }
693696

@@void Frame::transferChildFrameToNewDocument()
738741 // when the Geolocation's iframe is reparented.
739742 // See https://bugs.webkit.org/show_bug.cgi?id=55577
740743 // and https://bugs.webkit.org/show_bug.cgi?id=52877
741  if (m_domWindow)
 744 if (m_domWindow) {
742745 m_domWindow->resetGeolocation();
 746#if ENABLE(MEDIA_STREAM)
 747 m_domWindow->mediaStreamTransferToNewPage(newPage);
 748#endif
 749 }
743750
744751 m_page = newPage;
745752

Source/WebCore/page/MediaStreamClient.h

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#ifndef MediaStreamClient_h
 26#define MediaStreamClient_h
 27
 28#if ENABLE(MEDIA_STREAM)
 29
 30namespace WebCore {
 31
 32class MediaStreamClient {
 33public:
 34 // Notify the client about shutting down.
 35 virtual void mediaStreamDestroyed() = 0;
 36
 37 // FIXME: add here the requests to the embedder.
 38
 39protected:
 40 virtual ~MediaStreamClient() { }
 41};
 42
 43} // namespace WebCore
 44
 45#endif // ENABLE(MEDIA_STREAM)
 46
 47#endif // MediaStreamClient_h

Source/WebCore/page/MediaStreamContext.cpp

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#include "config.h"
 26#include "MediaStreamContext.h"
 27
 28#if ENABLE(MEDIA_STREAM)
 29
 30#include "DOMWindow.h"
 31#include "Document.h"
 32#include "Frame.h"
 33#include "MediaStreamController.h"
 34#include "Page.h"
 35#include "SecurityOrigin.h"
 36#include <wtf/RefCounted.h>
 37
 38namespace WebCore {
 39
 40class MediaStreamContext::Request : public RefCounted<Request> {
 41public:
 42 Request(ScriptExecutionContext* scriptContext)
 43 : m_scriptContext(scriptContext) { }
 44
 45 virtual ~Request() { }
 46
 47 ScriptExecutionContext* scriptContext() const { return m_scriptContext; }
 48
 49 virtual void abort() = 0;
 50
 51private:
 52 // This script execution context is the document referenced by the frame. It will
 53 // remain alive and valid the same time that the frame is, aborting all requests
 54 // when receiving disconnectFrame. Its purpose is to allow async request
 55 // abortions to be properly scheduled to comply with the specification.
 56 ScriptExecutionContext* m_scriptContext;
 57};
 58
 59void MediaStreamContext::RequestMap::abort(int requestId)
 60{
 61 ASSERT(contains(requestId));
 62 get(requestId)->abort();
 63 remove(requestId);
 64}
 65
 66void MediaStreamContext::RequestMap::abortAll()
 67{
 68 for (iterator it = begin(); it != end(); it = begin()) {
 69 it->second->abort();
 70 remove(it);
 71 }
 72}
 73
 74MediaStreamContext::MediaStreamContext(Frame* frame)
 75 : m_frame(frame)
 76 , m_detachedState(false)
 77{
 78}
 79
 80MediaStreamContext::~MediaStreamContext()
 81{
 82}
 83
 84SecurityOrigin* MediaStreamContext::securityOrigin() const
 85{
 86 return m_frame ? m_frame->existingDOMWindow()->securityOrigin() : 0;
 87}
 88
 89ScriptExecutionContext* MediaStreamContext::scriptExecutionContext() const
 90{
 91 return m_frame ? m_frame->existingDOMWindow()->scriptExecutionContext() : 0;
 92}
 93
 94MediaStreamController* MediaStreamContext::pageController() const
 95{
 96 return !m_detachedState && m_frame && m_frame->page() ? m_frame->page()->mediaStreamController() : 0;
 97}
 98
 99void MediaStreamContext::enterDetachedState()
 100{
 101 m_requests.abortAll();
 102 m_detachedState = true;
 103}
 104
 105void MediaStreamContext::pageDetached()
 106{
 107 if (m_detachedState)
 108 return;
 109
 110 if (pageController())
 111 pageController()->contextDetached(this);
 112
 113 enterDetachedState();
 114}
 115
 116// Called on frame destruction despite the name.
 117void MediaStreamContext::disconnectFrame()
 118{
 119 m_requests.abortAll();
 120
 121 if (pageController())
 122 pageController()->contextDestroyed(this);
 123
 124 m_frame = 0;
 125}
 126
 127void MediaStreamContext::controllerDestroyed(MediaStreamController* controller)
 128{
 129 ASSERT(controller);
 130
 131 if (pageController() == controller)
 132 enterDetachedState();
 133}
 134
 135void MediaStreamContext::transferToNewPage(Page* newPage)
 136{
 137 if (pageController())
 138 pageController()->transferContext(this, newPage ? newPage->mediaStreamController() : 0);
 139
 140 if (!newPage) {
 141 enterDetachedState();
 142 return;
 143 }
 144
 145 // FIXME: in the future we should keep running the media stream services while transfering frames.
 146 // However, until a proper way to do this is decided, we're shutting down services.
 147 enterDetachedState();
 148}
 149
 150} // namespace WebCore
 151
 152#endif // ENABLE(MEDIA_STREAM)

Source/WebCore/page/MediaStreamContext.h

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#ifndef MediaStreamContext_h
 26#define MediaStreamContext_h
 27
 28#if ENABLE(MEDIA_STREAM)
 29
 30#include <wtf/Forward.h>
 31#include <wtf/HashMap.h>
 32#include <wtf/Noncopyable.h>
 33
 34namespace WebCore {
 35
 36class Frame;
 37class MediaStreamController;
 38class NavigatorUserMediaErrorCallback;
 39class NavigatorUserMediaSuccessCallback;
 40class Page;
 41class SecurityOrigin;
 42class ScriptExecutionContext;
 43
 44class MediaStreamContext {
 45 WTF_MAKE_NONCOPYABLE(MediaStreamContext);
 46public:
 47 MediaStreamContext(Frame*);
 48 virtual ~MediaStreamContext();
 49
 50 SecurityOrigin* securityOrigin() const;
 51 ScriptExecutionContext* scriptExecutionContext() const;
 52
 53 void pageDetached();
 54 void disconnectFrame();
 55 void controllerDestroyed(MediaStreamController*);
 56 void transferToNewPage(Page*);
 57
 58private:
 59 class Request;
 60
 61 class IdGenerator {
 62 public:
 63 IdGenerator() : m_id(0) { }
 64 int getNextId() { return ++m_id; }
 65
 66 private:
 67 int m_id;
 68 };
 69
 70 class RequestMap : public IdGenerator, public HashMap<int, RefPtr<Request> > {
 71 public:
 72 void abort(int requestId);
 73 void abortAll();
 74 };
 75
 76 MediaStreamController* pageController() const;
 77 void enterDetachedState();
 78
 79 Frame* m_frame;
 80 RequestMap m_requests;
 81 bool m_detachedState;
 82};
 83
 84} // namespace WebCore
 85
 86#endif // ENABLE(MEDIA_STREAM)
 87
 88#endif // MediaStreamContext_h

Source/WebCore/page/MediaStreamController.cpp

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24#include "config.h"
 25#include "MediaStreamController.h"
 26
 27#if ENABLE(MEDIA_STREAM)
 28
 29#include "MediaStreamClient.h"
 30#include "MediaStreamContext.h"
 31#include <wtf/HashSet.h>
 32
 33namespace WebCore {
 34
 35MediaStreamController::MediaStreamController(MediaStreamClient* client)
 36 : m_client(client)
 37 , m_nextRequestId(1)
 38{
 39}
 40
 41MediaStreamController::~MediaStreamController()
 42{
 43 if (m_client)
 44 m_client->mediaStreamDestroyed();
 45
 46 unregisterController();
 47}
 48
 49void MediaStreamController::unregisterContext(MediaStreamContext* context)
 50{
 51 for (RequestContextMap::iterator it = m_requestContext.begin(); it != m_requestContext.end(); it = m_requestContext.begin()) {
 52 if (it->second.context() == context)
 53 m_requestContext.remove(it);
 54 }
 55}
 56
 57void MediaStreamController::unregisterController()
 58{
 59 HashSet<MediaStreamContext*> notifiedContexts;
 60
 61 for (RequestContextMap::iterator it = m_requestContext.begin(); it != m_requestContext.end(); it = m_requestContext.begin()) {
 62 if (!notifiedContexts.contains(it->second.context())) {
 63 notifiedContexts.add(it->second.context());
 64 it->second.context()->controllerDestroyed(this);
 65 }
 66
 67 m_requestContext.remove(it);
 68 }
 69}
 70
 71void MediaStreamController::contextDestroyed(MediaStreamContext* context)
 72{
 73 unregisterContext(context);
 74}
 75
 76void MediaStreamController::contextDetached(MediaStreamContext* context)
 77{
 78 // FIXME: in the future we should route replies to ongoing asynchronous requests to their
 79 // contexts even if they have been detached from this page. For now let's just destroy them.
 80 contextDestroyed(context);
 81}
 82
 83void MediaStreamController::transferContext(MediaStreamContext* context, MediaStreamController* newController)
 84{
 85 if (!newController) {
 86 contextDetached(context);
 87 return;
 88 }
 89
 90 // FIXME: in the future we should route replies to ongoing asynchronous requests to their
 91 // contexts even if they have been detached from this page. For now let's just destroy them.
 92 contextDestroyed(context);
 93}
 94
 95int MediaStreamController::registerRequest(int contextRequestId, MediaStreamContext* context)
 96{
 97 m_requestContext.add(m_nextRequestId, RequestContext(contextRequestId, context));
 98 return m_nextRequestId++;
 99}
 100
 101} // namespace WebCore
 102
 103#endif // ENABLE(MEDIA_STREAM)

Source/WebCore/page/MediaStreamController.h

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24#ifndef MediaStreamController_h
 25#define MediaStreamController_h
 26
 27#if ENABLE(MEDIA_STREAM)
 28
 29#include <wtf/Forward.h>
 30#include <wtf/HashMap.h>
 31#include <wtf/Noncopyable.h>
 32
 33namespace WebCore {
 34
 35class MediaStreamClient;
 36class MediaStreamContext;
 37
 38class MediaStreamController {
 39 WTF_MAKE_NONCOPYABLE(MediaStreamController);
 40public:
 41 MediaStreamController(MediaStreamClient*);
 42 virtual ~MediaStreamController();
 43
 44 void contextDestroyed(MediaStreamContext*);
 45 void contextDetached(MediaStreamContext*);
 46 void transferContext(MediaStreamContext*, MediaStreamController*);
 47
 48private:
 49 class RequestContext {
 50 public:
 51 RequestContext()
 52 : m_id(0)
 53 , m_context(0) { }
 54
 55 RequestContext(int requestId, MediaStreamContext* context)
 56 : m_id(requestId)
 57 , m_context(context) { }
 58
 59 int id() const { return m_id; }
 60 MediaStreamContext* context() const { return m_context; }
 61
 62 private:
 63 int m_id;
 64 MediaStreamContext* m_context;
 65 };
 66
 67 typedef HashMap<int, RequestContext> RequestContextMap;
 68
 69 int registerRequest(int contextRequestId, MediaStreamContext*);
 70
 71 void unregisterContext(MediaStreamContext*);
 72 void unregisterController();
 73
 74 MediaStreamClient* m_client;
 75 RequestContextMap m_requestContext;
 76 int m_nextRequestId;
 77};
 78
 79} // namespace WebCore
 80
 81#endif // ENABLE(MEDIA_STREAM)
 82
 83#endif // MediaStreamController_h

Source/WebCore/page/Page.cpp

5050#include "InspectorInstrumentation.h"
5151#include "Logging.h"
5252#include "MediaCanStartListener.h"
 53#include "MediaStreamClient.h"
 54#include "MediaStreamController.h"
5355#include "Navigator.h"
5456#include "NetworkStateNotifier.h"
5557#include "PageGroup.h"

@@Page::Page(const PageClients& pageClients)
136138 , m_deviceMotionController(RuntimeEnabledFeatures::deviceMotionEnabled() ? new DeviceMotionController(pageClients.deviceMotionClient) : 0)
137139 , m_deviceOrientationController(RuntimeEnabledFeatures::deviceOrientationEnabled() ? new DeviceOrientationController(this, pageClients.deviceOrientationClient) : 0)
138140#endif
 141#if ENABLE(MEDIA_STREAM)
 142 , m_mediaStreamController(RuntimeEnabledFeatures::mediaStreamEnabled() ? new MediaStreamController(pageClients.mediaStreamClient) : 0)
 143#endif
139144#if ENABLE(INPUT_SPEECH)
140145 , m_speechInputClient(pageClients.speechInputClient)
141146#endif

@@Page::PageClients::PageClients()
950955 , deviceMotionClient(0)
951956 , deviceOrientationClient(0)
952957 , speechInputClient(0)
 958 , mediaStreamClient(0)
953959{
954960}
955961

Source/WebCore/page/Page.h

@@namespace WebCore {
6262 class InspectorClient;
6363 class InspectorController;
6464 class MediaCanStartListener;
 65 class MediaStreamClient;
 66 class MediaStreamController;
6567 class Node;
6668 class PageGroup;
6769 class PluginData;

@@namespace WebCore {
114116 DeviceOrientationClient* deviceOrientationClient;
115117 RefPtr<BackForwardList> backForwardClient;
116118 SpeechInputClient* speechInputClient;
 119 MediaStreamClient* mediaStreamClient;
117120 };
118121
119122 Page(const PageClients&);

@@namespace WebCore {
179182 DeviceMotionController* deviceMotionController() const { return m_deviceMotionController.get(); }
180183 DeviceOrientationController* deviceOrientationController() const { return m_deviceOrientationController.get(); }
181184#endif
 185#if ENABLE(MEDIA_STREAM)
 186 MediaStreamController* mediaStreamController() const { return m_mediaStreamController.get(); }
 187#endif
182188#if ENABLE(INPUT_SPEECH)
183189 SpeechInput* speechInput();
184190#endif

@@namespace WebCore {
335341 OwnPtr<DeviceMotionController> m_deviceMotionController;
336342 OwnPtr<DeviceOrientationController> m_deviceOrientationController;
337343#endif
 344#if ENABLE(MEDIA_STREAM)
 345 OwnPtr<MediaStreamController> m_mediaStreamController;
 346#endif
338347#if ENABLE(INPUT_SPEECH)
339348 SpeechInputClient* m_speechInputClient;
340349 OwnPtr<SpeechInput> m_speechInput;
341350#endif
342351 OwnPtr<Settings> m_settings;
343352 OwnPtr<ProgressTracker> m_progress;
344 
 353
345354 OwnPtr<BackForwardController> m_backForwardController;
346355 RefPtr<Frame> m_mainFrame;
347356