Commit a9481f01 authored by weinig@apple.com's avatar weinig@apple.com

Pass ScriptExecutionContext by reference to from the bindings constructors

https://bugs.webkit.org/show_bug.cgi?id=123575

Reviewed by Andreas Kling.

Since we null check the ScriptExecutionContext before creating the c++ class,
we should be passing by reference.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1874cd05
2013-10-31 Sam Weinig <sam@webkit.org>
Pass ScriptExecutionContext by reference to from the bindings constructors
https://bugs.webkit.org/show_bug.cgi?id=123575
Reviewed by Andreas Kling.
Since we null check the ScriptExecutionContext before creating the c++ class,
we should be passing by reference.
2013-10-31 Zhuang Zhigang <zhuangzg@cn.fujitsu.com>
Paint the input tag of range type on WinCE port.
......
......@@ -47,14 +47,14 @@
namespace WebCore {
PassRefPtr<MediaSource> MediaSource::create(ScriptExecutionContext* context)
PassRefPtr<MediaSource> MediaSource::create(ScriptExecutionContext& context)
{
RefPtr<MediaSource> mediaSource(adoptRef(new MediaSource(context)));
mediaSource->suspendIfNeeded();
return mediaSource.release();
}
MediaSource::MediaSource(ScriptExecutionContext* context)
MediaSource::MediaSource(ScriptExecutionContext& context)
: MediaSourceBase(context)
{
LOG(Media, "MediaSource::MediaSource %p", this);
......
......@@ -43,7 +43,7 @@ namespace WebCore {
class MediaSource : public MediaSourceBase, public ScriptWrappable {
public:
static PassRefPtr<MediaSource> create(ScriptExecutionContext*);
static PassRefPtr<MediaSource> create(ScriptExecutionContext&);
virtual ~MediaSource();
// MediaSource.idl methods
......@@ -60,7 +60,7 @@ public:
using RefCounted<MediaSourceBase>::deref;
private:
explicit MediaSource(ScriptExecutionContext*);
explicit MediaSource(ScriptExecutionContext&);
// MediaSourceBase interface
virtual void onReadyStateChange(const AtomicString&, const AtomicString&) OVERRIDE;
......
......@@ -45,8 +45,8 @@
namespace WebCore {
MediaSourceBase::MediaSourceBase(ScriptExecutionContext* context)
: ActiveDOMObject(context)
MediaSourceBase::MediaSourceBase(ScriptExecutionContext& context)
: ActiveDOMObject(&context)
, m_readyState(closedKeyword())
, m_asyncEventQueue(*this)
, m_attached(false)
......
......@@ -92,7 +92,7 @@ public:
using RefCounted<MediaSourceBase>::deref;
protected:
explicit MediaSourceBase(ScriptExecutionContext*);
explicit MediaSourceBase(ScriptExecutionContext&);
virtual void onReadyStateChange(const AtomicString& oldState, const AtomicString& newState) = 0;
virtual Vector<RefPtr<TimeRanges>> activeRanges() const = 0;
......
......@@ -35,27 +35,27 @@
namespace WebCore {
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, const Dictionary& audioConstraints)
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext& context, const Dictionary& audioConstraints)
{
return adoptRef(new AudioStreamTrack(context, *MediaStreamTrackPrivate::create(0), &audioConstraints));
}
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack)
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
{
return adoptRef(new AudioStreamTrack(context, privateTrack, 0));
}
RefPtr<AudioStreamTrack> AudioStreamTrack::create(MediaStreamTrack* track)
RefPtr<AudioStreamTrack> AudioStreamTrack::create(MediaStreamTrack& track)
{
return adoptRef(new AudioStreamTrack(track));
}
AudioStreamTrack::AudioStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* audioConstraints)
AudioStreamTrack::AudioStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack, const Dictionary* audioConstraints)
: MediaStreamTrack(context, privateTrack, audioConstraints)
{
}
AudioStreamTrack::AudioStreamTrack(MediaStreamTrack* track)
AudioStreamTrack::AudioStreamTrack(MediaStreamTrack& track)
: MediaStreamTrack(track)
{
}
......
......@@ -39,17 +39,17 @@ class ScriptExecutionContext;
class AudioStreamTrack FINAL : public MediaStreamTrack {
public:
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, const Dictionary&);
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, MediaStreamTrackPrivate&);
static RefPtr<AudioStreamTrack> create(MediaStreamTrack*);
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext&, const Dictionary&);
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext&, MediaStreamTrackPrivate&);
static RefPtr<AudioStreamTrack> create(MediaStreamTrack&);
virtual ~AudioStreamTrack() { }
virtual const AtomicString& kind() const OVERRIDE;
private:
AudioStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
explicit AudioStreamTrack(MediaStreamTrack*);
AudioStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&, const Dictionary*);
explicit AudioStreamTrack(MediaStreamTrack&);
};
} // namespace WebCore
......
......@@ -41,12 +41,12 @@
namespace WebCore {
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context)
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context)
{
return MediaStream::create(context, MediaStreamDescriptor::create(MediaStreamSourceVector(), MediaStreamSourceVector()));
}
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStream> stream)
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context, PassRefPtr<MediaStream> stream)
{
ASSERT(stream);
......@@ -62,7 +62,7 @@ PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, Pas
return MediaStream::create(context, MediaStreamDescriptor::create(audioTracks, videoTracks));
}
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, const MediaStreamTrackVector& tracks)
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context, const MediaStreamTrackVector& tracks)
{
Vector<RefPtr<MediaStreamTrackPrivate>> audioTracks;
Vector<RefPtr<MediaStreamTrackPrivate>> videoTracks;
......@@ -77,13 +77,13 @@ PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, con
return MediaStream::create(context, MediaStreamDescriptor::create(audioTracks, videoTracks));
}
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
{
return adoptRef(new MediaStream(context, streamDescriptor));
}
MediaStream::MediaStream(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
: ContextDestructionObserver(context)
MediaStream::MediaStream(ScriptExecutionContext& context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
: ContextDestructionObserver(&context)
, m_descriptor(streamDescriptor)
, m_scheduledEventTimer(this, &MediaStream::scheduledEventTimerFired)
{
......@@ -286,11 +286,11 @@ void MediaStream::addRemoteSource(MediaStreamSource* source)
RefPtr<MediaStreamTrack> track;
switch (source->type()) {
case MediaStreamSource::Audio:
track = AudioStreamTrack::create(scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
track = AudioStreamTrack::create(*scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
m_audioTracks.append(track);
break;
case MediaStreamSource::Video:
track = VideoStreamTrack::create(scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
track = VideoStreamTrack::create(*scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
m_videoTracks.append(track);
break;
case MediaStreamSource::None:
......
......@@ -46,10 +46,10 @@ class MediaStreamCenter;
class MediaStream FINAL : public RefCounted<MediaStream>, public URLRegistrable, public ScriptWrappable, public MediaStreamDescriptorClient, public EventTargetWithInlineData, public ContextDestructionObserver {
public:
static PassRefPtr<MediaStream> create(ScriptExecutionContext*);
static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStream>);
static PassRefPtr<MediaStream> create(ScriptExecutionContext*, const MediaStreamTrackVector&);
static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>);
static PassRefPtr<MediaStream> create(ScriptExecutionContext&);
static PassRefPtr<MediaStream> create(ScriptExecutionContext&, PassRefPtr<MediaStream>);
static PassRefPtr<MediaStream> create(ScriptExecutionContext&, const MediaStreamTrackVector&);
static PassRefPtr<MediaStream> create(ScriptExecutionContext&, PassRefPtr<MediaStreamDescriptor>);
virtual ~MediaStream();
String id() const { return m_descriptor->id(); }
......@@ -82,7 +82,7 @@ public:
virtual URLRegistry& registry() const OVERRIDE;
protected:
MediaStream(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>);
MediaStream(ScriptExecutionContext&, PassRefPtr<MediaStreamDescriptor>);
// ContextDestructionObserver
virtual void contextDestroyed() OVERRIDE FINAL;
......
......@@ -51,8 +51,8 @@
namespace WebCore {
MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* constraints)
: ActiveDOMObject(context)
MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack, const Dictionary* constraints)
: ActiveDOMObject(&context)
, m_privateTrack(privateTrack)
, m_eventDispatchScheduled(false)
, m_stoppingTrack(false)
......@@ -65,9 +65,9 @@ MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext* context, MediaStreamT
applyConstraints(*constraints);
}
MediaStreamTrack::MediaStreamTrack(MediaStreamTrack* other)
: ActiveDOMObject(other->scriptExecutionContext())
, m_privateTrack(*other->privateTrack().clone())
MediaStreamTrack::MediaStreamTrack(MediaStreamTrack& other)
: ActiveDOMObject(other.scriptExecutionContext())
, m_privateTrack(*other.privateTrack().clone())
, m_eventDispatchScheduled(false)
, m_stoppingTrack(false)
{
......@@ -192,9 +192,9 @@ void MediaStreamTrack::applyConstraints(PassRefPtr<MediaConstraints>)
RefPtr<MediaStreamTrack> MediaStreamTrack::clone()
{
if (m_privateTrack->type() == MediaStreamSource::Audio)
return AudioStreamTrack::create(this);
return AudioStreamTrack::create(*this);
return VideoStreamTrack::create(this);
return VideoStreamTrack::create(*this);
}
void MediaStreamTrack::stopProducingData()
......
......@@ -105,8 +105,8 @@ public:
using RefCounted<MediaStreamTrack>::deref;
protected:
explicit MediaStreamTrack(MediaStreamTrack*);
MediaStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
explicit MediaStreamTrack(MediaStreamTrack&);
MediaStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&, const Dictionary*);
void setSource(PassRefPtr<MediaStreamSource>);
......
......@@ -114,7 +114,7 @@ PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
return rtcConfiguration.release();
}
PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
{
RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
if (ec)
......@@ -132,17 +132,17 @@ PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext*
return peerConnection.release();
}
RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionCode& ec)
: ActiveDOMObject(context)
RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context, PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionCode& ec)
: ActiveDOMObject(&context)
, m_signalingState(SignalingStateStable)
, m_iceGatheringState(IceGatheringStateNew)
, m_iceConnectionState(IceConnectionStateNew)
, m_scheduledEventTimer(this, &RTCPeerConnection::scheduledEventTimerFired)
, m_stopped(false)
{
Document* document = toDocument(m_scriptExecutionContext);
Document& document = toDocument(context);
if (!document->frame()) {
if (!document.frame()) {
ec = NOT_SUPPORTED_ERR;
return;
}
......@@ -153,7 +153,7 @@ RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr
return;
}
document->frame()->loader().client().dispatchWillStartUsingPeerConnectionHandler(m_peerHandler.get());
document.frame()->loader().client().dispatchWillStartUsingPeerConnectionHandler(m_peerHandler.get());
if (!m_peerHandler->initialize(configuration, constraints)) {
ec = NOT_SUPPORTED_ERR;
......
......@@ -60,7 +60,7 @@ class VoidCallback;
class RTCPeerConnection FINAL : public RefCounted<RTCPeerConnection>, public ScriptWrappable, public RTCPeerConnectionHandlerClient, public EventTargetWithInlineData, public ActiveDOMObject {
public:
static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode&);
static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext&, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode&);
~RTCPeerConnection();
void createOffer(PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCErrorCallback>, const Dictionary& mediaConstraints, ExceptionCode&);
......@@ -130,7 +130,7 @@ public:
using RefCounted<RTCPeerConnection>::deref;
private:
RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionCode&);
RTCPeerConnection(ScriptExecutionContext&, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionCode&);
static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionCode&);
void scheduleDispatchEvent(PassRefPtr<Event>);
......
......@@ -35,12 +35,12 @@
namespace WebCore {
RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext* context, const Dictionary& videoConstraints)
RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext& context, const Dictionary& videoConstraints)
{
return adoptRef(new VideoStreamTrack(context, *MediaStreamTrackPrivate::create(0), &videoConstraints));
}
RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack)
RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
{
return adoptRef(new VideoStreamTrack(context, privateTrack, 0));
}
......@@ -50,7 +50,7 @@ RefPtr<VideoStreamTrack> VideoStreamTrack::create(MediaStreamTrack* track)
return adoptRef(new VideoStreamTrack(track));
}
VideoStreamTrack::VideoStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* videoConstraints)
VideoStreamTrack::VideoStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack, const Dictionary* videoConstraints)
: MediaStreamTrack(context, privateTrack, videoConstraints)
{
}
......
......@@ -40,8 +40,8 @@ class MediaStremTrackDescriptor;
class VideoStreamTrack FINAL : public MediaStreamTrack {
public:
static RefPtr<VideoStreamTrack> create(ScriptExecutionContext*, const Dictionary&);
static RefPtr<VideoStreamTrack> create(ScriptExecutionContext*, MediaStreamTrackPrivate&);
static RefPtr<VideoStreamTrack> create(ScriptExecutionContext&, const Dictionary&);
static RefPtr<VideoStreamTrack> create(ScriptExecutionContext&, MediaStreamTrackPrivate&);
static RefPtr<VideoStreamTrack> create(MediaStreamTrack*);
virtual ~VideoStreamTrack() { }
......@@ -49,7 +49,7 @@ public:
virtual const AtomicString& kind() const OVERRIDE;
private:
VideoStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
VideoStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&, const Dictionary*);
explicit VideoStreamTrack(MediaStreamTrack*);
};
......
......@@ -80,13 +80,13 @@ Notification::Notification(const String& title, const String& body, const String
#endif
#if ENABLE(NOTIFICATIONS)
Notification::Notification(ScriptExecutionContext* context, const String& title)
: ActiveDOMObject(context)
Notification::Notification(ScriptExecutionContext& context, const String& title)
: ActiveDOMObject(&context)
, m_title(title)
, m_state(Idle)
, m_taskTimer(adoptPtr(new Timer<Notification>(this, &Notification::taskTimerFired)))
{
m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocument(context)->domWindow());
m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocument(context).domWindow());
ASSERT(m_notificationCenter->client());
m_taskTimer->startOneShot(0);
......@@ -107,7 +107,7 @@ PassRefPtr<Notification> Notification::create(const String& title, const String&
#endif
#if ENABLE(NOTIFICATIONS)
PassRefPtr<Notification> Notification::create(ScriptExecutionContext* context, const String& title, const Dictionary& options)
PassRefPtr<Notification> Notification::create(ScriptExecutionContext& context, const String& title, const Dictionary& options)
{
RefPtr<Notification> notification(adoptRef(new Notification(context, title)));
String argument;
......@@ -120,7 +120,7 @@ PassRefPtr<Notification> Notification::create(ScriptExecutionContext* context, c
if (options.get("dir", argument))
notification->setDir(argument);
if (options.get("icon", argument)) {
URL iconURI = argument.isEmpty() ? URL() : context->completeURL(argument);
URL iconURI = argument.isEmpty() ? URL() : context.completeURL(argument);
if (!iconURI.isEmpty() && iconURI.isValid())
notification->setIconURL(iconURI);
}
......
......@@ -71,7 +71,7 @@ public:
static PassRefPtr<Notification> create(const String& title, const String& body, const String& iconURI, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<NotificationCenter> provider);
#endif
#if ENABLE(NOTIFICATIONS)
static PassRefPtr<Notification> create(ScriptExecutionContext*, const String& title, const Dictionary& options);
static PassRefPtr<Notification> create(ScriptExecutionContext&, const String& title, const Dictionary& options);
#endif
virtual ~Notification();
......@@ -143,7 +143,7 @@ private:
Notification(const String& title, const String& body, const String& iconURI, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<NotificationCenter>);
#endif
#if ENABLE(NOTIFICATIONS)
Notification(ScriptExecutionContext*, const String& title);
Notification(ScriptExecutionContext&, const String& title);
#endif
void setBody(const String& body) { m_body = body; }
......
......@@ -30,13 +30,13 @@
namespace WebCore {
PassRefPtr<SpeechSynthesisUtterance> SpeechSynthesisUtterance::create(ScriptExecutionContext* context, const String& text)
PassRefPtr<SpeechSynthesisUtterance> SpeechSynthesisUtterance::create(ScriptExecutionContext& context, const String& text)
{
return adoptRef(new SpeechSynthesisUtterance(context, text));
}
SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext* context, const String& text)
: ContextDestructionObserver(context)
SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext& context, const String& text)
: ContextDestructionObserver(&context)
, m_platformUtterance(PlatformSpeechSynthesisUtterance::create(this))
{
m_platformUtterance->setText(text);
......
......@@ -39,7 +39,7 @@ namespace WebCore {
class SpeechSynthesisUtterance FINAL : public PlatformSpeechSynthesisUtteranceClient, public RefCounted<SpeechSynthesisUtterance>, public ContextDestructionObserver, public EventTargetWithInlineData {
public:
static PassRefPtr<SpeechSynthesisUtterance> create(ScriptExecutionContext*, const String&);
static PassRefPtr<SpeechSynthesisUtterance> create(ScriptExecutionContext&, const String&);
~SpeechSynthesisUtterance();
......@@ -80,7 +80,7 @@ public:
PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance.get(); }
private:
SpeechSynthesisUtterance(ScriptExecutionContext*, const String&);
SpeechSynthesisUtterance(ScriptExecutionContext&, const String&);
RefPtr<PlatformSpeechSynthesisUtterance> m_platformUtterance;
RefPtr<SpeechSynthesisVoice> m_voice;
......
......@@ -107,11 +107,10 @@ bool AudioContext::isSampleRateRangeGood(float sampleRate)
const unsigned MaxHardwareContexts = 4;
unsigned AudioContext::s_hardwareContextCount = 0;
PassRefPtr<AudioContext> AudioContext::create(Document* document, ExceptionCode& ec)
PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
ASSERT(document);
ASSERT(isMainThread());
if (s_hardwareContextCount >= MaxHardwareContexts)
return 0;
......@@ -122,8 +121,8 @@ PassRefPtr<AudioContext> AudioContext::create(Document* document, ExceptionCode&
}
// Constructor for rendering to the audio hardware.
AudioContext::AudioContext(Document* document)
: ActiveDOMObject(document)
AudioContext::AudioContext(Document& document)
: ActiveDOMObject(&document)
, m_isStopScheduled(false)
, m_isInitialized(false)
, m_isAudioThreadFinished(false)
......@@ -149,8 +148,8 @@ AudioContext::AudioContext(Document* document)
}
// Constructor for offline (non-realtime) rendering.
AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: ActiveDOMObject(document)
AudioContext::AudioContext(Document& document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: ActiveDOMObject(&document)
, m_isStopScheduled(false)
, m_isInitialized(false)
, m_isAudioThreadFinished(false)
......
......@@ -76,7 +76,7 @@ class PeriodicWave;
class AudioContext : public ActiveDOMObject, public ThreadSafeRefCounted<AudioContext>, public EventTargetWithInlineData, public MediaCanStartListener {
public:
// Create an AudioContext for rendering to the audio hardware.
static PassRefPtr<AudioContext> create(Document*, ExceptionCode&);
static PassRefPtr<AudioContext> create(Document&, ExceptionCode&);
// Create an AudioContext for offline (non-realtime) rendering.
static PassRefPtr<AudioContext> createOfflineContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode&);
......@@ -265,8 +265,8 @@ public:
void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
protected:
explicit AudioContext(Document*);
AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
explicit AudioContext(Document&);
AudioContext(Document&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
static bool isSampleRateRangeGood(float sampleRate);
......
......@@ -34,15 +34,15 @@
namespace WebCore {
PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionContext* context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionContext& context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
{
// FIXME: add support for workers.
if (!context || !context->isDocument()) {
if (!context.isDocument()) {
ec = NOT_SUPPORTED_ERR;
return 0;
}
Document* document = toDocument(context);
Document& document = toDocument(context);
if (numberOfChannels > 10 || !isSampleRateRangeGood(sampleRate)) {
ec = SYNTAX_ERR;
......@@ -54,7 +54,7 @@ PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionConte
return audioContext.release();
}
OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
OfflineAudioContext::OfflineAudioContext(Document& document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: AudioContext(document, numberOfChannels, numberOfFrames, sampleRate)
{
}
......
......@@ -31,12 +31,12 @@ namespace WebCore {
class OfflineAudioContext : public AudioContext {
public:
static PassRefPtr<OfflineAudioContext> create(ScriptExecutionContext*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode&);
static PassRefPtr<OfflineAudioContext> create(ScriptExecutionContext&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode&);
virtual ~OfflineAudioContext();
private:
OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
OfflineAudioContext(Document&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
};
} // namespace WebCore
......
......@@ -141,8 +141,8 @@ const char* WebSocket::subProtocolSeperator()
return ", ";
}
WebSocket::WebSocket(ScriptExecutionContext* context)
: ActiveDOMObject(context)
WebSocket::WebSocket(ScriptExecutionContext& context)
: ActiveDOMObject(&context)
, m_state(CONNECTING)
, m_bufferedAmount(0)
, m_bufferedAmountAfterClose(0)
......@@ -158,20 +158,20 @@ WebSocket::~WebSocket()
m_channel->disconnect();
}
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context)
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context)
{
RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context)));
webSocket->suspendIfNeeded();
return webSocket.release();
}
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, ExceptionCode& ec)
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context, const String& url, ExceptionCode& ec)
{
Vector<String> protocols;
return WebSocket::create(context, url, protocols, ec);
}
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const Vector<String>& protocols, ExceptionCode& ec)
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context, const String& url, const Vector<String>& protocols, ExceptionCode& ec)
{
if (url.isNull()) {
ec = SYNTAX_ERR;
......@@ -181,14 +181,14 @@ PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const S
RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context)));
webSocket->suspendIfNeeded();
webSocket->connect(context->completeURL(url), protocols, ec);
webSocket->connect(context.completeURL(url), protocols, ec);
if (ec)
return 0;
return webSocket.release();
}
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const String& protocol, ExceptionCode& ec)
PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context, const String& url, const String& protocol, ExceptionCode& ec)
{
Vector<String> protocols;
protocols.append(protocol);
......
......@@ -55,10 +55,10 @@ public:
static void setIsAvailable(bool);
static bool isAvailable();
static const char* subProtocolSeperator();
static PassRefPtr<WebSocket> create(ScriptExecutionContext*);
static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& url, ExceptionCode&);
static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& url, const String& protocol, ExceptionCode&);
static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& url, const Vector<String>& protocols, ExceptionCode&);
static PassRefPtr<WebSocket> create(ScriptExecutionContext&);
static PassRefPtr<WebSocket> create(ScriptExecutionContext&, const String& url, ExceptionCode&);
static PassRefPtr<WebSocket> create(ScriptExecutionContext&, const String& url, const String& protocol, ExceptionCode&);
static PassRefPtr<WebSocket> create(ScriptExecutionContext&, const String& url, const Vector<String>& protocols, ExceptionCode&);
virtual ~WebSocket();
enum State {
......@@ -113,7 +113,7 @@ public:
virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE;
private:
explicit WebSocket(ScriptExecutionContext*);
explicit WebSocket(ScriptExecutionContext&);
// ActiveDOMObject functions.