Skip to content

Commit

Permalink
Bug 1430139 P3 Remove workers namespace from service worker code. r=a…
Browse files Browse the repository at this point in the history
…suth
  • Loading branch information
wanderview committed Jan 26, 2018
1 parent d4213ff commit d895430
Show file tree
Hide file tree
Showing 61 changed files with 401 additions and 493 deletions.
3 changes: 1 addition & 2 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/ServiceWorkerInterceptController.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerUtils.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/TabGroup.h"
#include "mozilla/dom/ToJSValue.h"

#include "mozilla/dom/workers/ServiceWorkerManager.h"

#include "mozilla/net/ReferrerPolicy.h"

Expand Down Expand Up @@ -229,7 +229,6 @@

using namespace mozilla;
using namespace mozilla::dom;
using mozilla::dom::workers::ServiceWorkerManager;

// Threshold value in ms for META refresh based redirects
#define REFRESH_REDIRECT_TIMER 15000
Expand Down
1 change: 0 additions & 1 deletion dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/XULCommandEvent.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"
Expand Down
4 changes: 2 additions & 2 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#include "mozilla/dom/TreeWalker.h"

#include "nsIServiceManager.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "imgLoader.h"

#include "nsCanvasFrame.h"
Expand Down Expand Up @@ -5530,7 +5530,7 @@ nsDocument::DispatchContentLoadedEvents()
}

if (mMaybeServiceWorkerControlled) {
using mozilla::dom::workers::ServiceWorkerManager;
using mozilla::dom::ServiceWorkerManager;
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (swm) {
Maybe<ClientInfo> clientInfo = GetClientInfo();
Expand Down
10 changes: 0 additions & 10 deletions dom/bindings/Bindings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,15 @@ DOMInterfaces = {

'ExtendableEvent': {
'headerFile': 'mozilla/dom/ServiceWorkerEvents.h',
'nativeType': 'mozilla::dom::workers::ExtendableEvent',
'implicitJSContext': [ 'waitUntil' ],
},

'ExtendableMessageEvent': {
'headerFile': 'mozilla/dom/ServiceWorkerEvents.h',
'nativeType': 'mozilla::dom::workers::ExtendableMessageEvent',
},

'FetchEvent': {
'headerFile': 'ServiceWorkerEvents.h',
'nativeType': 'mozilla::dom::workers::FetchEvent',
'binaryNames': {
'request': 'request_'
},
Expand Down Expand Up @@ -722,12 +719,10 @@ DOMInterfaces = {

'PushEvent': {
'headerFile': 'ServiceWorkerEvents.h',
'nativeType': 'mozilla::dom::workers::PushEvent',
},

'PushMessageData': {
'headerFile': 'ServiceWorkerEvents.h',
'nativeType': 'mozilla::dom::workers::PushMessageData',
},

'Range': {
Expand Down Expand Up @@ -763,11 +758,6 @@ DOMInterfaces = {
'nativeType': 'nsScreen',
},

'ServiceWorker': {
'nativeType': 'mozilla::dom::workers::ServiceWorker',
'headerFile': 'mozilla/dom/workers/bindings/ServiceWorker.h',
},

'ServiceWorkerGlobalScope': {
'headerFile': 'mozilla/dom/WorkerScope.h',
},
Expand Down
3 changes: 1 addition & 2 deletions dom/clients/api/Clients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "mozilla/dom/ClientsBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorkerDescriptor.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/SystemGroup.h"
#include "nsIGlobalObject.h"
#include "nsString.h"
Expand All @@ -23,7 +23,6 @@ namespace dom {

using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
using mozilla::dom::workers::WorkerPrivate;
using mozilla::dom::workers::ServiceWorkerManager;
using mozilla::ipc::PrincipalInfo;

NS_IMPL_CYCLE_COLLECTING_ADDREF(Clients);
Expand Down
7 changes: 2 additions & 5 deletions dom/clients/manager/ClientSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
#include "mozilla/dom/ServiceWorker.h"
#include "mozilla/dom/ServiceWorkerContainer.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/workers/bindings/ServiceWorker.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "nsContentUtils.h"
#include "nsIDocShell.h"
#include "nsPIDOMWindow.h"
Expand All @@ -29,9 +29,6 @@ namespace mozilla {
namespace dom {

using mozilla::dom::ipc::StructuredCloneData;
using mozilla::dom::workers::ServiceWorkerInfo;
using mozilla::dom::workers::ServiceWorkerManager;
using mozilla::dom::workers::ServiceWorkerRegistrationInfo;
using mozilla::dom::workers::WorkerPrivate;
using mozilla::ipc::PrincipalInfo;
using mozilla::ipc::PrincipalInfoToPrincipal;
Expand Down
10 changes: 4 additions & 6 deletions dom/events/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ namespace dom {

class EventTarget;
class EventMessageAutoOverride;
// ExtendableEvent is a ServiceWorker event that is not
// autogenerated since it has some extra methods.
class ExtendableEvent;
class WantsPopupControlCheck;
#define GENERATED_EVENT(EventClass_) class EventClass_;
#include "mozilla/dom/GeneratedEventList.h"
#undef GENERATED_EVENT
// ExtendableEvent is a ServiceWorker event that is not
// autogenerated since it has some extra methods.
namespace workers {
class ExtendableEvent;
} // namespace workers

// Dummy class so we can cast through it to get from nsISupports to
// Event subclasses with only two non-ambiguous static casts.
Expand Down Expand Up @@ -106,7 +104,7 @@ class Event : public EventBase,

// ExtendableEvent is a ServiceWorker event that is not
// autogenerated since it has some extra methods.
virtual workers::ExtendableEvent* AsExtendableEvent()
virtual ExtendableEvent* AsExtendableEvent()
{
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/events/MessageEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "mozilla/dom/MessageEventBinding.h"
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/workers/bindings/ServiceWorker.h"
#include "mozilla/dom/ServiceWorker.h"

#include "mozilla/HoldDropJSObjects.h"
#include "jsapi.h"
Expand Down
7 changes: 2 additions & 5 deletions dom/events/MessageEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ namespace dom {
struct MessageEventInit;
class MessagePort;
class OwningWindowProxyOrMessagePortOrServiceWorker;
class WindowProxyOrMessagePortOrServiceWorker;

namespace workers {
class ServiceWorker;
}
class WindowProxyOrMessagePortOrServiceWorker;

/**
* Implements the MessageEvent event, used for cross-document messaging and
Expand Down Expand Up @@ -79,7 +76,7 @@ class MessageEvent final : public Event
nsString mLastEventId;
RefPtr<nsPIDOMWindowOuter> mWindowSource;
RefPtr<MessagePort> mPortSource;
RefPtr<workers::ServiceWorker> mServiceWorkerSource;
RefPtr<ServiceWorker> mServiceWorkerSource;

nsTArray<RefPtr<MessagePort>> mPorts;
};
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#include "mozilla/dom/PLoginReputationChild.h"
#include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/PushNotifier.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/TabGroup.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/nsIContentChild.h"
#include "mozilla/dom/URLClassifierChild.h"
#include "mozilla/gfx/gfxVars.h"
Expand Down
2 changes: 1 addition & 1 deletion dom/notification/Notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWorkerProxy.h"
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
#include "mozilla/dom/ServiceWorkerManager.h"

#include "nsAlertsUtils.h"
#include "nsComponentManagerUtils.h"
Expand Down Expand Up @@ -53,7 +54,6 @@
#include "nsThreadUtils.h"
#include "nsToolkitCompsCID.h"
#include "nsXULAppAPI.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
Expand Down
3 changes: 1 addition & 2 deletions dom/push/PushNotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "nsIXULRuntime.h"
#include "nsNetUtil.h"
#include "nsXPCOM.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerManager.h"

#include "mozilla/Services.h"
#include "mozilla/Unused.h"
Expand All @@ -25,7 +25,6 @@ namespace mozilla {
namespace dom {

using workers::AssertIsOnMainThread;
using workers::ServiceWorkerManager;

PushNotifier::PushNotifier()
{}
Expand Down
8 changes: 3 additions & 5 deletions dom/serviceworkers/ServiceWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ using namespace mozilla::dom;

namespace mozilla {
namespace dom {
namespace workers {

bool
ServiceWorkerVisible(JSContext* aCx, JSObject* aObj)
Expand All @@ -44,7 +43,7 @@ ServiceWorker::ServiceWorker(nsPIDOMWindowInner* aWindow,
: DOMEventTargetHelper(aWindow),
mInfo(aInfo)
{
AssertIsOnMainThread();
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aInfo);

// This will update our state too.
Expand All @@ -53,7 +52,7 @@ ServiceWorker::ServiceWorker(nsPIDOMWindowInner* aWindow,

ServiceWorker::~ServiceWorker()
{
AssertIsOnMainThread();
MOZ_ASSERT(NS_IsMainThread());
mInfo->RemoveWorker(this);
}

Expand All @@ -66,7 +65,7 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
JSObject*
ServiceWorker::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
AssertIsOnMainThread();
MOZ_ASSERT(NS_IsMainThread());

return ServiceWorkerBinding::Wrap(aCx, this, aGivenProto);
}
Expand Down Expand Up @@ -116,6 +115,5 @@ ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
clientState.ref().ToIPC()));
}

} // namespace workers
} // namespace dom
} // namespace mozilla
9 changes: 3 additions & 6 deletions dom/serviceworkers/ServiceWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* 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/. */

#ifndef mozilla_dom_workers_serviceworker_h__
#define mozilla_dom_workers_serviceworker_h__
#ifndef mozilla_dom_serviceworker_h__
#define mozilla_dom_serviceworker_h__

#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/BindingDeclarations.h"
Expand All @@ -16,8 +16,6 @@ class nsPIDOMWindowInner;
namespace mozilla {
namespace dom {

namespace workers {

class ServiceWorkerInfo;
class ServiceWorkerManager;
class SharedWorker;
Expand Down Expand Up @@ -77,8 +75,7 @@ class ServiceWorker final : public DOMEventTargetHelper
const RefPtr<ServiceWorkerInfo> mInfo;
};

} // namespace workers
} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_workers_serviceworker_h__
#endif // mozilla_dom_serviceworker_h__
10 changes: 3 additions & 7 deletions dom/serviceworkers/ServiceWorkerContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@
#include "mozilla/dom/DOMPrefs.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorker.h"
#include "mozilla/dom/ServiceWorkerContainerBinding.h"
#include "mozilla/dom/workers/bindings/ServiceWorker.h"

#include "ServiceWorker.h"

namespace mozilla {
namespace dom {

using mozilla::dom::workers::ServiceWorkerInfo;
using mozilla::dom::workers::ServiceWorkerManager;
using mozilla::dom::workers::ServiceWorkerRegistrationInfo;

NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerContainer)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)

Expand Down Expand Up @@ -217,7 +213,7 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
return ret.forget();
}

already_AddRefed<workers::ServiceWorker>
already_AddRefed<ServiceWorker>
ServiceWorkerContainer::GetController()
{
if (!mControllerWorker) {
Expand Down Expand Up @@ -258,7 +254,7 @@ ServiceWorkerContainer::GetController()
mControllerWorker = info->GetOrCreateInstance(inner);
}

RefPtr<workers::ServiceWorker> ref = mControllerWorker;
RefPtr<ServiceWorker> ref = mControllerWorker;
return ref.forget();
}

Expand Down
9 changes: 3 additions & 6 deletions dom/serviceworkers/ServiceWorkerContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ namespace dom {

class Promise;
struct RegistrationOptions;

namespace workers {
class ServiceWorker;
} // namespace workers

// Lightweight serviceWorker APIs collection.
class ServiceWorkerContainer final : public DOMEventTargetHelper
Expand All @@ -44,7 +41,7 @@ class ServiceWorkerContainer final : public DOMEventTargetHelper
const RegistrationOptions& aOptions,
ErrorResult& aRv);

already_AddRefed<workers::ServiceWorker>
already_AddRefed<ServiceWorker>
GetController();

already_AddRefed<Promise>
Expand Down Expand Up @@ -76,12 +73,12 @@ class ServiceWorkerContainer final : public DOMEventTargetHelper

// This only changes when a worker hijacks everything in its scope by calling
// claim.
RefPtr<workers::ServiceWorker> mControllerWorker;
RefPtr<ServiceWorker> mControllerWorker;

RefPtr<Promise> mReadyPromise;
};

} // namespace dom
} // namespace mozilla

#endif /* mozilla_dom_workers_serviceworkercontainer_h__ */
#endif /* mozilla_dom_serviceworkercontainer_h__ */
Loading

0 comments on commit d895430

Please sign in to comment.