Commit bb381c75 authored by darin@apple.com's avatar darin@apple.com

2010-07-07 Darin Adler <darin@apple.com>

        Reviewed by Adam Barth.

        Turn on adoptRef assertion for RefCounted
        https://bugs.webkit.org/show_bug.cgi?id=41547

        * wtf/CrossThreadRefCounted.h: Fixed include style. Includes of other
        WTF headers should use "" includes; consistent in most WTF headers.
        Added a call to relaxAdoptionRequirement.

        * wtf/RefCounted.h: Fixed include style. Removed LOOSE_REF_COUNTED.
        Added relaxAdoptionRequirement.
2010-07-07  Darin Adler  <darin@apple.com>

        Reviewed by Adam Barth.

        Turn on adoptRef assertion for RefCounted
        https://bugs.webkit.org/show_bug.cgi?id=41547

        The WebCore part of this fixes all the assertions I saw in testing.

        * html/FileReader.cpp:
        (WebCore::FileReader::readAsBinaryString): Added null checks.
        Callers from JavaScript can pass the wrong type, which becomes null.
        (WebCore::FileReader::readAsText): Ditto.
        (WebCore::FileReader::readAsDataURL): Ditto.

        * html/FileStreamClient.h: Removed unneeded include.

        * html/FileStreamProxy.cpp:
        (WebCore::FileStreamProxy::FileStreamProxy): Made inline and moved
        some of the code, including the ref, into the create function.
        (WebCore::FileStreamProxy::create): Moved some of the code from
        the constructor here. It's safe to ref once the object has been
        created and adopted.

        * html/FileStreamProxy.h: Changed create function to no longer be
        inlined. Also removed an unneeded include.

        * page/EventSource.cpp:
        (WebCore::EventSource::EventSource): Made inline, changed arguments
        and moved code that involves the need to ref this object into the
        create function. Also moved failure handling out there since it's
        cleaner to have a function that fails than a constructor. For
        example, the function can return 0.
        (WebCore::EventSource::create): Moved some of the code from the
        constructor here.

        * page/EventSource.h: Removed unneeded includes. Made the
        creation function non-inline. Changed the arguments to the constructor.

        * storage/StorageAreaSync.cpp:
        (WebCore::StorageAreaSync::StorageAreaSync): Made inline. Moved
        code that requires ref'ing this object out to the create function.
        (WebCore::StorageAreaSync::create): Moved some of the code from the
        constructor here.

        * storage/StorageAreaSync.h: Removed unneeded includes. Changed
        the type of one of the constructor arguments from String to
        const String&.

        * workers/SharedWorker.cpp:
        (WebCore::SharedWorker::SharedWorker): Made inline. Moved most of
        the setup code out of here into the create function.
        (WebCore::SharedWorker::create): Moved the code here.

        * workers/SharedWorker.h: Removed unneeded includes. Made the
        create function non-inline. Marked the toSharedWorker override private
        to catch people doing an unnecessary virtual function call if they
        already have a SharedWorker*.

        * workers/Worker.cpp:
        (WebCore::Worker::Worker): Made inline. Moved most of the setup code
        out of here into the create function.
        (WebCore::Worker::create): Moved the code here.

        * workers/Worker.h: Made the create function non-inline. Changed
        the arguments to the constructor.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@62696 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 42b3b74b
