|
|
|
|
| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 |
/* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
2 |
/* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
| 3 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
3 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
6 |
|
| 7 |
#include "ServiceWorkerManagerParent.h" |
7 |
#include "ServiceWorkerManagerParent.h" |
| 8 |
#include "ServiceWorkerManagerService.h" |
8 |
#include "ServiceWorkerManagerService.h" |
|
|
9 |
#include "SyncService.h" |
| 9 |
#include "mozilla/AppProcessChecker.h" |
10 |
#include "mozilla/AppProcessChecker.h" |
| 10 |
#include "mozilla/dom/ContentParent.h" |
11 |
#include "mozilla/dom/ContentParent.h" |
| 11 |
#include "mozilla/dom/ServiceWorkerRegistrar.h" |
12 |
#include "mozilla/dom/ServiceWorkerRegistrar.h" |
| 12 |
#include "mozilla/ipc/BackgroundParent.h" |
13 |
#include "mozilla/ipc/BackgroundParent.h" |
| 13 |
#include "mozilla/ipc/BackgroundUtils.h" |
14 |
#include "mozilla/ipc/BackgroundUtils.h" |
| 14 |
#include "mozilla/unused.h" |
15 |
#include "mozilla/unused.h" |
| 15 |
#include "nsThreadUtils.h" |
16 |
#include "nsThreadUtils.h" |
| 16 |
|
17 |
|
|
|
| 143 |
PrincipalInfo mPrincipalInfo; |
144 |
PrincipalInfo mPrincipalInfo; |
| 144 |
RefPtr<nsRunnable> mCallback; |
145 |
RefPtr<nsRunnable> mCallback; |
| 145 |
nsCOMPtr<nsIThread> mBackgroundThread; |
146 |
nsCOMPtr<nsIThread> mBackgroundThread; |
| 146 |
}; |
147 |
}; |
| 147 |
|
148 |
|
| 148 |
} // namespace |
149 |
} // namespace |
| 149 |
|
150 |
|
| 150 |
ServiceWorkerManagerParent::ServiceWorkerManagerParent() |
151 |
ServiceWorkerManagerParent::ServiceWorkerManagerParent() |
| 151 |
: mService(ServiceWorkerManagerService::GetOrCreate()) |
152 |
: mServiceWorkerService(ServiceWorkerManagerService::GetOrCreate()) |
|
|
153 |
, mSyncService(SyncService::GetOrCreate()) |
| 152 |
, mID(++sServiceWorkerManagerParentID) |
154 |
, mID(++sServiceWorkerManagerParentID) |
| 153 |
, mActorDestroyed(false) |
155 |
, mActorDestroyed(false) |
| 154 |
{ |
156 |
{ |
| 155 |
AssertIsOnBackgroundThread(); |
157 |
AssertIsOnBackgroundThread(); |
| 156 |
mService->RegisterActor(this); |
158 |
mServiceWorkerService->RegisterActor(this); |
|
|
159 |
mSyncService->RegisterActor(this); |
| 157 |
} |
160 |
} |
| 158 |
|
161 |
|
| 159 |
ServiceWorkerManagerParent::~ServiceWorkerManagerParent() |
162 |
ServiceWorkerManagerParent::~ServiceWorkerManagerParent() |
| 160 |
{ |
163 |
{ |
| 161 |
AssertIsOnBackgroundThread(); |
164 |
AssertIsOnBackgroundThread(); |
| 162 |
} |
165 |
} |
| 163 |
|
166 |
|
| 164 |
already_AddRefed<ContentParent> |
167 |
already_AddRefed<ContentParent> |
|
Lines 243-331
ServiceWorkerManagerParent::RecvUnregist
|
Link Here
|
|---|
|
| 243 |
} |
246 |
} |
| 244 |
|
247 |
|
| 245 |
bool |
248 |
bool |
| 246 |
ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, |
249 |
ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, |
| 247 |
const nsString& aScope) |
250 |
const nsString& aScope) |
| 248 |
{ |
251 |
{ |
| 249 |
AssertIsOnBackgroundThread(); |
252 |
AssertIsOnBackgroundThread(); |
| 250 |
|
253 |
|
| 251 |
if (NS_WARN_IF(!mService)) { |
254 |
if (NS_WARN_IF(!mServiceWorkerService)) { |
| 252 |
return false; |
255 |
return false; |
| 253 |
} |
256 |
} |
| 254 |
|
257 |
|
| 255 |
mService->PropagateSoftUpdate(mID, aOriginAttributes, aScope); |
258 |
mServiceWorkerService->PropagateSoftUpdate(mID, aOriginAttributes, aScope); |
| 256 |
return true; |
259 |
return true; |
| 257 |
} |
260 |
} |
| 258 |
|
261 |
|
| 259 |
bool |
262 |
bool |
| 260 |
ServiceWorkerManagerParent::RecvPropagateUnregister(const PrincipalInfo& aPrincipalInfo, |
263 |
ServiceWorkerManagerParent::RecvPropagateUnregister(const PrincipalInfo& aPrincipalInfo, |
| 261 |
const nsString& aScope) |
264 |
const nsString& aScope) |
| 262 |
{ |
265 |
{ |
| 263 |
AssertIsOnBackgroundThread(); |
266 |
AssertIsOnBackgroundThread(); |
| 264 |
|
267 |
|
| 265 |
if (NS_WARN_IF(!mService)) { |
268 |
if (NS_WARN_IF(!mServiceWorkerService)) { |
| 266 |
return false; |
269 |
return false; |
| 267 |
} |
270 |
} |
| 268 |
|
271 |
|
| 269 |
mService->PropagateUnregister(mID, aPrincipalInfo, aScope); |
272 |
mServiceWorkerService->PropagateUnregister(mID, aPrincipalInfo, aScope); |
| 270 |
return true; |
273 |
return true; |
| 271 |
} |
274 |
} |
| 272 |
|
275 |
|
| 273 |
bool |
276 |
bool |
| 274 |
ServiceWorkerManagerParent::RecvPropagateRemove(const nsCString& aHost) |
277 |
ServiceWorkerManagerParent::RecvPropagateRemove(const nsCString& aHost) |
| 275 |
{ |
278 |
{ |
| 276 |
AssertIsOnBackgroundThread(); |
279 |
AssertIsOnBackgroundThread(); |
| 277 |
|
280 |
|
| 278 |
if (NS_WARN_IF(!mService)) { |
281 |
if (NS_WARN_IF(!mServiceWorkerService)) { |
| 279 |
return false; |
282 |
return false; |
| 280 |
} |
283 |
} |
| 281 |
|
284 |
|
| 282 |
mService->PropagateRemove(mID, aHost); |
285 |
mServiceWorkerService->PropagateRemove(mID, aHost); |
| 283 |
return true; |
286 |
return true; |
| 284 |
} |
287 |
} |
| 285 |
|
288 |
|
| 286 |
bool |
289 |
bool |
| 287 |
ServiceWorkerManagerParent::RecvPropagateRemoveAll() |
290 |
ServiceWorkerManagerParent::RecvPropagateRemoveAll() |
| 288 |
{ |
291 |
{ |
| 289 |
AssertIsOnBackgroundThread(); |
292 |
AssertIsOnBackgroundThread(); |
| 290 |
|
293 |
|
| 291 |
if (NS_WARN_IF(!mService)) { |
294 |
if (NS_WARN_IF(!mServiceWorkerService)) { |
| 292 |
return false; |
295 |
return false; |
| 293 |
} |
296 |
} |
| 294 |
|
297 |
|
| 295 |
mService->PropagateRemoveAll(mID); |
298 |
mServiceWorkerService->PropagateRemoveAll(mID); |
| 296 |
return true; |
299 |
return true; |
| 297 |
} |
300 |
} |
| 298 |
|
301 |
|
| 299 |
bool |
302 |
bool |
| 300 |
ServiceWorkerManagerParent::RecvShutdown() |
303 |
ServiceWorkerManagerParent::RecvShutdown() |
| 301 |
{ |
304 |
{ |
| 302 |
AssertIsOnBackgroundThread(); |
305 |
AssertIsOnBackgroundThread(); |
| 303 |
|
306 |
|
| 304 |
if (NS_WARN_IF(!mService)) { |
307 |
if (NS_WARN_IF(!mServiceWorkerService)) { |
| 305 |
return false; |
308 |
return false; |
| 306 |
} |
309 |
} |
| 307 |
|
310 |
|
| 308 |
mService->UnregisterActor(this); |
311 |
mServiceWorkerService->UnregisterActor(this); |
| 309 |
mService = nullptr; |
312 |
mServiceWorkerService = nullptr; |
| 310 |
|
313 |
|
| 311 |
Unused << Send__delete__(this); |
314 |
Unused << Send__delete__(this); |
| 312 |
return true; |
315 |
return true; |
| 313 |
} |
316 |
} |
| 314 |
|
317 |
|
| 315 |
void |
318 |
void |
| 316 |
ServiceWorkerManagerParent::ActorDestroy(ActorDestroyReason aWhy) |
319 |
ServiceWorkerManagerParent::ActorDestroy(ActorDestroyReason aWhy) |
| 317 |
{ |
320 |
{ |
| 318 |
AssertIsOnBackgroundThread(); |
321 |
AssertIsOnBackgroundThread(); |
| 319 |
|
322 |
|
| 320 |
mActorDestroyed = true; |
323 |
mActorDestroyed = true; |
| 321 |
|
324 |
|
| 322 |
if (mService) { |
325 |
if (mServiceWorkerService) { |
| 323 |
// This object is about to be released and with it, also mService will be |
326 |
// This object is about to be released and with it, also mServiceWorkerService will be |
| 324 |
// released too. |
327 |
// released too. |
| 325 |
mService->UnregisterActor(this); |
328 |
mServiceWorkerService->UnregisterActor(this); |
| 326 |
} |
329 |
} |
| 327 |
} |
330 |
} |
| 328 |
|
331 |
|
| 329 |
} // namespace workers |
332 |
} // namespace workers |
| 330 |
} // namespace dom |
333 |
} // namespace dom |
| 331 |
} // namespace mozilla |
334 |
} // namespace mozilla |