2013-02-05 15:17:17 -08:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "URL.h"
|
|
|
|
|
2013-03-21 17:05:20 -07:00
|
|
|
#include "nsIDocument.h"
|
2013-02-05 15:17:17 -08:00
|
|
|
#include "nsIDOMFile.h"
|
2013-10-23 06:16:49 -07:00
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2013-02-05 15:17:17 -08:00
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
#include "mozilla/dom/URL.h"
|
2013-11-05 06:16:25 -08:00
|
|
|
#include "mozilla/dom/URLBinding.h"
|
2013-12-12 11:30:27 -08:00
|
|
|
#include "mozilla/dom/URLSearchParams.h"
|
2013-10-23 06:16:49 -07:00
|
|
|
#include "nsGlobalWindow.h"
|
|
|
|
#include "nsHostObjectProtocolHandler.h"
|
2013-09-04 10:07:34 -07:00
|
|
|
#include "nsNetCID.h"
|
2013-10-23 06:16:49 -07:00
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
|
|
|
|
#include "File.h"
|
|
|
|
#include "WorkerPrivate.h"
|
|
|
|
#include "WorkerRunnable.h"
|
2013-09-04 10:07:34 -07:00
|
|
|
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
2013-08-22 22:17:08 -07:00
|
|
|
using mozilla::dom::GlobalObject;
|
2013-02-05 15:17:17 -08:00
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
class URLProxy MOZ_FINAL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLProxy)
|
|
|
|
|
|
|
|
URLProxy(mozilla::dom::URL* aURL)
|
|
|
|
: mURL(aURL)
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::dom::URL* URL()
|
|
|
|
{
|
|
|
|
return mURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIURI* URI()
|
|
|
|
{
|
|
|
|
return mURL->GetURI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReleaseURI()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
mURL = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-04-02 09:21:03 -07:00
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~URLProxy()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mURL);
|
|
|
|
}
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<mozilla::dom::URL> mURL;
|
|
|
|
};
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
// This class creates an URL from a DOM Blob on the main thread.
|
2014-02-24 05:57:03 -08:00
|
|
|
class CreateURLRunnable : public WorkerMainThreadRunnable
|
2013-02-05 15:17:17 -08:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
nsIDOMBlob* mBlob;
|
|
|
|
nsString& mURL;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CreateURLRunnable(WorkerPrivate* aWorkerPrivate, nsIDOMBlob* aBlob,
|
2013-08-22 22:17:09 -07:00
|
|
|
const mozilla::dom::objectURLOptions& aOptions,
|
2013-02-05 15:17:17 -08:00
|
|
|
nsString& aURL)
|
2014-02-24 05:57:03 -08:00
|
|
|
: WorkerMainThreadRunnable(aWorkerPrivate),
|
2013-02-05 15:17:17 -08:00
|
|
|
mBlob(aBlob),
|
|
|
|
mURL(aURL)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aBlob);
|
|
|
|
}
|
|
|
|
|
2014-02-24 05:57:03 -08:00
|
|
|
bool
|
2013-02-05 15:17:17 -08:00
|
|
|
MainThreadRun()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
2013-06-22 14:48:00 -07:00
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
nsIDocument* doc = nullptr;
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = mWorkerPrivate->GetWindow();
|
2013-06-22 14:48:00 -07:00
|
|
|
if (window) {
|
|
|
|
doc = window->GetExtantDoc();
|
|
|
|
if (!doc) {
|
|
|
|
SetDOMStringToNull(mURL);
|
2014-02-24 05:57:03 -08:00
|
|
|
return false;
|
2013-06-22 14:48:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
principal = doc->NodePrincipal();
|
|
|
|
} else {
|
2013-07-18 07:30:41 -07:00
|
|
|
MOZ_ASSERT_IF(!mWorkerPrivate->GetParent(), mWorkerPrivate->IsChromeWorker());
|
2013-06-22 14:48:00 -07:00
|
|
|
principal = mWorkerPrivate->GetPrincipal();
|
2013-02-05 15:17:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCString url;
|
|
|
|
nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(
|
|
|
|
NS_LITERAL_CSTRING(BLOBURI_SCHEME),
|
2013-06-22 14:48:00 -07:00
|
|
|
mBlob, principal, url);
|
2013-02-05 15:17:17 -08:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Failed to add data entry for the blob!");
|
|
|
|
SetDOMStringToNull(mURL);
|
2014-02-24 05:57:03 -08:00
|
|
|
return false;
|
2013-02-05 15:17:17 -08:00
|
|
|
}
|
|
|
|
|
2013-06-22 14:48:00 -07:00
|
|
|
if (doc) {
|
|
|
|
doc->RegisterHostObjectUri(url);
|
|
|
|
} else {
|
|
|
|
mWorkerPrivate->RegisterHostObjectURI(url);
|
|
|
|
}
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
mURL = NS_ConvertUTF8toUTF16(url);
|
2014-02-24 05:57:03 -08:00
|
|
|
return true;
|
2013-02-05 15:17:17 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// This class revokes an URL on the main thread.
|
2014-02-24 05:57:03 -08:00
|
|
|
class RevokeURLRunnable : public WorkerMainThreadRunnable
|
2013-02-05 15:17:17 -08:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
const nsString mURL;
|
|
|
|
|
|
|
|
public:
|
|
|
|
RevokeURLRunnable(WorkerPrivate* aWorkerPrivate,
|
|
|
|
const nsAString& aURL)
|
2014-02-24 05:57:03 -08:00
|
|
|
: WorkerMainThreadRunnable(aWorkerPrivate),
|
2013-02-05 15:17:17 -08:00
|
|
|
mURL(aURL)
|
|
|
|
{}
|
|
|
|
|
2014-02-24 05:57:03 -08:00
|
|
|
bool
|
2013-02-05 15:17:17 -08:00
|
|
|
MainThreadRun()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
2013-06-22 14:48:00 -07:00
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
nsIDocument* doc = nullptr;
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = mWorkerPrivate->GetWindow();
|
2013-06-22 14:48:00 -07:00
|
|
|
if (window) {
|
|
|
|
doc = window->GetExtantDoc();
|
|
|
|
if (!doc) {
|
2014-02-24 05:57:03 -08:00
|
|
|
return false;
|
2013-06-22 14:48:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
principal = doc->NodePrincipal();
|
|
|
|
} else {
|
2013-07-18 07:30:41 -07:00
|
|
|
MOZ_ASSERT_IF(!mWorkerPrivate->GetParent(), mWorkerPrivate->IsChromeWorker());
|
2013-06-22 14:48:00 -07:00
|
|
|
principal = mWorkerPrivate->GetPrincipal();
|
2013-02-05 15:17:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ConvertUTF16toUTF8 url(mURL);
|
|
|
|
|
2013-06-22 14:48:00 -07:00
|
|
|
nsIPrincipal* urlPrincipal =
|
2013-02-05 15:17:17 -08:00
|
|
|
nsHostObjectProtocolHandler::GetDataEntryPrincipal(url);
|
|
|
|
|
|
|
|
bool subsumes;
|
2013-06-22 14:48:00 -07:00
|
|
|
if (urlPrincipal &&
|
|
|
|
NS_SUCCEEDED(principal->Subsumes(urlPrincipal, &subsumes)) &&
|
2013-02-05 15:17:17 -08:00
|
|
|
subsumes) {
|
2013-06-22 14:48:00 -07:00
|
|
|
if (doc) {
|
|
|
|
doc->UnregisterHostObjectUri(url);
|
|
|
|
}
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
nsHostObjectProtocolHandler::RemoveDataEntry(url);
|
|
|
|
}
|
2013-06-22 14:48:00 -07:00
|
|
|
|
|
|
|
if (!window) {
|
|
|
|
mWorkerPrivate->UnregisterHostObjectURI(url);
|
|
|
|
}
|
2014-02-24 05:57:03 -08:00
|
|
|
|
|
|
|
return true;
|
2013-02-05 15:17:17 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
// This class creates a URL object on the main thread.
|
2014-02-24 05:57:03 -08:00
|
|
|
class ConstructorRunnable : public WorkerMainThreadRunnable
|
2013-09-04 10:07:34 -07:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
const nsString mURL;
|
|
|
|
|
|
|
|
const nsString mBase;
|
|
|
|
nsRefPtr<URLProxy> mBaseProxy;
|
|
|
|
mozilla::ErrorResult& mRv;
|
|
|
|
|
|
|
|
nsRefPtr<URLProxy> mRetval;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ConstructorRunnable(WorkerPrivate* aWorkerPrivate,
|
|
|
|
const nsAString& aURL, const nsAString& aBase,
|
|
|
|
mozilla::ErrorResult& aRv)
|
2014-02-24 05:57:03 -08:00
|
|
|
: WorkerMainThreadRunnable(aWorkerPrivate)
|
2013-09-04 10:07:34 -07:00
|
|
|
, mURL(aURL)
|
|
|
|
, mBase(aBase)
|
|
|
|
, mRv(aRv)
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstructorRunnable(WorkerPrivate* aWorkerPrivate,
|
|
|
|
const nsAString& aURL, URLProxy* aBaseProxy,
|
|
|
|
mozilla::ErrorResult& aRv)
|
2014-02-24 05:57:03 -08:00
|
|
|
: WorkerMainThreadRunnable(aWorkerPrivate)
|
2013-09-04 10:07:34 -07:00
|
|
|
, mURL(aURL)
|
|
|
|
, mBaseProxy(aBaseProxy)
|
|
|
|
, mRv(aRv)
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2014-02-24 05:57:03 -08:00
|
|
|
bool
|
2013-09-04 10:07:34 -07:00
|
|
|
MainThreadRun()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mRv.Throw(rv);
|
2014-02-24 05:57:03 -08:00
|
|
|
return true;
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> baseURL;
|
|
|
|
|
|
|
|
if (!mBaseProxy) {
|
|
|
|
rv = ioService->NewURI(NS_ConvertUTF16toUTF8(mBase), nullptr, nullptr,
|
|
|
|
getter_AddRefs(baseURL));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
2014-02-24 05:57:03 -08:00
|
|
|
return true;
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
baseURL = mBaseProxy->URI();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> url;
|
|
|
|
rv = ioService->NewURI(NS_ConvertUTF16toUTF8(mURL), nullptr, baseURL,
|
|
|
|
getter_AddRefs(url));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
2014-02-24 05:57:03 -08:00
|
|
|
return true;
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
2013-10-09 23:56:01 -07:00
|
|
|
mRetval = new URLProxy(new mozilla::dom::URL(url));
|
2014-02-24 05:57:03 -08:00
|
|
|
return true;
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
URLProxy*
|
|
|
|
GetURLProxy()
|
|
|
|
{
|
|
|
|
return mRetval;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-18 12:02:24 -08:00
|
|
|
class TeardownURLRunnable : public nsRunnable
|
2013-09-04 10:07:34 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-02-18 12:02:24 -08:00
|
|
|
TeardownURLRunnable(URLProxy* aURLProxy)
|
2013-09-04 10:07:34 -07:00
|
|
|
: mURLProxy(aURLProxy)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
mURLProxy->ReleaseURI();
|
|
|
|
mURLProxy = nullptr;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<URLProxy> mURLProxy;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This class is the generic getter for any URL property.
|
2014-02-24 05:57:03 -08:00
|
|
|
class GetterRunnable : public WorkerMainThreadRunnable
|
2013-09-04 10:07:34 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum GetterType {
|
|
|
|
GetterHref,
|
|
|
|
GetterOrigin,
|
|
|
|
GetterProtocol,
|
|
|
|
GetterUsername,
|
|
|
|
GetterPassword,
|
|
|
|
GetterHost,
|
|
|
|
GetterHostname,
|
|
|
|
GetterPort,
|
|
|
|
GetterPathname,
|
|
|
|
GetterSearch,
|
|
|
|
GetterHash,
|
|
|
|
};
|
|
|
|
|
|
|
|
GetterRunnable(WorkerPrivate* aWorkerPrivate,
|
|
|
|
GetterType aType, nsString& aValue,
|
|
|
|
URLProxy* aURLProxy)
|
2014-02-24 05:57:03 -08:00
|
|
|
: WorkerMainThreadRunnable(aWorkerPrivate)
|
2013-09-04 10:07:34 -07:00
|
|
|
, mValue(aValue)
|
|
|
|
, mType(aType)
|
|
|
|
, mURLProxy(aURLProxy)
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2014-02-24 05:57:03 -08:00
|
|
|
bool
|
2013-09-04 10:07:34 -07:00
|
|
|
MainThreadRun()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
switch (mType) {
|
|
|
|
case GetterHref:
|
|
|
|
mURLProxy->URL()->GetHref(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterOrigin:
|
|
|
|
mURLProxy->URL()->GetOrigin(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterProtocol:
|
|
|
|
mURLProxy->URL()->GetProtocol(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterUsername:
|
|
|
|
mURLProxy->URL()->GetUsername(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterPassword:
|
|
|
|
mURLProxy->URL()->GetPassword(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterHost:
|
|
|
|
mURLProxy->URL()->GetHost(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterHostname:
|
|
|
|
mURLProxy->URL()->GetHostname(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterPort:
|
|
|
|
mURLProxy->URL()->GetPort(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterPathname:
|
|
|
|
mURLProxy->URL()->GetPathname(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterSearch:
|
|
|
|
mURLProxy->URL()->GetSearch(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GetterHash:
|
|
|
|
mURLProxy->URL()->GetHash(mValue);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-24 05:57:03 -08:00
|
|
|
|
|
|
|
return true;
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsString& mValue;
|
|
|
|
GetterType mType;
|
|
|
|
nsRefPtr<URLProxy> mURLProxy;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This class is the generic setter for any URL property.
|
2014-02-24 05:57:03 -08:00
|
|
|
class SetterRunnable : public WorkerMainThreadRunnable
|
2013-09-04 10:07:34 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum SetterType {
|
|
|
|
SetterHref,
|
|
|
|
SetterProtocol,
|
|
|
|
SetterUsername,
|
|
|
|
SetterPassword,
|
|
|
|
SetterHost,
|
|
|
|
SetterHostname,
|
|
|
|
SetterPort,
|
|
|
|
SetterPathname,
|
|
|
|
SetterSearch,
|
|
|
|
SetterHash,
|
|
|
|
};
|
|
|
|
|
|
|
|
SetterRunnable(WorkerPrivate* aWorkerPrivate,
|
|
|
|
SetterType aType, const nsAString& aValue,
|
|
|
|
URLProxy* aURLProxy, mozilla::ErrorResult& aRv)
|
2014-02-24 05:57:03 -08:00
|
|
|
: WorkerMainThreadRunnable(aWorkerPrivate)
|
2013-09-04 10:07:34 -07:00
|
|
|
, mValue(aValue)
|
|
|
|
, mType(aType)
|
|
|
|
, mURLProxy(aURLProxy)
|
|
|
|
, mRv(aRv)
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2014-02-24 05:57:03 -08:00
|
|
|
bool
|
2013-09-04 10:07:34 -07:00
|
|
|
MainThreadRun()
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
switch (mType) {
|
|
|
|
case SetterHref:
|
|
|
|
mURLProxy->URL()->SetHref(mValue, mRv);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterProtocol:
|
|
|
|
mURLProxy->URL()->SetProtocol(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterUsername:
|
|
|
|
mURLProxy->URL()->SetUsername(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterPassword:
|
|
|
|
mURLProxy->URL()->SetPassword(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterHost:
|
|
|
|
mURLProxy->URL()->SetHost(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterHostname:
|
|
|
|
mURLProxy->URL()->SetHostname(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterPort:
|
|
|
|
mURLProxy->URL()->SetPort(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterPathname:
|
|
|
|
mURLProxy->URL()->SetPathname(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterSearch:
|
|
|
|
mURLProxy->URL()->SetSearch(mValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SetterHash:
|
|
|
|
mURLProxy->URL()->SetHash(mValue);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-24 05:57:03 -08:00
|
|
|
|
|
|
|
return true;
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const nsString mValue;
|
|
|
|
SetterType mType;
|
|
|
|
nsRefPtr<URLProxy> mURLProxy;
|
|
|
|
mozilla::ErrorResult& mRv;
|
|
|
|
};
|
|
|
|
|
2014-04-25 09:49:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION(URL, mSearchParams)
|
2013-12-12 11:30:27 -08:00
|
|
|
|
|
|
|
// The reason for using worker::URL is to have different refcnt logging than
|
|
|
|
// for main thread URL.
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(workers::URL)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(workers::URL)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(URL)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-09-04 10:07:21 -07:00
|
|
|
// static
|
|
|
|
URL*
|
|
|
|
URL::Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
URL& aBase, ErrorResult& aRv)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
JSContext* cx = aGlobal.GetContext();
|
|
|
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
|
|
|
|
|
|
|
|
nsRefPtr<ConstructorRunnable> runnable =
|
|
|
|
new ConstructorRunnable(workerPrivate, aUrl, aBase.GetURLProxy(), aRv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(cx)) {
|
|
|
|
JS_ReportPendingException(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<URLProxy> proxy = runnable->GetURLProxy();
|
|
|
|
if (!proxy) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
return new URL(workerPrivate, proxy);
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
URL*
|
|
|
|
URL::Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
JSContext* cx = aGlobal.GetContext();
|
|
|
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
|
|
|
|
|
|
|
|
nsRefPtr<ConstructorRunnable> runnable =
|
|
|
|
new ConstructorRunnable(workerPrivate, aUrl, aBase, aRv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(cx)) {
|
|
|
|
JS_ReportPendingException(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<URLProxy> proxy = runnable->GetURLProxy();
|
|
|
|
if (!proxy) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
return new URL(workerPrivate, proxy);
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
URL::URL(WorkerPrivate* aWorkerPrivate, URLProxy* aURLProxy)
|
2013-11-05 06:16:25 -08:00
|
|
|
: mWorkerPrivate(aWorkerPrivate)
|
2013-09-04 10:07:34 -07:00
|
|
|
, mURLProxy(aURLProxy)
|
|
|
|
{
|
2013-11-05 06:16:25 -08:00
|
|
|
MOZ_COUNT_CTOR(workers::URL);
|
2013-09-04 10:07:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
URL::~URL()
|
|
|
|
{
|
2013-11-05 06:16:25 -08:00
|
|
|
MOZ_COUNT_DTOR(workers::URL);
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
if (mURLProxy) {
|
2014-02-18 12:02:24 -08:00
|
|
|
nsRefPtr<TeardownURLRunnable> runnable =
|
|
|
|
new TeardownURLRunnable(mURLProxy);
|
2013-09-04 10:07:34 -07:00
|
|
|
mURLProxy = nullptr;
|
|
|
|
|
|
|
|
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
|
|
|
NS_ERROR("Failed to dispatch teardown runnable!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-05 06:16:25 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
URL::WrapObject(JSContext* aCx)
|
2013-09-04 10:07:34 -07:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return URLBinding_workers::Wrap(aCx, this);
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetHref(nsString& aHref) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterHref, aHref,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetHref(const nsAString& aHref, ErrorResult& aRv)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterHref, aHref,
|
|
|
|
mURLProxy, aRv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-12-12 11:30:27 -08:00
|
|
|
|
2014-02-03 08:48:38 -08:00
|
|
|
UpdateURLSearchParams();
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetOrigin(nsString& aOrigin) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterOrigin, aOrigin,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetProtocol(nsString& aProtocol) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterProtocol, aProtocol,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetProtocol(const nsAString& aProtocol)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterProtocol,
|
|
|
|
aProtocol, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetUsername(nsString& aUsername) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterUsername, aUsername,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetUsername(const nsAString& aUsername)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterUsername,
|
|
|
|
aUsername, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetPassword(nsString& aPassword) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterPassword, aPassword,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetPassword(const nsAString& aPassword)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterPassword,
|
|
|
|
aPassword, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetHost(nsString& aHost) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterHost, aHost,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetHost(const nsAString& aHost)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterHost,
|
|
|
|
aHost, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetHostname(nsString& aHostname) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterHostname, aHostname,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetHostname(const nsAString& aHostname)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterHostname,
|
|
|
|
aHostname, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetPort(nsString& aPort) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterPort, aPort,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetPort(const nsAString& aPort)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterPort,
|
|
|
|
aPort, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetPathname(nsString& aPathname) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterPathname, aPathname,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetPathname(const nsAString& aPathname)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterPathname,
|
|
|
|
aPathname, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::GetSearch(nsString& aSearch) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterSearch, aSearch,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetSearch(const nsAString& aSearch)
|
2013-12-12 11:30:27 -08:00
|
|
|
{
|
|
|
|
SetSearchInternal(aSearch);
|
2014-02-03 08:48:38 -08:00
|
|
|
UpdateURLSearchParams();
|
2013-12-12 11:30:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetSearchInternal(const nsAString& aSearch)
|
2013-09-04 10:07:21 -07:00
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterSearch,
|
|
|
|
aSearch, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
2013-12-12 11:30:27 -08:00
|
|
|
mozilla::dom::URLSearchParams*
|
2014-03-19 08:36:46 -07:00
|
|
|
URL::SearchParams()
|
2013-12-12 11:30:27 -08:00
|
|
|
{
|
|
|
|
CreateSearchParamsIfNeeded();
|
|
|
|
return mSearchParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-03-19 08:36:46 -07:00
|
|
|
URL::SetSearchParams(URLSearchParams& aSearchParams)
|
2013-12-12 11:30:27 -08:00
|
|
|
{
|
2014-02-03 08:48:38 -08:00
|
|
|
if (mSearchParams) {
|
|
|
|
mSearchParams->RemoveObserver(this);
|
2013-12-12 11:30:27 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 08:36:46 -07:00
|
|
|
mSearchParams = &aSearchParams;
|
2014-02-03 08:48:38 -08:00
|
|
|
mSearchParams->AddObserver(this);
|
2013-12-12 11:30:27 -08:00
|
|
|
|
|
|
|
nsString search;
|
|
|
|
mSearchParams->Serialize(search);
|
|
|
|
SetSearchInternal(search);
|
|
|
|
}
|
|
|
|
|
2013-09-04 10:07:21 -07:00
|
|
|
void
|
|
|
|
URL::GetHash(nsString& aHash) const
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
nsRefPtr<GetterRunnable> runnable =
|
|
|
|
new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterHash, aHash,
|
|
|
|
mURLProxy);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::SetHash(const nsAString& aHash)
|
|
|
|
{
|
2013-09-04 10:07:34 -07:00
|
|
|
ErrorResult rv;
|
|
|
|
nsRefPtr<SetterRunnable> runnable =
|
|
|
|
new SetterRunnable(mWorkerPrivate, SetterRunnable::SetterHash,
|
|
|
|
aHash, mURLProxy, rv);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
|
|
|
JS_ReportPendingException(mWorkerPrivate->GetJSContext());
|
|
|
|
}
|
2013-09-04 10:07:21 -07:00
|
|
|
}
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
// static
|
|
|
|
void
|
2013-08-22 22:17:08 -07:00
|
|
|
URL::CreateObjectURL(const GlobalObject& aGlobal, JSObject* aBlob,
|
2013-08-22 22:17:09 -07:00
|
|
|
const mozilla::dom::objectURLOptions& aOptions,
|
2013-02-05 15:17:17 -08:00
|
|
|
nsString& aResult, mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
JSContext* cx = aGlobal.GetContext();
|
|
|
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMBlob> blob = file::GetDOMBlobFromJSObject(aBlob);
|
|
|
|
if (!blob) {
|
|
|
|
SetDOMStringToNull(aResult);
|
2013-02-06 07:50:27 -08:00
|
|
|
|
2013-06-17 10:07:03 -07:00
|
|
|
NS_NAMED_LITERAL_STRING(argStr, "Argument 1 of URL.createObjectURL");
|
2013-02-06 07:50:27 -08:00
|
|
|
NS_NAMED_LITERAL_STRING(blobStr, "Blob");
|
2013-06-17 10:07:03 -07:00
|
|
|
aRv.ThrowTypeError(MSG_DOES_NOT_IMPLEMENT_INTERFACE, &argStr, &blobStr);
|
2013-02-05 15:17:17 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<CreateURLRunnable> runnable =
|
|
|
|
new CreateURLRunnable(workerPrivate, blob, aOptions, aResult);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(cx)) {
|
|
|
|
JS_ReportPendingException(cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 00:04:11 -08:00
|
|
|
// static
|
|
|
|
void
|
2013-08-22 22:17:08 -07:00
|
|
|
URL::CreateObjectURL(const GlobalObject& aGlobal, JSObject& aBlob,
|
2013-08-22 22:17:09 -07:00
|
|
|
const mozilla::dom::objectURLOptions& aOptions,
|
2013-02-15 00:04:11 -08:00
|
|
|
nsString& aResult, mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
return CreateObjectURL(aGlobal, &aBlob, aOptions, aResult, aRv);
|
|
|
|
}
|
|
|
|
|
2013-02-05 15:17:17 -08:00
|
|
|
// static
|
|
|
|
void
|
2013-08-22 22:17:08 -07:00
|
|
|
URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl)
|
2013-02-05 15:17:17 -08:00
|
|
|
{
|
|
|
|
JSContext* cx = aGlobal.GetContext();
|
|
|
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
|
|
|
|
|
|
|
|
nsRefPtr<RevokeURLRunnable> runnable =
|
|
|
|
new RevokeURLRunnable(workerPrivate, aUrl);
|
|
|
|
|
|
|
|
if (!runnable->Dispatch(cx)) {
|
|
|
|
JS_ReportPendingException(cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-12 11:30:27 -08:00
|
|
|
void
|
|
|
|
URL::URLSearchParamsUpdated()
|
|
|
|
{
|
2014-02-03 08:48:38 -08:00
|
|
|
MOZ_ASSERT(mSearchParams);
|
2013-12-12 11:30:27 -08:00
|
|
|
|
|
|
|
nsString search;
|
|
|
|
mSearchParams->Serialize(search);
|
|
|
|
SetSearchInternal(search);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-03 08:48:38 -08:00
|
|
|
URL::UpdateURLSearchParams()
|
2013-12-12 11:30:27 -08:00
|
|
|
{
|
2014-02-03 08:48:38 -08:00
|
|
|
if (mSearchParams) {
|
|
|
|
nsString search;
|
|
|
|
GetSearch(search);
|
|
|
|
mSearchParams->ParseInput(NS_ConvertUTF16toUTF8(Substring(search, 1)), this);
|
|
|
|
}
|
2013-12-12 11:30:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
URL::CreateSearchParamsIfNeeded()
|
|
|
|
{
|
|
|
|
if (!mSearchParams) {
|
|
|
|
mSearchParams = new URLSearchParams();
|
2014-02-03 08:48:38 -08:00
|
|
|
mSearchParams->AddObserver(this);
|
|
|
|
UpdateURLSearchParams();
|
2013-12-12 11:30:27 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 10:07:34 -07:00
|
|
|
END_WORKERS_NAMESPACE
|