2010-07-07 Darin Adler <darin@apple.com>
Reviewed by Adam Barth.
Turn on adoptRef assertion for RefCounted
https://bugs.webkit.org/show_bug.cgi?id=41547
* wtf/CrossThreadRefCounted.h: Fixed include style. Includes of other
WTF headers should use "" includes; consistent in most WTF headers.
Added a call to relaxAdoptionRequirement.
* wtf/RefCounted.h: Fixed include style. Removed LOOSE_REF_COUNTED.
Added relaxAdoptionRequirement.
2010-07-07 Anders Carlsson <andersca@apple.com>
Try to fix the Windows build.
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -31,10 +32,9 @@
#ifndef CrossThreadRefCounted_h
#define CrossThreadRefCounted_h
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/Threading.h>
#include "PassRefPtr.h"
#include "RefCounted.h"
#include "Threading.h"
namespace WTF {
......@@ -78,6 +78,9 @@ namespace WTF {
, m_threadId(0)
#endif
{
// We use RefCountedBase in an unusual way here, so get rid of the requirement
// that adoptRef be called on it.
m_refCounter.relaxAdoptionRequirement();
}
~CrossThreadRefCounted()
......
......@@ -21,11 +21,8 @@
#ifndef RefCounted_h
#define RefCounted_h
#include <wtf/Assertions.h>
#include <wtf/Noncopyable.h>
// Remove this once we make all WebKit code compatible with stricter rules about RefCounted.
#define LOOSE_REF_COUNTED
#include "Assertions.h"
#include "Noncopyable.h"
namespace WTF {
......@@ -37,9 +34,7 @@ public:
void ref()
{
ASSERT(!m_deletionHasBegun);
#ifndef LOOSE_REF_COUNTED
ASSERT(!m_adoptionIsRequired);
#endif
++m_refCount;
}
......@@ -54,6 +49,15 @@ public:
return m_refCount;
}
void relaxAdoptionRequirement()
{
#ifndef NDEBUG
ASSERT(!m_deletionHasBegun);
ASSERT(m_adoptionIsRequired);
m_adoptionIsRequired = false;
#endif
}
protected:
RefCountedBase()
: m_refCount(1)
......@@ -66,19 +70,15 @@ protected:
~RefCountedBase()
{
#ifndef LOOSE_REF_COUNTED
ASSERT(m_deletionHasBegun);
ASSERT(!m_adoptionIsRequired);
#endif
}
// Returns whether the pointer should be freed or not.
bool derefBase()
{
ASSERT(!m_deletionHasBegun);
#ifndef LOOSE_REF_COUNTED
ASSERT(!m_adoptionIsRequired);
#endif
ASSERT(m_refCount > 0);
if (m_refCount == 1) {
......
2010-07-07 Darin Adler <darin@apple.com>
Reviewed by Adam Barth.
Turn on adoptRef assertion for RefCounted
https://bugs.webkit.org/show_bug.cgi?id=41547
The WebCore part of this fixes all the assertions I saw in testing.
* html/FileReader.cpp:
(WebCore::FileReader::readAsBinaryString): Added null checks.
Callers from JavaScript can pass the wrong type, which becomes null.
(WebCore::FileReader::readAsText): Ditto.
(WebCore::FileReader::readAsDataURL): Ditto.
* html/FileStreamClient.h: Removed unneeded include.
* html/FileStreamProxy.cpp:
(WebCore::FileStreamProxy::FileStreamProxy): Made inline and moved
some of the code, including the ref, into the create function.
(WebCore::FileStreamProxy::create): Moved some of the code from
the constructor here. It's safe to ref once the object has been
created and adopted.
* html/FileStreamProxy.h: Changed create function to no longer be
inlined. Also removed an unneeded include.
* page/EventSource.cpp:
(WebCore::EventSource::EventSource): Made inline, changed arguments
and moved code that involves the need to ref this object into the
create function. Also moved failure handling out there since it's
cleaner to have a function that fails than a constructor. For
example, the function can return 0.
(WebCore::EventSource::create): Moved some of the code from the
constructor here.
* page/EventSource.h: Removed unneeded includes. Made the
creation function non-inline. Changed the arguments to the constructor.
* storage/StorageAreaSync.cpp:
(WebCore::StorageAreaSync::StorageAreaSync): Made inline. Moved
code that requires ref'ing this object out to the create function.
(WebCore::StorageAreaSync::create): Moved some of the code from the
constructor here.
* storage/StorageAreaSync.h: Removed unneeded includes. Changed
the type of one of the constructor arguments from String to
const String&.
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::SharedWorker): Made inline. Moved most of
the setup code out of here into the create function.
(WebCore::SharedWorker::create): Moved the code here.
* workers/SharedWorker.h: Removed unneeded includes. Made the
create function non-inline. Marked the toSharedWorker override private
to catch people doing an unnecessary virtual function call if they
already have a SharedWorker*.
* workers/Worker.cpp:
(WebCore::Worker::Worker): Made inline. Moved most of the setup code
out of here into the create function.
(WebCore::Worker::create): Moved the code here.
* workers/Worker.h: Made the create function non-inline. Changed
the arguments to the constructor.
2010-07-07 Chris Fleizach <cfleizach@apple.com>
Reviewed by Beth Dakin.
......@@ -85,6 +85,9 @@ void FileReader::stop()
void FileReader::readAsBinaryString(Blob* fileBlob)
{
if (!fileBlob)
return;
// FIXME: needs to handle non-file blobs.
LOG(FileAPI, "FileReader: reading as binary: %s\n", fileBlob->path().utf8().data());
......@@ -93,6 +96,9 @@ void FileReader::readAsBinaryString(Blob* fileBlob)
void FileReader::readAsText(Blob* fileBlob, const String& encoding)
{
if (!fileBlob)
return;
// FIXME: needs to handle non-file blobs.
LOG(FileAPI, "FileReader: reading as text: %s\n", fileBlob->path().utf8().data());
......@@ -103,6 +109,9 @@ void FileReader::readAsText(Blob* fileBlob, const String& encoding)
void FileReader::readAsDataURL(File* file)
{
if (!file)
return;
LOG(FileAPI, "FileReader: reading as data URL: %s\n", file->path().utf8().data());
m_fileType = file->type();
......
......@@ -34,7 +34,6 @@
#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER)
#include "ExceptionCode.h"
#include <wtf/PassRefPtr.h>
namespace WebCore {
......
......@@ -44,15 +44,24 @@
namespace WebCore {
FileStreamProxy::FileStreamProxy(ScriptExecutionContext* context, FileStreamClient* client)
inline FileStreamProxy::FileStreamProxy(ScriptExecutionContext* context, FileStreamClient* client)
: m_context(context)
, m_client(client)
, m_stream(FileStream::create(this))
{
// Holds an extra ref so that the instance will not get deleted while there can be any tasks on the file thread.
ref();
}
PassRefPtr<FileStreamProxy> FileStreamProxy::create(ScriptExecutionContext* context, FileStreamClient* client)
{
RefPtr<FileStreamProxy> proxy = adoptRef(new FileStreamProxy(context, client));
// Hold an ref so that the instance will not get deleted while there are tasks on the file thread.
// This is balanced by the deref in derefProxyOnContext below.
proxy->ref();
proxy->fileThread()->postTask(createFileThreadTask(proxy->m_stream.get(), &FileStream::start));
fileThread()->postTask(createFileThreadTask(m_stream.get(), &FileStream::start));
return proxy.release();
}
FileStreamProxy::~FileStreamProxy()
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -33,7 +34,6 @@
#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER)
#include "ExceptionCode.h"
#include "FileStreamClient.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
......@@ -50,10 +50,7 @@ class String;
// A proxy module that calls corresponding FileStream methods on the file thread. Note: you must call stop() first and then release the reference to destruct the FileStreamProxy instance.
class FileStreamProxy : public RefCounted<FileStreamProxy>, public FileStreamClient {
public:
static PassRefPtr<FileStreamProxy> create(ScriptExecutionContext* context, FileStreamClient* client)
{
return adoptRef(new FileStreamProxy(context, client));
}
static PassRefPtr<FileStreamProxy> create(ScriptExecutionContext*, FileStreamClient*);
virtual ~FileStreamProxy();
void openForRead(Blob* blob);
......
/*
* Copyright (C) 2009 Ericsson AB
* All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -53,30 +54,45 @@ namespace WebCore {
const unsigned long long EventSource::defaultReconnectDelay = 3000;
EventSource::EventSource(const String& url, ScriptExecutionContext* context, ExceptionCode& ec)
inline EventSource::EventSource(const KURL& url, ScriptExecutionContext* context)
: ActiveDOMObject(context, this)
, m_url(url)
, m_state(CONNECTING)
, m_decoder(TextResourceDecoder::create("text/plain", "UTF-8"))
, m_reconnectTimer(this, &EventSource::reconnectTimerFired)
, m_discardTrailingNewline(false)
, m_failSilently(false)
, m_requestInFlight(false)
, m_reconnectDelay(defaultReconnectDelay)
, m_origin(context->securityOrigin()->toString())
{
if (url.isEmpty() || !(m_url = context->completeURL(url)).isValid()) {
}
PassRefPtr<EventSource> EventSource::create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec)
{
if (url.isEmpty()) {
ec = SYNTAX_ERR;
return;
return 0;
}
// FIXME: should support cross-origin requests
if (!scriptExecutionContext()->securityOrigin()->canRequest(m_url)) {
KURL fullURL = context->completeURL(url);
if (!fullURL.isValid()) {
ec = SYNTAX_ERR;
return 0;
}
// FIXME: Should support at least some cross-origin requests.
if (!context->securityOrigin()->canRequest(fullURL)) {
ec = SECURITY_ERR;
return;
return 0;
}
m_origin = scriptExecutionContext()->securityOrigin()->toString();
m_decoder = TextResourceDecoder::create("text/plain", "UTF-8");
RefPtr<EventSource> source = adoptRef(new EventSource(fullURL, context));
setPendingActivity(this);
connect();
source->setPendingActivity(source.get());
source->connect();
return source.release();
}
EventSource::~EventSource()
......
/*
* Copyright (C) 2009 Ericsson AB
* All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -35,15 +36,10 @@
#if ENABLE(EVENTSOURCE)
#include "ActiveDOMObject.h"
#include "AtomicStringHash.h"
#include "EventNames.h"
#include "EventTarget.h"
#include "KURL.h"
#include "ThreadableLoaderClient.h"
#include "Timer.h"
#include <wtf/HashMap.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
......@@ -56,7 +52,7 @@ namespace WebCore {
class EventSource : public RefCounted<EventSource>, public EventTarget, private ThreadableLoaderClient, public ActiveDOMObject {
public:
static PassRefPtr<EventSource> create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec) { return adoptRef(new EventSource(url, context, ec)); }
static PassRefPtr<EventSource> create(const String& url, ScriptExecutionContext*, ExceptionCode&);
virtual ~EventSource();
static const unsigned long long defaultReconnectDelay;
......@@ -86,17 +82,17 @@ namespace WebCore {
virtual void stop();
private:
EventSource(const String& url, ScriptExecutionContext* context, ExceptionCode& ec);
EventSource(const KURL&, ScriptExecutionContext*);
virtual void refEventTarget() { ref(); }
virtual void derefEventTarget() { deref(); }
virtual EventTargetData* eventTargetData();
virtual EventTargetData* ensureEventTargetData();
virtual void didReceiveResponse(const ResourceResponse& response);
virtual void didReceiveResponse(const ResourceResponse&);
virtual void didReceiveData(const char* data, int length);
virtual void didFinishLoading(unsigned long);
virtual void didFail(const ResourceError& error);
virtual void didFail(const ResourceError&);
virtual void didFailRedirectCheck();
void connect();
......
/*
* Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
* Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -49,12 +49,7 @@ static const double StorageSyncInterval = 1.0;
// much harder to starve the rest of LocalStorage and the OS's IO subsystem in general.
static const int MaxiumItemsToSync = 100;
PassRefPtr<StorageAreaSync> StorageAreaSync::create(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageAreaImpl> storageArea, String databaseIdentifier)
{
return adoptRef(new StorageAreaSync(storageSyncManager, storageArea, databaseIdentifier));
}
StorageAreaSync::StorageAreaSync(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageAreaImpl> storageArea, String databaseIdentifier)
inline StorageAreaSync::StorageAreaSync(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageAreaImpl> storageArea, const String& databaseIdentifier)
: m_syncTimer(this, &StorageAreaSync::syncTimerFired)
, m_itemsCleared(false)
, m_finalSyncScheduled(false)
......@@ -70,11 +65,18 @@ StorageAreaSync::StorageAreaSync(PassRefPtr<StorageSyncManager> storageSyncManag
ASSERT(isMainThread());
ASSERT(m_storageArea);
ASSERT(m_syncManager);
}
PassRefPtr<StorageAreaSync> StorageAreaSync::create(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageAreaImpl> storageArea, const String& databaseIdentifier)
{
RefPtr<StorageAreaSync> area = adoptRef(new StorageAreaSync(storageSyncManager, storageArea, databaseIdentifier));
// FIXME: If it can't import, then the default WebKit behavior should be that of private browsing,
// not silently ignoring it. https://bugs.webkit.org/show_bug.cgi?id=25894
if (!m_syncManager->scheduleImport(this))
m_importComplete = true;
// not silently ignoring it. https://bugs.webkit.org/show_bug.cgi?id=25894
if (!area->m_syncManager->scheduleImport(area.get()))
area->m_importComplete = true;
return area.release();
}
StorageAreaSync::~StorageAreaSync()
......
/*
* Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
* Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -28,7 +28,6 @@
#if ENABLE(DOM_STORAGE)
#include "PlatformString.h"
#include "SQLiteDatabase.h"
#include "StringHash.h"
#include "Timer.h"
......@@ -42,7 +41,7 @@ namespace WebCore {
class StorageAreaSync : public RefCounted<StorageAreaSync> {
public:
static PassRefPtr<StorageAreaSync> create(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageAreaImpl> storageArea, String databaseIdentifier);
static PassRefPtr<StorageAreaSync> create(PassRefPtr<StorageSyncManager>, PassRefPtr<StorageAreaImpl>, const String& databaseIdentifier);
~StorageAreaSync();
void scheduleFinalSync();
......@@ -52,7 +51,7 @@ namespace WebCore {
void scheduleClear();
private:
StorageAreaSync(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageAreaImpl> storageArea, String databaseIdentifier);
StorageAreaSync(PassRefPtr<StorageSyncManager>, PassRefPtr<StorageAreaImpl>, const String& databaseIdentifier);
void dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame);
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -42,22 +43,32 @@
namespace WebCore {
SharedWorker::SharedWorker(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
inline SharedWorker::SharedWorker(ScriptExecutionContext* context)
: AbstractWorker(context)
{
RefPtr<MessageChannel> channel = MessageChannel::create(scriptExecutionContext());
m_port = channel->port1();
}
PassRefPtr<SharedWorker> SharedWorker::create(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
{
RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context));
RefPtr<MessageChannel> channel = MessageChannel::create(context);
worker->m_port = channel->port1();
OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle(ec);
ASSERT(!ec);
ASSERT(remotePort);
KURL scriptURL = worker->resolveURL(url, ec);
if (scriptURL.isEmpty())
return 0;
SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptURL, name, ec);
KURL scriptUrl = resolveURL(url, ec);
if (ec)
return;
SharedWorkerRepository::connect(this, remotePort.release(), scriptUrl, name, ec);
#if ENABLE(INSPECTOR)
if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
inspector->didCreateWorker(asID(), scriptUrl.string(), true);
if (InspectorController* inspector = context->inspectorController())
inspector->didCreateWorker(worker->asID(), scriptURL.string(), true);
#endif
return worker.release();
}
SharedWorker::~SharedWorker()
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -33,26 +34,21 @@
#include "AbstractWorker.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#if ENABLE(SHARED_WORKERS)
namespace WebCore {
class SharedWorker : public AbstractWorker {
public:
static PassRefPtr<SharedWorker> create(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
{
return adoptRef(new SharedWorker(url, name, context, ec));
}
~SharedWorker();
MessagePort* port() const { return m_port.get(); }
static PassRefPtr<SharedWorker> create(const String& url, const String& name, ScriptExecutionContext*, ExceptionCode&);
virtual ~SharedWorker();
virtual SharedWorker* toSharedWorker() { return this; }
MessagePort* port() const { return m_port.get(); }
private:
SharedWorker(const String& url, const String& name, ScriptExecutionContext*, ExceptionCode&);
SharedWorker(ScriptExecutionContext*);
virtual SharedWorker* toSharedWorker() { return this; }
RefPtr<MessagePort> m_port;
};
......
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
* Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
* Copyright (C) 2009 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -50,21 +50,32 @@
namespace WebCore {
Worker::Worker(const String& url, ScriptExecutionContext* context, ExceptionCode& ec)
inline Worker::Worker(ScriptExecutionContext* context)
: AbstractWorker(context)
, m_contextProxy(WorkerContextProxy::create(this))
{
KURL scriptURL = resolveURL(url, ec);
if (ec)
return;
}
PassRefPtr<Worker> Worker::create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec)
{
RefPtr<Worker> worker = adoptRef(new Worker(context));
KURL scriptURL = worker->resolveURL(url, ec);
if (scriptURL.isEmpty())
return 0;
worker->m_scriptLoader = adoptPtr(new WorkerScriptLoader(ResourceRequestBase::TargetIsWorker));
worker->m_scriptLoader->loadAsynchronously(context, scriptURL, DenyCrossOriginRequests, worker.get());
// The worker context does not exist while loading, so we must ensure that the worker object is not collected, nor are its event listeners.
worker->setPendingActivity(worker.get());
m_scriptLoader = new WorkerScriptLoader(ResourceRequestBase::TargetIsWorker);
m_scriptLoader->loadAsynchronously(scriptExecutionContext(), scriptURL, DenyCrossOriginRequests, this);
setPendingActivity(this); // The worker context does not exist while loading, so we must ensure that the worker object is not collected, as well as its event listeners.
#if ENABLE(INSPECTOR)
if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
inspector->didCreateWorker(asID(), scriptURL.string(), false);
if (InspectorController* inspector = context->inspectorController())
inspector->didCreateWorker(worker->asID(), scriptURL.string(), false);
#endif
return worker.release();
}
Worker::~Worker()
......
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
* Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -53,13 +53,13 @@ namespace WebCore {
class Worker : public AbstractWorker, private WorkerScriptLoaderClient {
public:
static PassRefPtr<Worker> create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec) { return adoptRef(new Worker(url, context, ec)); }
~Worker();
static PassRefPtr<Worker> create(const String& url, ScriptExecutionContext*, ExceptionCode&);
virtual ~Worker();
virtual Worker* toWorker() { return this; }
void postMessage(PassRefPtr<SerializedScriptValue>, ExceptionCode&);
void postMessage(PassRefPtr<SerializedScriptValue>, const MessagePortArray*, ExceptionCode&);
void postMessage(PassRefPtr<SerializedScriptValue> message, ExceptionCode&);
void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
// FIXME: remove this when we update the ObjC bindings (bug #28774).
void postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort*, ExceptionCode&);
......@@ -72,7 +72,7 @@ namespace WebCore {
DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
private:
Worker(const String&, ScriptExecutionContext*, ExceptionCode&);
Worker(ScriptExecutionContext*);
virtual void notifyFinished();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment