|
|
|
|
| 28 |
#include "Workers.h" |
28 |
#include "Workers.h" |
| 29 |
#include "WorkerScope.h" |
29 |
#include "WorkerScope.h" |
| 30 |
|
30 |
|
| 31 |
#ifndef MOZ_SIMPLEPUSH |
31 |
#ifndef MOZ_SIMPLEPUSH |
| 32 |
#include "mozilla/dom/PushManagerBinding.h" |
32 |
#include "mozilla/dom/PushManagerBinding.h" |
| 33 |
#include "mozilla/dom/PushManager.h" |
33 |
#include "mozilla/dom/PushManager.h" |
| 34 |
#endif |
34 |
#endif |
| 35 |
|
35 |
|
|
|
36 |
#include "mozilla/dom/SyncManagerBinding.h" |
| 37 |
#include "mozilla/dom/SyncManager.h" |
| 38 |
|
| 36 |
using namespace mozilla::dom::workers; |
39 |
using namespace mozilla::dom::workers; |
| 37 |
|
40 |
|
| 38 |
namespace mozilla { |
41 |
namespace mozilla { |
| 39 |
namespace dom { |
42 |
namespace dom { |
| 40 |
|
43 |
|
| 41 |
bool |
44 |
bool |
| 42 |
ServiceWorkerRegistrationVisible(JSContext* aCx, JSObject* aObj) |
45 |
ServiceWorkerRegistrationVisible(JSContext* aCx, JSObject* aObj) |
| 43 |
{ |
46 |
{ |
|
Lines 87-106
ServiceWorkerRegistrationBase::ServiceWo
|
Link Here
|
|---|
|
| 87 |
NS_IMPL_ADDREF_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase) |
90 |
NS_IMPL_ADDREF_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase) |
| 88 |
NS_IMPL_RELEASE_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase) |
91 |
NS_IMPL_RELEASE_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase) |
| 89 |
|
92 |
|
| 90 |
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistrationMainThread) |
93 |
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistrationMainThread) |
| 91 |
NS_INTERFACE_MAP_END_INHERITING(ServiceWorkerRegistrationBase) |
94 |
NS_INTERFACE_MAP_END_INHERITING(ServiceWorkerRegistrationBase) |
| 92 |
|
95 |
|
| 93 |
#ifndef MOZ_SIMPLEPUSH |
96 |
#ifndef MOZ_SIMPLEPUSH |
| 94 |
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase, |
97 |
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase, |
| 95 |
mPushManager, |
98 |
mPushManager, mSyncManager, |
| 96 |
mInstallingWorker, mWaitingWorker, mActiveWorker); |
99 |
mInstallingWorker, mWaitingWorker, mActiveWorker); |
| 97 |
#else |
100 |
#else |
| 98 |
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase, |
101 |
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistrationMainThread, ServiceWorkerRegistrationBase, |
|
|
102 |
mSyncManager, |
| 99 |
mInstallingWorker, mWaitingWorker, mActiveWorker); |
103 |
mInstallingWorker, mWaitingWorker, mActiveWorker); |
| 100 |
#endif |
104 |
#endif |
| 101 |
|
105 |
|
| 102 |
ServiceWorkerRegistrationMainThread::ServiceWorkerRegistrationMainThread(nsPIDOMWindowInner* aWindow, |
106 |
ServiceWorkerRegistrationMainThread::ServiceWorkerRegistrationMainThread(nsPIDOMWindowInner* aWindow, |
| 103 |
const nsAString& aScope) |
107 |
const nsAString& aScope) |
| 104 |
: ServiceWorkerRegistrationBase(aWindow, aScope) |
108 |
: ServiceWorkerRegistrationBase(aWindow, aScope) |
| 105 |
, mListeningForEvents(false) |
109 |
, mListeningForEvents(false) |
| 106 |
{ |
110 |
{ |
|
Lines 777-792
ServiceWorkerRegistrationMainThread::Get
|
Link Here
|
|---|
|
| 777 |
} |
781 |
} |
| 778 |
|
782 |
|
| 779 |
RefPtr<PushManager> ret = mPushManager; |
783 |
RefPtr<PushManager> ret = mPushManager; |
| 780 |
return ret.forget(); |
784 |
return ret.forget(); |
| 781 |
|
785 |
|
| 782 |
#endif /* ! MOZ_SIMPLEPUSH */ |
786 |
#endif /* ! MOZ_SIMPLEPUSH */ |
| 783 |
} |
787 |
} |
| 784 |
|
788 |
|
|
|
789 |
SyncManager* |
| 790 |
ServiceWorkerRegistrationMainThread::GetSync(ErrorResult& aRv) |
| 791 |
{ |
| 792 |
AssertIsOnMainThread(); |
| 793 |
|
| 794 |
if (!mSyncManager) { |
| 795 |
nsCOMPtr<nsIGlobalObject> globalObject = do_QueryInterface(GetOwner()); |
| 796 |
|
| 797 |
if (!globalObject) { |
| 798 |
aRv.Throw(NS_ERROR_FAILURE); |
| 799 |
return nullptr; |
| 800 |
} |
| 801 |
|
| 802 |
nsCOMPtr<nsIDocument> document = GetOwner()->GetExtantDoc(); |
| 803 |
if (!document) { |
| 804 |
aRv.Throw(NS_ERROR_FAILURE); |
| 805 |
return nullptr; |
| 806 |
} |
| 807 |
|
| 808 |
nsCOMPtr<nsIPrincipal> principal = document->NodePrincipal(); |
| 809 |
if (!principal) { |
| 810 |
aRv.Throw(NS_ERROR_FAILURE); |
| 811 |
return nullptr; |
| 812 |
} |
| 813 |
|
| 814 |
mSyncManager = SyncManager::CreateOnMainThread(globalObject, principal, |
| 815 |
aRv); |
| 816 |
} |
| 817 |
|
| 818 |
return mSyncManager; |
| 819 |
} |
| 820 |
|
| 785 |
//////////////////////////////////////////////////// |
821 |
//////////////////////////////////////////////////// |
| 786 |
// Worker Thread implementation |
822 |
// Worker Thread implementation |
| 787 |
class WorkerListener final : public ServiceWorkerRegistrationListener |
823 |
class WorkerListener final : public ServiceWorkerRegistrationListener |
| 788 |
{ |
824 |
{ |
| 789 |
// Accessed on the main thread. |
825 |
// Accessed on the main thread. |
| 790 |
WorkerPrivate* mWorkerPrivate; |
826 |
WorkerPrivate* mWorkerPrivate; |
| 791 |
nsString mScope; |
827 |
nsString mScope; |
| 792 |
bool mListeningForEvents; |
828 |
bool mListeningForEvents; |
|
Lines 901-923
NS_INTERFACE_MAP_END_INHERITING(ServiceW
|
Link Here
|
|---|
|
| 901 |
// Expanded macros since we need special behaviour to release the proxy. |
937 |
// Expanded macros since we need special behaviour to release the proxy. |
| 902 |
NS_IMPL_CYCLE_COLLECTION_CLASS(ServiceWorkerRegistrationWorkerThread) |
938 |
NS_IMPL_CYCLE_COLLECTION_CLASS(ServiceWorkerRegistrationWorkerThread) |
| 903 |
|
939 |
|
| 904 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServiceWorkerRegistrationWorkerThread, |
940 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServiceWorkerRegistrationWorkerThread, |
| 905 |
ServiceWorkerRegistrationBase) |
941 |
ServiceWorkerRegistrationBase) |
| 906 |
#ifndef MOZ_SIMPLEPUSH |
942 |
#ifndef MOZ_SIMPLEPUSH |
| 907 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPushManager) |
943 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPushManager) |
| 908 |
#endif |
944 |
#endif |
|
|
945 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSyncManager) |
| 909 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
946 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
| 910 |
|
947 |
|
| 911 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServiceWorkerRegistrationWorkerThread, |
948 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServiceWorkerRegistrationWorkerThread, |
| 912 |
ServiceWorkerRegistrationBase) |
949 |
ServiceWorkerRegistrationBase) |
| 913 |
#ifndef MOZ_SIMPLEPUSH |
950 |
#ifndef MOZ_SIMPLEPUSH |
| 914 |
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPushManager) |
951 |
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPushManager) |
| 915 |
#endif |
952 |
#endif |
|
|
953 |
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSyncManager) |
| 916 |
tmp->ReleaseListener(RegistrationIsGoingAway); |
954 |
tmp->ReleaseListener(RegistrationIsGoingAway); |
| 917 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
955 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
| 918 |
|
956 |
|
| 919 |
ServiceWorkerRegistrationWorkerThread::ServiceWorkerRegistrationWorkerThread(WorkerPrivate* aWorkerPrivate, |
957 |
ServiceWorkerRegistrationWorkerThread::ServiceWorkerRegistrationWorkerThread(WorkerPrivate* aWorkerPrivate, |
| 920 |
const nsAString& aScope) |
958 |
const nsAString& aScope) |
| 921 |
: ServiceWorkerRegistrationBase(nullptr, aScope) |
959 |
: ServiceWorkerRegistrationBase(nullptr, aScope) |
| 922 |
, mWorkerPrivate(aWorkerPrivate) |
960 |
, mWorkerPrivate(aWorkerPrivate) |
| 923 |
{ |
961 |
{ |
|
Lines 1215-1224
ServiceWorkerRegistrationWorkerThread::G
|
Link Here
|
|---|
|
| 1215 |
} |
1253 |
} |
| 1216 |
|
1254 |
|
| 1217 |
RefPtr<PushManager> ret = mPushManager; |
1255 |
RefPtr<PushManager> ret = mPushManager; |
| 1218 |
return ret.forget(); |
1256 |
return ret.forget(); |
| 1219 |
|
1257 |
|
| 1220 |
#endif /* ! MOZ_SIMPLEPUSH */ |
1258 |
#endif /* ! MOZ_SIMPLEPUSH */ |
| 1221 |
} |
1259 |
} |
| 1222 |
|
1260 |
|
|
|
1261 |
SyncManager* |
| 1262 |
ServiceWorkerRegistrationWorkerThread::GetSync(ErrorResult& aRv) |
| 1263 |
{ |
| 1264 |
if (!mSyncManager) { |
| 1265 |
mSyncManager = SyncManager::CreateOnWorker(mWorkerPrivate->GlobalScope(), |
| 1266 |
mWorkerPrivate); |
| 1267 |
} |
| 1268 |
|
| 1269 |
return mSyncManager; |
| 1270 |
} |
| 1271 |
|
| 1223 |
} // dom namespace |
1272 |
} // dom namespace |
| 1224 |
} // mozilla namespace |
1273 |
} // mozilla namespace |