Bug 1112469 - Part 1: Implement an XPCOM service responsible to trigger daily updates of service workers; r=nsm

--HG--
rename : dom/base/nsDOMCID.h => dom/workers/ServiceWorkerPeriodicUpdater.cpp
rename : dom/base/nsDOMCID.h => dom/workers/ServiceWorkerPeriodicUpdater.h
This commit is contained in:
Ehsan Akhgari 2015-04-10 19:44:10 -04:00
Родитель 51fe298034
Коммит 41df4b9686
6 изменённых файлов: 110 добавлений и 0 удалений

Просмотреть файл

@ -20,6 +20,9 @@
0x45f27d10, 0x987b, 0x11d2, \ 0x45f27d10, 0x987b, 0x11d2, \
{0xbd, 0x40, 0x00, 0x10, 0x5a, 0xa4, 0x5e, 0x89} } {0xbd, 0x40, 0x00, 0x10, 0x5a, 0xa4, 0x5e, 0x89} }
#define SERVICEWORKERPERIODICUPDATER_CONTRACTID \
"@mozilla.org/service-worker-periodic-updater;1"
//The dom cannot provide the crypto or pkcs11 classes that //The dom cannot provide the crypto or pkcs11 classes that
//were used in older days, so if someone wants to provide //were used in older days, so if someone wants to provide
//the service they must implement an object and give it //the service they must implement an object and give it

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
* 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 "ServiceWorkerPeriodicUpdater.h"
#include "mozilla/ClearOnShutdown.h"
#define OBSERVER_TOPIC_IDLE_DAILY "idle-daily"
namespace mozilla {
namespace dom {
namespace workers {
NS_IMPL_ISUPPORTS(ServiceWorkerPeriodicUpdater, nsIObserver)
StaticRefPtr<ServiceWorkerPeriodicUpdater>
ServiceWorkerPeriodicUpdater::sInstance;
already_AddRefed<ServiceWorkerPeriodicUpdater>
ServiceWorkerPeriodicUpdater::GetSingleton()
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
if (!sInstance) {
sInstance = new ServiceWorkerPeriodicUpdater();
ClearOnShutdown(&sInstance);
}
nsRefPtr<ServiceWorkerPeriodicUpdater> copy(sInstance.get());
return copy.forget();
}
ServiceWorkerPeriodicUpdater::ServiceWorkerPeriodicUpdater()
{
}
ServiceWorkerPeriodicUpdater::~ServiceWorkerPeriodicUpdater()
{
}
NS_IMETHODIMP
ServiceWorkerPeriodicUpdater::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
if (strcmp(aTopic, OBSERVER_TOPIC_IDLE_DAILY) == 0) {
// TODO: Update the service workers NOW!!!!!
}
return NS_OK;
}
} // namespace workers
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
* 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/. */
#ifndef mozilla_ServiceWorkerPeriodicUpdater_h
#define mozilla_ServiceWorkerPeriodicUpdater_h
#include "nsCOMPtr.h"
#include "nsIObserver.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
namespace dom {
namespace workers {
class ServiceWorkerPeriodicUpdater final : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
static already_AddRefed<ServiceWorkerPeriodicUpdater> GetSingleton();
private:
ServiceWorkerPeriodicUpdater();
~ServiceWorkerPeriodicUpdater();
static StaticRefPtr<ServiceWorkerPeriodicUpdater> sInstance;
};
} // namespace workers
} // namespace dom
} // namespace mozilla
#endif

Просмотреть файл

