https://bugs.webkit.org/show_bug.cgi?id=180207
Reviewed by Geoffrey Garen.
Rename RegistrationOptions to ServiceWorkerRegistrationOptions as the name
RegistrationOptions is too generic and likely to conflict. Also modernize
ServiceWorkerRegistrationOptions' IPC decoder.
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerJobData.h:
(WebCore::ServiceWorkerJobData::decode):
* workers/service/ServiceWorkerRegistrationOptions.cpp:
(WebCore::ServiceWorkerRegistrationOptions::isolatedCopy const):
* workers/service/ServiceWorkerRegistrationOptions.h:
(WebCore::ServiceWorkerRegistrationOptions::encode const):
(WebCore::ServiceWorkerRegistrationOptions::decode):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225335
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-11-30 Chris Dumez <cdumez@apple.com>
+
+ Rename RegistrationOptions to ServiceWorkerRegistrationOptions
+ https://bugs.webkit.org/show_bug.cgi?id=180207
+
+ Reviewed by Geoffrey Garen.
+
+ Rename RegistrationOptions to ServiceWorkerRegistrationOptions as the name
+ RegistrationOptions is too generic and likely to conflict. Also modernize
+ ServiceWorkerRegistrationOptions' IPC decoder.
+
+ * workers/service/ServiceWorkerContainer.h:
+ * workers/service/ServiceWorkerJobData.h:
+ (WebCore::ServiceWorkerJobData::decode):
+ * workers/service/ServiceWorkerRegistrationOptions.cpp:
+ (WebCore::ServiceWorkerRegistrationOptions::isolatedCopy const):
+ * workers/service/ServiceWorkerRegistrationOptions.h:
+ (WebCore::ServiceWorkerRegistrationOptions::encode const):
+ (WebCore::ServiceWorkerRegistrationOptions::decode):
+
2017-11-30 Darin Adler <darin@apple.com>
[Mac] remove unneeded RetainPtr use introduced in r225142
ServiceWorkerContainer(ScriptExecutionContext&, NavigatorBase&);
~ServiceWorkerContainer();
- typedef WebCore::RegistrationOptions RegistrationOptions;
-
ServiceWorker* controller() const;
using ReadyPromise = DOMPromiseProxy<IDLInterface<ServiceWorkerRegistration>>;
ReadyPromise& ready() { return m_readyPromise; }
+ using RegistrationOptions = ServiceWorkerRegistrationOptions;
void addRegistration(const String& scriptURL, const RegistrationOptions&, Ref<DeferredPromise>&&);
void removeRegistration(const URL& scopeURL, Ref<DeferredPromise>&&);
void updateRegistration(const URL& scopeURL, const URL& scriptURL, WorkerType, Ref<DeferredPromise>&&);
URL scopeURL;
ServiceWorkerJobType type;
- RegistrationOptions registrationOptions;
+ ServiceWorkerRegistrationOptions registrationOptions;
Identifier identifier() const { return m_identifier; }
ServiceWorkerRegistrationKey registrationKey() const;
if (!identifier)
return std::nullopt;
- std::optional<ServiceWorkerJobData> jobData = { ServiceWorkerJobData { WTFMove(*identifier) } };
+ ServiceWorkerJobData jobData { WTFMove(*identifier) };
- if (!decoder.decode(jobData->scriptURL))
+ if (!decoder.decode(jobData.scriptURL))
return std::nullopt;
- if (!decoder.decode(jobData->clientCreationURL))
+ if (!decoder.decode(jobData.clientCreationURL))
return std::nullopt;
std::optional<SecurityOriginData> topOrigin;
decoder >> topOrigin;
if (!topOrigin)
return std::nullopt;
- jobData->topOrigin = WTFMove(*topOrigin);
+ jobData.topOrigin = WTFMove(*topOrigin);
- if (!decoder.decode(jobData->scopeURL))
+ if (!decoder.decode(jobData.scopeURL))
return std::nullopt;
- if (!decoder.decodeEnum(jobData->type))
+ if (!decoder.decodeEnum(jobData.type))
return std::nullopt;
- switch (jobData->type) {
- case ServiceWorkerJobType::Register:
- if (!decoder.decode(jobData->registrationOptions))
+ switch (jobData.type) {
+ case ServiceWorkerJobType::Register: {
+ std::optional<ServiceWorkerRegistrationOptions> registrationOptions;
+ decoder >> registrationOptions;
+ if (!registrationOptions)
return std::nullopt;
+ jobData.registrationOptions = WTFMove(*registrationOptions);
break;
+ }
case ServiceWorkerJobType::Unregister:
case ServiceWorkerJobType::Update:
break;
}
- return jobData;
+ return WTFMove(jobData);
}
} // namespace WebCore
namespace WebCore {
-RegistrationOptions RegistrationOptions::isolatedCopy() const
+ServiceWorkerRegistrationOptions ServiceWorkerRegistrationOptions::isolatedCopy() const
{
- RegistrationOptions result;
- result.scope = scope.isolatedCopy();
- result.type = type;
- result.updateViaCache = updateViaCache;
-
- return result;
+ return ServiceWorkerRegistrationOptions { scope.isolatedCopy(), type, updateViaCache };
}
} // namespace WebCore
enum class ServiceWorkerUpdateViaCache;
enum class WorkerType;
-struct RegistrationOptions {
+struct ServiceWorkerRegistrationOptions {
String scope;
WorkerType type;
ServiceWorkerUpdateViaCache updateViaCache;
- RegistrationOptions isolatedCopy() const;
+ ServiceWorkerRegistrationOptions isolatedCopy() const;
template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static bool decode(Decoder&, RegistrationOptions&);
+ template<class Decoder> static std::optional<ServiceWorkerRegistrationOptions> decode(Decoder&);
};
template<class Encoder>
-void RegistrationOptions::encode(Encoder& encoder) const
+void ServiceWorkerRegistrationOptions::encode(Encoder& encoder) const
{
- encoder << scope;
- encoder.encodeEnum(type);
- encoder.encodeEnum(updateViaCache);
+ encoder << scope << type << updateViaCache;
}
template<class Decoder>
-bool RegistrationOptions::decode(Decoder& decoder, RegistrationOptions& options)
+std::optional<ServiceWorkerRegistrationOptions> ServiceWorkerRegistrationOptions::decode(Decoder& decoder)
{
- if (!decoder.decode(options.scope))
- return false;
- if (!decoder.decodeEnum(options.type))
- return false;
- if (!decoder.decodeEnum(options.updateViaCache))
- return false;
+ std::optional<String> scope;
+ decoder >> scope;
+ if (!scope)
+ return std::nullopt;
- return true;
+ std::optional<WorkerType> type;
+ decoder >> type;
+ if (!type)
+ return std::nullopt;
+
+ std::optional<ServiceWorkerUpdateViaCache> updateViaCache;
+ decoder >> updateViaCache;
+ if (!updateViaCache)
+ return std::nullopt;
+
+ return ServiceWorkerRegistrationOptions { WTFMove(*scope), WTFMove(*type), WTFMove(*updateViaCache) };
}
} // namespace WebCore