@ -18,6 +18,7 @@ EXPORTS.mozilla.dom += [
EXPORTS.mozilla.dom.workers += [ EXPORTS.mozilla.dom.workers += [
'ServiceWorkerManager.h', 'ServiceWorkerManager.h',
'ServiceWorkerPeriodicUpdater.h',
'WorkerDebuggerManager.h', 'WorkerDebuggerManager.h',
'Workers.h', 'Workers.h',
] ]
@ -68,6 +69,7 @@ UNIFIED_SOURCES += [
'ServiceWorkerContainer.cpp', 'ServiceWorkerContainer.cpp',
'ServiceWorkerEvents.cpp', 'ServiceWorkerEvents.cpp',
'ServiceWorkerManager.cpp', 'ServiceWorkerManager.cpp',
'ServiceWorkerPeriodicUpdater.cpp',
'ServiceWorkerRegistrar.cpp', 'ServiceWorkerRegistrar.cpp',
'ServiceWorkerRegistration.cpp', 'ServiceWorkerRegistration.cpp',
'ServiceWorkerScriptCache.cpp', 'ServiceWorkerScriptCache.cpp',

Просмотреть файл

@ -82,4 +82,8 @@
#define SERVICEWORKERMANAGER_CID \ #define SERVICEWORKERMANAGER_CID \
{ 0xc74bde32, 0xbcc7, 0x4840, { 0x84, 0x30, 0xc7, 0x33, 0x35, 0x1b, 0x21, 0x2a } } { 0xc74bde32, 0xbcc7, 0x4840, { 0x84, 0x30, 0xc7, 0x33, 0x35, 0x1b, 0x21, 0x2a } }
// {91f43ef6-8159-457a-ba68-249c3ff7a06a}
#define SERVICEWORKERPERIODICUPDATER_CID \
{ 0x91f43ef6, 0x8159, 0x457a, { 0xba, 0x68, 0x24, 0x9c, 0x3f, 0xf7, 0xa0, 0x6a } }
#endif /* nsLayoutCID_h__ */ #endif /* nsLayoutCID_h__ */

Просмотреть файл

@ -90,6 +90,7 @@
#include "mozilla/dom/network/UDPSocketChild.h" #include "mozilla/dom/network/UDPSocketChild.h"
#include "mozilla/dom/quota/QuotaManager.h" #include "mozilla/dom/quota/QuotaManager.h"
#include "mozilla/dom/workers/ServiceWorkerManager.h" #include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/workers/ServiceWorkerPeriodicUpdater.h"
#include "mozilla/dom/workers/WorkerDebuggerManager.h" #include "mozilla/dom/workers/WorkerDebuggerManager.h"
#include "mozilla/OSFileConstants.h" #include "mozilla/OSFileConstants.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
@ -263,6 +264,7 @@ using mozilla::dom::alarm::AlarmHalService;
using mozilla::dom::power::PowerManagerService; using mozilla::dom::power::PowerManagerService;
using mozilla::dom::quota::QuotaManager; using mozilla::dom::quota::QuotaManager;
using mozilla::dom::workers::ServiceWorkerManager; using mozilla::dom::workers::ServiceWorkerManager;
using mozilla::dom::workers::ServiceWorkerPeriodicUpdater;
using mozilla::dom::workers::WorkerDebuggerManager; using mozilla::dom::workers::WorkerDebuggerManager;
using mozilla::dom::TCPSocketChild; using mozilla::dom::TCPSocketChild;
using mozilla::dom::TCPSocketParent; using mozilla::dom::TCPSocketParent;
@ -308,6 +310,8 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager,
QuotaManager::FactoryCreate) QuotaManager::FactoryCreate)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerManager, NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerManager,
ServiceWorkerManager::FactoryCreate) ServiceWorkerManager::FactoryCreate)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerPeriodicUpdater,
ServiceWorkerPeriodicUpdater::GetSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR(WorkerDebuggerManager) NS_GENERIC_FACTORY_CONSTRUCTOR(WorkerDebuggerManager)
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
@ -748,6 +752,7 @@ NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID);
NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID); NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID);
NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID); NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID);
NS_DEFINE_NAMED_CID(SERVICEWORKERMANAGER_CID); NS_DEFINE_NAMED_CID(SERVICEWORKERMANAGER_CID);
NS_DEFINE_NAMED_CID(SERVICEWORKERPERIODICUPDATER_CID);
NS_DEFINE_NAMED_CID(WORKERDEBUGGERMANAGER_CID); NS_DEFINE_NAMED_CID(WORKERDEBUGGERMANAGER_CID);
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID); NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID);
@ -1051,6 +1056,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor }, { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },
{ &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor }, { &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor },
{ &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor }, { &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor },
{ &kSERVICEWORKERPERIODICUPDATER_CID, false, nullptr, ServiceWorkerPeriodicUpdaterConstructor },
{ &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor }, { &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor },
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
{ &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor }, { &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor },
@ -1214,6 +1220,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID }, { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID },
{ QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID }, { QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID },
{ SERVICEWORKERMANAGER_CONTRACTID, &kSERVICEWORKERMANAGER_CID }, { SERVICEWORKERMANAGER_CONTRACTID, &kSERVICEWORKERMANAGER_CID },
{ SERVICEWORKERPERIODICUPDATER_CONTRACTID, &kSERVICEWORKERPERIODICUPDATER_CID, Module::MAIN_PROCESS_ONLY },
{ WORKERDEBUGGERMANAGER_CONTRACTID, &kWORKERDEBUGGERMANAGER_CID }, { WORKERDEBUGGERMANAGER_CONTRACTID, &kWORKERDEBUGGERMANAGER_CID },
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
{ SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID }, { SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID },
@ -1321,6 +1328,7 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = {
{ "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID }, { "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID },
#endif #endif
{ "profile-after-change", "PresentationDeviceManager", PRESENTATION_DEVICE_MANAGER_CONTRACTID }, { "profile-after-change", "PresentationDeviceManager", PRESENTATION_DEVICE_MANAGER_CONTRACTID },
{ "idle-daily", "ServiceWorker Periodic Updater", SERVICEWORKERPERIODICUPDATER_CONTRACTID },
{ nullptr } { nullptr }
}; };