Diff
Modified: trunk/Source/WTF/ChangeLog (221398 => 221399)
--- trunk/Source/WTF/ChangeLog 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WTF/ChangeLog 2017-08-30 21:50:27 UTC (rev 221399)
@@ -1,3 +1,17 @@
+2017-08-30 Brady Eidson <beid...@apple.com>
+
+ Add "Identified" base class to replace a whole bunch of custom identifier generators.
+ https://bugs.webkit.org/show_bug.cgi?id=176120
+
+ Reviewed by Alex Christensen.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/Identified.h: Added.
+ (WTF::IdentifiedBase::identifier const):
+ (WTF::IdentifiedBase::IdentifiedBase):
+ (WTF::Identified::Identified):
+ (WTF::ThreadSafeIdentified::ThreadSafeIdentified):
+
2017-08-22 Filip Pizlo <fpi...@apple.com>
Strings need to be in some kind of gigacage
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (221398 => 221399)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-08-30 21:50:27 UTC (rev 221399)
@@ -309,6 +309,7 @@
515F794C1CFC9F4A00CCED93 /* CrossThreadCopier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadCopier.h; sourceTree = "<group>"; };
515F794D1CFC9F4A00CCED93 /* CrossThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadTask.h; sourceTree = "<group>"; };
515F79551CFD3A6900CCED93 /* CrossThreadQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadQueue.h; sourceTree = "<group>"; };
+ 517A53571F5734B700DCDC0A /* Identified.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Identified.h; sourceTree = "<group>"; };
5182C22C1F2BC7E60059BA7C /* InstanceCounted.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InstanceCounted.h; sourceTree = "<group>"; };
51F175241F3D486000C74950 /* PersistentCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersistentCoder.h; sourceTree = "<group>"; };
51F175251F3D486000C74950 /* PersistentCoders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersistentCoders.h; sourceTree = "<group>"; };
@@ -833,6 +834,7 @@
A8A472B9151A825A004123FF /* HashTable.h */,
A8A472BA151A825A004123FF /* HashTraits.h */,
A8A472BB151A825A004123FF /* HexNumber.h */,
+ 517A53571F5734B700DCDC0A /* Identified.h */,
FE8925AF1D00DAEC0046907E /* Indenter.h */,
9C67C542589348E285B49699 /* IndexedContainerIterator.h */,
0F2AC5621E8A01490001EE3F /* IndexKeyType.h */,
Added: trunk/Source/WTF/wtf/Identified.h (0 => 221399)
--- trunk/Source/WTF/wtf/Identified.h (rev 0)
+++ trunk/Source/WTF/wtf/Identified.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WTF {
+
+template <typename IdentifierType, typename StaticType, typename ClassType>
+class IdentifiedBase {
+public:
+ IdentifierType identifier() const
+ {
+ return m_identifier;
+ }
+
+protected:
+ IdentifiedBase()
+ : m_identifier(++s_currentIdentifier)
+ {
+ }
+
+ IdentifiedBase(const IdentifiedBase& other)
+ : m_identifier(other.m_identifier)
+ {
+ }
+
+ explicit IdentifiedBase(IdentifierType identifier)
+ : m_identifier(identifier)
+ {
+ }
+
+private:
+ IdentifierType m_identifier;
+ static StaticType s_currentIdentifier;
+};
+
+template<typename IdentifierType, typename StaticType, typename ClassType> StaticType IdentifiedBase<IdentifierType, StaticType, ClassType>::s_currentIdentifier;
+
+template <typename T>
+class Identified : public IdentifiedBase<uint64_t, uint64_t, T> {
+protected:
+ Identified() = default;
+ Identified(const Identified&) = default;
+
+ explicit Identified(uint64_t identifier)
+ : IdentifiedBase<uint64_t, uint64_t, T>(identifier)
+ {
+ }
+};
+
+template <typename T>
+class ThreadSafeIdentified : public IdentifiedBase<uint64_t, std::atomic<uint64_t>, T> {
+protected:
+ ThreadSafeIdentified() = default;
+ ThreadSafeIdentified(const ThreadSafeIdentified&) = default;
+
+ explicit ThreadSafeIdentified(uint64_t identifier)
+ : IdentifiedBase<uint64_t, std::atomic<uint64_t>, T>(identifier)
+ {
+ }
+};
+
+} // namespace WTF
+
+using WTF::Identified;
+using WTF::ThreadSafeIdentified;
Modified: trunk/Source/WebCore/ChangeLog (221398 => 221399)
--- trunk/Source/WebCore/ChangeLog 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/ChangeLog 2017-08-30 21:50:27 UTC (rev 221399)
@@ -1,3 +1,50 @@
+2017-08-30 Brady Eidson <beid...@apple.com>
+
+ Add "Identified" base class to replace a whole bunch of custom identifier generators.
+ https://bugs.webkit.org/show_bug.cgi?id=176120
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No behavior change).
+
+ Instead of repeating the common pattern of a class with an integer identifier keeping its
+ own static counter of the next identifier and generating it for each instance, this
+ uses a common template in WTF that does that automatically.
+
+ * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction):
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction):
+ (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted.
+ * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted.
+
+ * workers/service/ServiceWorkerJobData.cpp:
+ (WebCore::ServiceWorkerJobData::ServiceWorkerJobData):
+ (WebCore::ServiceWorkerJobData::isolatedCopy const):
+ * workers/service/ServiceWorkerJobData.h:
+ (WebCore::ServiceWorkerJobData::encode const):
+ (WebCore::ServiceWorkerJobData::decode):
+ (WebCore::ServiceWorkerJobData::identifier const): Deleted.
+
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::Connection::Connection):
+ * workers/service/server/SWServer.h:
+ (WebCore::SWServer::Connection::identifier const): Deleted.
+
+ * workers/service/server/SWServerRegistration.cpp:
+ (WebCore::SWServerRegistration::SWServerRegistration):
+ (WebCore::SWServerRegistration::data const):
+ * workers/service/server/SWServerRegistration.h:
+ (WebCore::SWServerRegistration::identifier const): Deleted.
+
2017-08-30 Youenn Fablet <you...@apple.com>
Remove FetchRequest::InternalRequest
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp (221398 => 221399)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -38,12 +38,6 @@
namespace WebCore {
namespace IDBServer {
-static uint64_t nextDatabaseConnectionIdentifier()
-{
- static uint64_t nextIdentifier = 0;
- return ++nextIdentifier;
-}
-
Ref<UniqueIDBDatabaseConnection> UniqueIDBDatabaseConnection::create(UniqueIDBDatabase& database, ServerOpenDBRequest& request)
{
return adoptRef(*new UniqueIDBDatabaseConnection(database, request));
@@ -50,8 +44,7 @@
}
UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection(UniqueIDBDatabase& database, ServerOpenDBRequest& request)
- : m_identifier(nextDatabaseConnectionIdentifier())
- , m_database(database)
+ : m_database(database)
, m_connectionToClient(request.connection())
, m_openRequestIdentifier(request.requestData().requestIdentifier())
{
@@ -85,7 +78,7 @@
void UniqueIDBDatabaseConnection::connectionPendingCloseFromClient()
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::connectionPendingCloseFromClient - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::connectionPendingCloseFromClient - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
m_closePending = true;
}
@@ -92,7 +85,7 @@
void UniqueIDBDatabaseConnection::connectionClosedFromClient()
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::connectionClosedFromClient - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::connectionClosedFromClient - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
m_database.connectionClosedFromClient(*this);
}
@@ -99,7 +92,7 @@
void UniqueIDBDatabaseConnection::confirmDidCloseFromServer()
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::confirmDidCloseFromServer - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::confirmDidCloseFromServer - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
m_database.confirmDidCloseFromServer(*this);
}
@@ -106,7 +99,7 @@
void UniqueIDBDatabaseConnection::didFireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier)
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::didFireVersionChangeEvent - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::didFireVersionChangeEvent - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
m_database.didFireVersionChangeEvent(*this, requestIdentifier);
}
@@ -113,7 +106,7 @@
void UniqueIDBDatabaseConnection::didFinishHandlingVersionChange(const IDBResourceIdentifier& transactionIdentifier)
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::didFinishHandlingVersionChange - %s - %" PRIu64, transactionIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::didFinishHandlingVersionChange - %s - %" PRIu64, transactionIdentifier.loggingString().utf8().data(), identifier());
m_database.didFinishHandlingVersionChange(*this, transactionIdentifier);
}
@@ -126,7 +119,7 @@
UniqueIDBDatabaseTransaction& UniqueIDBDatabaseConnection::createVersionChangeTransaction(uint64_t newVersion)
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::createVersionChangeTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::createVersionChangeTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
ASSERT(!m_closePending);
IDBTransactionInfo info = IDBTransactionInfo::versionChange(m_connectionToClient, m_database.info(), newVersion);
@@ -139,7 +132,7 @@
void UniqueIDBDatabaseConnection::establishTransaction(const IDBTransactionInfo& info)
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::establishTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::establishTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
ASSERT(info.mode() != IDBTransactionMode::Versionchange);
@@ -154,7 +147,7 @@
void UniqueIDBDatabaseConnection::didAbortTransaction(UniqueIDBDatabaseTransaction& transaction, const IDBError& error)
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::didAbortTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::didAbortTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
auto transactionIdentifier = transaction.info().identifier();
auto takenTransaction = m_transactionMap.take(transactionIdentifier);
@@ -166,7 +159,7 @@
void UniqueIDBDatabaseConnection::didCommitTransaction(UniqueIDBDatabaseTransaction& transaction, const IDBError& error)
{
- LOG(IndexedDB, "UniqueIDBDatabaseConnection::didCommitTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::didCommitTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), identifier());
auto transactionIdentifier = transaction.info().identifier();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h (221398 => 221399)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -29,6 +29,7 @@
#include "UniqueIDBDatabaseTransaction.h"
#include <wtf/HashMap.h>
+#include <wtf/Identified.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
@@ -44,13 +45,12 @@
class UniqueIDBDatabase;
class UniqueIDBDatabaseTransaction;
-class UniqueIDBDatabaseConnection : public RefCounted<UniqueIDBDatabaseConnection> {
+class UniqueIDBDatabaseConnection : public RefCounted<UniqueIDBDatabaseConnection>, public Identified<UniqueIDBDatabaseConnection> {
public:
static Ref<UniqueIDBDatabaseConnection> create(UniqueIDBDatabase&, ServerOpenDBRequest&);
~UniqueIDBDatabaseConnection();
- uint64_t identifier() const { return m_identifier; }
const IDBResourceIdentifier& openRequestIdentifier() { return m_openRequestIdentifier; }
UniqueIDBDatabase& database() { return m_database; }
IDBConnectionToClient& connectionToClient() { return m_connectionToClient; }
@@ -86,7 +86,6 @@
private:
UniqueIDBDatabaseConnection(UniqueIDBDatabase&, ServerOpenDBRequest&);
- uint64_t m_identifier { 0 };
UniqueIDBDatabase& m_database;
IDBConnectionToClient& m_connectionToClient;
IDBResourceIdentifier m_openRequestIdentifier;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobData.cpp (221398 => 221399)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJobData.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobData.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -30,24 +30,15 @@
namespace WebCore {
-static std::atomic<uint64_t> currentJobIdentifier;
-
-ServiceWorkerJobData::ServiceWorkerJobData(uint64_t connectionIdentifier)
- : m_jobIdentifier(++currentJobIdentifier)
+ServiceWorkerJobData::ServiceWorkerJobData(uint64_t jobIdentifier, uint64_t connectionIdentifier)
+ : ThreadSafeIdentified(jobIdentifier)
, m_connectionIdentifier(connectionIdentifier)
{
}
-ServiceWorkerJobData::ServiceWorkerJobData(const ServiceWorkerJobData& other)
+ServiceWorkerJobData::ServiceWorkerJobData(uint64_t connectionIdentifier)
+ : m_connectionIdentifier(connectionIdentifier)
{
- m_jobIdentifier = other.m_jobIdentifier;
- m_connectionIdentifier = other.m_connectionIdentifier;
- scriptURL = other.scriptURL;
- clientCreationURL = other.clientCreationURL;
- topOrigin = other.topOrigin;
- scopeURL = other.scopeURL;
- type = other.type;
- registrationOptions = other.registrationOptions;
}
ServiceWorkerRegistrationKey ServiceWorkerJobData::registrationKey() const
@@ -57,9 +48,7 @@
ServiceWorkerJobData ServiceWorkerJobData::isolatedCopy() const
{
- ServiceWorkerJobData result;
- result.m_jobIdentifier = m_jobIdentifier;
- result.m_connectionIdentifier = m_connectionIdentifier;
+ ServiceWorkerJobData result { identifier(), m_connectionIdentifier };
result.type = type;
result.scriptURL = scriptURL.isolatedCopy();
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobData.h (221398 => 221399)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJobData.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobData.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -32,16 +32,16 @@
#include "ServiceWorkerRegistrationKey.h"
#include "ServiceWorkerRegistrationOptions.h"
#include "URL.h"
+#include <wtf/Identified.h>
namespace WebCore {
-struct ServiceWorkerJobData {
+struct ServiceWorkerJobData : public ThreadSafeIdentified<ServiceWorkerJobData> {
public:
explicit ServiceWorkerJobData(uint64_t connectionIdentifier);
- ServiceWorkerJobData(const ServiceWorkerJobData&);
+ ServiceWorkerJobData(const ServiceWorkerJobData&) = default;
ServiceWorkerJobData() = default;
- uint64_t identifier() const { return m_jobIdentifier; }
uint64_t connectionIdentifier() const { return m_connectionIdentifier; }
URL scriptURL;
@@ -56,10 +56,11 @@
ServiceWorkerJobData isolatedCopy() const;
template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static bool decode(Decoder&, ServiceWorkerJobData&);
+ template<class Decoder> static std::optional<ServiceWorkerJobData> decode(Decoder&);
private:
- uint64_t m_jobIdentifier { 0 };
+ WEBCORE_EXPORT ServiceWorkerJobData(uint64_t jobIdentifier, uint64_t connectionIdentifier);
+
uint64_t m_connectionIdentifier { 0 };
};
@@ -66,7 +67,7 @@
template<class Encoder>
void ServiceWorkerJobData::encode(Encoder& encoder) const
{
- encoder << m_jobIdentifier << m_connectionIdentifier << scriptURL << clientCreationURL << topOrigin << scopeURL;
+ encoder << identifier() << m_connectionIdentifier << scriptURL << clientCreationURL << topOrigin << scopeURL;
encoder.encodeEnum(type);
switch (type) {
case ServiceWorkerJobType::Register:
@@ -76,31 +77,37 @@
}
template<class Decoder>
-bool ServiceWorkerJobData::decode(Decoder& decoder, ServiceWorkerJobData& jobData)
+std::optional<ServiceWorkerJobData> ServiceWorkerJobData::decode(Decoder& decoder)
{
- if (!decoder.decode(jobData.m_jobIdentifier))
- return false;
- if (!decoder.decode(jobData.m_connectionIdentifier))
- return false;
- if (!decoder.decode(jobData.scriptURL))
- return false;
- if (!decoder.decode(jobData.clientCreationURL))
- return false;
- if (!decoder.decode(jobData.topOrigin))
- return false;
- if (!decoder.decode(jobData.scopeURL))
- return false;
- if (!decoder.decodeEnum(jobData.type))
- return false;
+ uint64_t jobIdentifier;
+ if (!decoder.decode(jobIdentifier))
+ return std::nullopt;
- switch (jobData.type) {
+ uint64_t connectionIdentifier;
+ if (!decoder.decode(connectionIdentifier))
+ return std::nullopt;
+
+ std::optional<ServiceWorkerJobData> jobData = { { jobIdentifier, connectionIdentifier } };
+
+ if (!decoder.decode(jobData->scriptURL))
+ return std::nullopt;
+ if (!decoder.decode(jobData->clientCreationURL))
+ return std::nullopt;
+ if (!decoder.decode(jobData->topOrigin))
+ return std::nullopt;
+ if (!decoder.decode(jobData->scopeURL))
+ return std::nullopt;
+ if (!decoder.decodeEnum(jobData->type))
+ return std::nullopt;
+
+ switch (jobData->type) {
case ServiceWorkerJobType::Register:
- if (!decoder.decode(jobData.registrationOptions))
- return false;
+ if (!decoder.decode(jobData->registrationOptions))
+ return std::nullopt;
break;
}
- return true;
+ return jobData;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (221398 => 221399)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -38,8 +38,8 @@
namespace WebCore {
SWServer::Connection::Connection(SWServer& server, uint64_t identifier)
- : m_server(server)
- , m_identifier(identifier)
+ : Identified(identifier)
+ , m_server(server)
{
m_server.registerConnection(*this);
}
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (221398 => 221399)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -34,6 +34,7 @@
#include <wtf/CrossThreadTask.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/Identified.h>
#include <wtf/RunLoop.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Threading.h>
@@ -46,13 +47,11 @@
class SWServer {
public:
- class Connection {
+ class Connection : public Identified<Connection> {
friend class SWServer;
public:
WEBCORE_EXPORT virtual ~Connection();
- uint64_t identifier() const { return m_identifier; };
-
protected:
WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier);
SWServer& server() { return m_server; }
@@ -64,7 +63,6 @@
virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
SWServer& m_server;
- uint64_t m_identifier;
};
WEBCORE_EXPORT SWServer();
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (221398 => 221399)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -37,12 +37,9 @@
namespace WebCore {
-static std::atomic<uint64_t> currentIdentifier;
-
SWServerRegistration::SWServerRegistration(SWServer& server, const ServiceWorkerRegistrationKey& key)
: m_jobTimer(*this, &SWServerRegistration::startNextJob)
, m_server(server)
- , m_identifier(++currentIdentifier)
, m_registrationKey(key)
{
}
@@ -203,7 +200,7 @@
ServiceWorkerRegistrationData SWServerRegistration::data() const
{
- return { m_registrationKey, m_identifier };
+ return { m_registrationKey, identifier() };
}
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (221398 => 221399)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -31,6 +31,7 @@
#include "ServiceWorkerRegistrationData.h"
#include "Timer.h"
#include <wtf/Deque.h>
+#include <wtf/Identified.h>
namespace WebCore {
@@ -38,7 +39,7 @@
class SWServerWorker;
struct ExceptionData;
-class SWServerRegistration {
+class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
public:
explicit SWServerRegistration(SWServer&, const ServiceWorkerRegistrationKey&);
SWServerRegistration(const SWServerRegistration&) = delete;
@@ -46,7 +47,6 @@
void enqueueJob(const ServiceWorkerJobData&);
- uint64_t identifier() const { return m_identifier; }
ServiceWorkerRegistrationData data() const;
private:
@@ -76,7 +76,6 @@
Timer m_jobTimer;
SWServer& m_server;
- uint64_t m_identifier;
ServiceWorkerRegistrationKey m_registrationKey;
};
Modified: trunk/Source/WebKit/ChangeLog (221398 => 221399)
--- trunk/Source/WebKit/ChangeLog 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/ChangeLog 2017-08-30 21:50:27 UTC (rev 221399)
@@ -1,5 +1,74 @@
2017-08-30 Brady Eidson <beid...@apple.com>
+ Add "Identified" base class to replace a whole bunch of custom identifier generators.
+ https://bugs.webkit.org/show_bug.cgi?id=176120
+
+ Reviewed by Alex Christensen.
+
+ * UIProcess/API/APIUserScript.cpp:
+ (API::UserScript::UserScript):
+ (API::generateIdentifier): Deleted.
+ * UIProcess/API/APIUserScript.h:
+
+ * UIProcess/API/APIUserStyleSheet.cpp:
+ (API::UserStyleSheet::UserStyleSheet):
+ (API::generateIdentifier): Deleted.
+ * UIProcess/API/APIUserStyleSheet.h:
+
+ * UIProcess/UserContent/WebScriptMessageHandler.cpp:
+ (WebKit::WebScriptMessageHandler::WebScriptMessageHandler):
+ (WebKit::generateIdentifier): Deleted.
+ * UIProcess/UserContent/WebScriptMessageHandler.h:
+ (WebKit::WebScriptMessageHandler::identifier const): Deleted.
+
+ * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
+ (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy):
+ (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy):
+ (WebKit::WebUserContentControllerProxy::addProcess):
+ (WebKit::WebUserContentControllerProxy::removeProcess):
+ (WebKit::WebUserContentControllerProxy::addUserContentWorldUse):
+ (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses):
+ (WebKit::WebUserContentControllerProxy::addUserScript):
+ (WebKit::WebUserContentControllerProxy::removeUserScript):
+ (WebKit::WebUserContentControllerProxy::removeAllUserScripts):
+ (WebKit::WebUserContentControllerProxy::addUserStyleSheet):
+ (WebKit::WebUserContentControllerProxy::removeUserStyleSheet):
+ (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets):
+ (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler):
+ (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName):
+ (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers):
+ (WebKit::WebUserContentControllerProxy::addContentRuleList):
+ (WebKit::WebUserContentControllerProxy::removeContentRuleList):
+ (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists):
+ (WebKit::generateIdentifier): Deleted.
+ * UIProcess/UserContent/WebUserContentControllerProxy.h:
+ (WebKit::WebUserContentControllerProxy::identifier const): Deleted.
+
+ * UIProcess/VisitedLinkStore.cpp:
+ (WebKit::VisitedLinkStore::~VisitedLinkStore):
+ (WebKit::VisitedLinkStore::VisitedLinkStore):
+ (WebKit::VisitedLinkStore::addProcess):
+ (WebKit::VisitedLinkStore::removeProcess):
+ (WebKit::VisitedLinkStore::removeAll):
+ (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired):
+ (WebKit::VisitedLinkStore::sendTable):
+ (WebKit::generateIdentifier): Deleted.
+ * UIProcess/VisitedLinkStore.h:
+
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::WebsiteDataStore):
+ (WebKit::generateIdentifier): Deleted.
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+ (WebKit::WebsiteDataStore::identifier const): Deleted.
+
+ * WebProcess/Network/WebSocketStream.cpp:
+ (WebKit::WebSocketStream::WebSocketStream):
+ (WebKit::WebSocketStream::~WebSocketStream):
+ (WebKit::WebSocketStream::messageSenderDestinationID):
+ * WebProcess/Network/WebSocketStream.h:
+
+2017-08-30 Brady Eidson <beid...@apple.com>
+
Implement all of "Register" right up until where the script is fetched.
https://bugs.webkit.org/show_bug.cgi?id=176082
Modified: trunk/Source/WebKit/UIProcess/API/APIUserScript.cpp (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/API/APIUserScript.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/API/APIUserScript.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -30,13 +30,6 @@
namespace API {
-static uint64_t generateIdentifier()
-{
- static uint64_t identifier;
-
- return ++identifier;
-}
-
WebCore::URL UserScript::generateUniqueURL()
{
static uint64_t identifier;
@@ -48,8 +41,7 @@
}
UserScript::UserScript(WebCore::UserScript userScript, API::UserContentWorld& world)
- : m_identifier(generateIdentifier())
- , m_userScript(userScript)
+ : m_userScript(userScript)
, m_world(world)
{
}
Modified: trunk/Source/WebKit/UIProcess/API/APIUserScript.h (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/API/APIUserScript.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/API/APIUserScript.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -29,10 +29,11 @@
#include "APIObject.h"
#include "APIUserContentWorld.h"
#include <WebCore/UserScript.h>
+#include <wtf/Identified.h>
namespace API {
-class UserScript final : public ObjectImpl<Object::Type::UserScript> {
+class UserScript final : public ObjectImpl<Object::Type::UserScript>, public Identified<UserScript> {
public:
static WebCore::URL generateUniqueURL();
@@ -43,8 +44,6 @@
UserScript(WebCore::UserScript, API::UserContentWorld&);
- uint64_t identifier() const { return m_identifier; }
-
const WebCore::UserScript& userScript() const { return m_userScript; }
UserContentWorld& userContentWorld() { return m_world; }
@@ -51,7 +50,6 @@
const UserContentWorld& userContentWorld() const { return m_world; }
private:
- uint64_t m_identifier;
WebCore::UserScript m_userScript;
Ref<UserContentWorld> m_world;
};
Modified: trunk/Source/WebKit/UIProcess/API/APIUserStyleSheet.cpp (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/API/APIUserStyleSheet.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/API/APIUserStyleSheet.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -30,13 +30,6 @@
namespace API {
-static uint64_t generateIdentifier()
-{
- static uint64_t identifier;
-
- return ++identifier;
-}
-
WebCore::URL UserStyleSheet::generateUniqueURL()
{
static uint64_t identifier;
@@ -48,8 +41,7 @@
}
UserStyleSheet::UserStyleSheet(WebCore::UserStyleSheet userStyleSheet, API::UserContentWorld& world)
- : m_identifier(generateIdentifier())
- , m_userStyleSheet(userStyleSheet)
+ : m_userStyleSheet(userStyleSheet)
, m_world(world)
{
}
Modified: trunk/Source/WebKit/UIProcess/API/APIUserStyleSheet.h (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/API/APIUserStyleSheet.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/API/APIUserStyleSheet.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -29,10 +29,11 @@
#include "APIObject.h"
#include "APIUserContentWorld.h"
#include <WebCore/UserStyleSheet.h>
+#include <wtf/Identified.h>
namespace API {
-class UserStyleSheet final : public ObjectImpl<Object::Type::UserStyleSheet> {
+class UserStyleSheet final : public ObjectImpl<Object::Type::UserStyleSheet>, public Identified<UserStyleSheet> {
public:
static WebCore::URL generateUniqueURL();
@@ -43,8 +44,6 @@
UserStyleSheet(WebCore::UserStyleSheet, API::UserContentWorld&);
- uint64_t identifier() const { return m_identifier; }
-
const WebCore::UserStyleSheet& userStyleSheet() const { return m_userStyleSheet; }
UserContentWorld& userContentWorld() { return m_world; }
@@ -51,7 +50,6 @@
const UserContentWorld& userContentWorld() const { return m_world; }
private:
- uint64_t m_identifier;
WebCore::UserStyleSheet m_userStyleSheet;
Ref<UserContentWorld> m_world;
};
Modified: trunk/Source/WebKit/UIProcess/UserContent/WebScriptMessageHandler.cpp (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/UserContent/WebScriptMessageHandler.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebScriptMessageHandler.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -30,13 +30,6 @@
namespace WebKit {
-static uint64_t generateIdentifier()
-{
- static uint64_t identifier;
-
- return ++identifier;
-}
-
Ref<WebScriptMessageHandler> WebScriptMessageHandler::create(std::unique_ptr<Client> client, const String& name, API::UserContentWorld& world)
{
return adoptRef(*new WebScriptMessageHandler(WTFMove(client), name, world));
@@ -43,8 +36,7 @@
}
WebScriptMessageHandler::WebScriptMessageHandler(std::unique_ptr<Client> client, const String& name, API::UserContentWorld& world)
- : m_identifier(generateIdentifier())
- , m_client(WTFMove(client))
+ : m_client(WTFMove(client))
, m_name(name)
, m_world(world)
{
Modified: trunk/Source/WebKit/UIProcess/UserContent/WebScriptMessageHandler.h (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/UserContent/WebScriptMessageHandler.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebScriptMessageHandler.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -27,6 +27,7 @@
#define WebScriptMessageHandler_h
#include "WebUserContentControllerDataTypes.h"
+#include <wtf/Identified.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
@@ -46,7 +47,7 @@
class WebFrameProxy;
struct FrameInfoData;
-class WebScriptMessageHandler : public RefCounted<WebScriptMessageHandler> {
+class WebScriptMessageHandler : public RefCounted<WebScriptMessageHandler>, public Identified<WebScriptMessageHandler> {
public:
class Client {
public:
@@ -57,7 +58,6 @@
static Ref<WebScriptMessageHandler> create(std::unique_ptr<Client>, const String& name, API::UserContentWorld&);
virtual ~WebScriptMessageHandler();
- uint64_t identifier() const { return m_identifier; }
String name() const { return m_name; }
const API::UserContentWorld& userContentWorld() const { return m_world; }
@@ -67,8 +67,6 @@
private:
WebScriptMessageHandler(std::unique_ptr<Client>, const String&, API::UserContentWorld&);
-
- uint64_t m_identifier;
std::unique_ptr<Client> m_client;
String m_name;
Modified: trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -46,16 +46,8 @@
namespace WebKit {
-static uint64_t generateIdentifier()
-{
- static uint64_t identifier;
-
- return ++identifier;
-}
-
WebUserContentControllerProxy::WebUserContentControllerProxy()
- : m_identifier(generateIdentifier())
- , m_userScripts(API::Array::create())
+ : m_userScripts(API::Array::create())
, m_userStyleSheets(API::Array::create())
{
}
@@ -63,7 +55,7 @@
WebUserContentControllerProxy::~WebUserContentControllerProxy()
{
for (WebProcessProxy* process : m_processes) {
- process->removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), m_identifier);
+ process->removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier());
process->didDestroyWebUserContentControllerProxy(*this);
}
}
@@ -73,7 +65,7 @@
if (!m_processes.add(&webProcessProxy).isNewEntry)
return;
- webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), m_identifier, *this);
+ webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier(), *this);
ASSERT(parameters.userContentWorlds.isEmpty());
for (const auto& world : m_userContentWorlds)
@@ -103,7 +95,7 @@
ASSERT(m_processes.contains(&webProcessProxy));
m_processes.remove(&webProcessProxy);
- webProcessProxy.removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), m_identifier);
+ webProcessProxy.removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier());
}
void WebUserContentControllerProxy::addUserContentWorldUse(API::UserContentWorld& world)
@@ -114,7 +106,7 @@
auto addResult = m_userContentWorlds.add(&world);
if (addResult.isNewEntry) {
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::AddUserContentWorlds({ std::make_pair(world.identifier(), world.name()) }), m_identifier);
+ process->send(Messages::WebUserContentController::AddUserContentWorlds({ std::make_pair(world.identifier(), world.name()) }), identifier());
}
}
@@ -138,7 +130,7 @@
{
if (shouldSendRemoveUserContentWorldsMessage(world, numberOfUsesToRemove)) {
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveUserContentWorlds({ world.identifier() }), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveUserContentWorlds({ world.identifier() }), identifier());
}
}
@@ -151,7 +143,7 @@
}
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), identifier());
}
void WebUserContentControllerProxy::addUserScript(API::UserScript& userScript)
@@ -163,7 +155,7 @@
m_userScripts->elements().append(&userScript);
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), m_identifier);
+ process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), identifier());
}
void WebUserContentControllerProxy::removeUserScript(API::UserScript& userScript)
@@ -171,7 +163,7 @@
Ref<API::UserContentWorld> world = userScript.userContentWorld();
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveUserScript(world->identifier(), userScript.identifier()), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveUserScript(world->identifier(), userScript.identifier()), identifier());
m_userScripts->elements().removeAll(&userScript);
@@ -181,7 +173,7 @@
void WebUserContentControllerProxy::removeAllUserScripts(API::UserContentWorld& world)
{
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveAllUserScripts({ world.identifier() }), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveAllUserScripts({ world.identifier() }), identifier());
unsigned userScriptsRemoved = m_userScripts->removeAllOfTypeMatching<API::UserScript>([&](const auto& userScript) {
return &userScript->userContentWorld() == &world;
@@ -202,7 +194,7 @@
worldIdentifiers.uncheckedAppend(worldCountPair.key->identifier());
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveAllUserScripts(worldIdentifiers), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveAllUserScripts(worldIdentifiers), identifier());
m_userScripts->elements().clear();
@@ -218,7 +210,7 @@
m_userStyleSheets->elements().append(&userStyleSheet);
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::AddUserStyleSheets({ { userStyleSheet.identifier(), world->identifier(), userStyleSheet.userStyleSheet() } }), m_identifier);
+ process->send(Messages::WebUserContentController::AddUserStyleSheets({ { userStyleSheet.identifier(), world->identifier(), userStyleSheet.userStyleSheet() } }), identifier());
}
void WebUserContentControllerProxy::removeUserStyleSheet(API::UserStyleSheet& userStyleSheet)
@@ -226,7 +218,7 @@
Ref<API::UserContentWorld> world = userStyleSheet.userContentWorld();
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveUserStyleSheet(world->identifier(), userStyleSheet.identifier()), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveUserStyleSheet(world->identifier(), userStyleSheet.identifier()), identifier());
m_userStyleSheets->elements().removeAll(&userStyleSheet);
@@ -236,7 +228,7 @@
void WebUserContentControllerProxy::removeAllUserStyleSheets(API::UserContentWorld& world)
{
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets({ world.identifier() }), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets({ world.identifier() }), identifier());
unsigned userStyleSheetsRemoved = m_userStyleSheets->removeAllOfTypeMatching<API::UserStyleSheet>([&](const auto& userStyleSheet) {
return &userStyleSheet->userContentWorld() == &world;
@@ -257,7 +249,7 @@
worldIdentifiers.uncheckedAppend(worldCountPair.key->identifier());
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(worldIdentifiers), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(worldIdentifiers), identifier());
m_userStyleSheets->elements().clear();
@@ -278,7 +270,7 @@
m_scriptMessageHandlers.add(handler.identifier(), &handler);
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::AddUserScriptMessageHandlers({ { handler.identifier(), world->identifier(), handler.name() } }), m_identifier);
+ process->send(Messages::WebUserContentController::AddUserScriptMessageHandlers({ { handler.identifier(), world->identifier(), handler.name() } }), identifier());
return true;
}
@@ -288,7 +280,7 @@
for (auto it = m_scriptMessageHandlers.begin(), end = m_scriptMessageHandlers.end(); it != end; ++it) {
if (it->value->name() == name && &it->value->userContentWorld() == &world) {
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveUserScriptMessageHandler(world.identifier(), it->value->identifier()), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveUserScriptMessageHandler(world.identifier(), it->value->identifier()), identifier());
m_scriptMessageHandlers.remove(it);
@@ -301,7 +293,7 @@
void WebUserContentControllerProxy::removeAllUserMessageHandlers(API::UserContentWorld& world)
{
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveAllUserScriptMessageHandlers({ world.identifier() }), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveAllUserScriptMessageHandlers({ world.identifier() }), identifier());
unsigned numberRemoved = 0;
m_scriptMessageHandlers.removeIf([&](auto& entry) {
@@ -339,7 +331,7 @@
auto pair = std::make_pair(contentRuleList.name(), contentRuleList.compiledRuleList().data());
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::AddContentRuleLists({ pair }), m_identifier);
+ process->send(Messages::WebUserContentController::AddContentRuleLists({ pair }), identifier());
}
void WebUserContentControllerProxy::removeContentRuleList(const String& name)
@@ -347,7 +339,7 @@
m_contentRuleLists.remove(name);
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveContentRuleList(name), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveContentRuleList(name), identifier());
}
void WebUserContentControllerProxy::removeAllContentRuleLists()
@@ -355,7 +347,7 @@
m_contentRuleLists.clear();
for (WebProcessProxy* process : m_processes)
- process->send(Messages::WebUserContentController::RemoveAllContentRuleLists(), m_identifier);
+ process->send(Messages::WebUserContentController::RemoveAllContentRuleLists(), identifier());
}
#endif
Modified: trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -31,6 +31,7 @@
#include <wtf/HashCountedSet.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/Identified.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/text/StringHash.h>
@@ -58,7 +59,7 @@
struct FrameInfoData;
struct WebPageCreationParameters;
-class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver {
+class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver, public Identified<WebUserContentControllerProxy> {
public:
static Ref<WebUserContentControllerProxy> create()
{
@@ -67,8 +68,6 @@
explicit WebUserContentControllerProxy();
~WebUserContentControllerProxy();
- uint64_t identifier() const { return m_identifier; }
-
void addProcess(WebProcessProxy&, WebPageCreationParameters&);
void removeProcess(WebProcessProxy&);
@@ -108,7 +107,6 @@
void removeUserContentWorldUses(HashCountedSet<RefPtr<API::UserContentWorld>>&);
bool shouldSendRemoveUserContentWorldsMessage(API::UserContentWorld&, unsigned numberOfUsesToRemove);
- uint64_t m_identifier;
HashSet<WebProcessProxy*> m_processes;
Ref<API::Array> m_userScripts;
Ref<API::Array> m_userStyleSheets;
Modified: trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -40,13 +40,6 @@
static const int visitedLinkTableMaxLoad = 2;
-static uint64_t generateIdentifier()
-{
- static uint64_t identifier;
-
- return ++identifier;
-}
-
Ref<VisitedLinkStore> VisitedLinkStore::create()
{
return adoptRef(*new VisitedLinkStore);
@@ -55,14 +48,13 @@
VisitedLinkStore::~VisitedLinkStore()
{
for (WebProcessProxy* process : m_processes) {
- process->removeMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), m_identifier);
+ process->removeMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier());
process->didDestroyVisitedLinkStore(*this);
}
}
VisitedLinkStore::VisitedLinkStore()
- : m_identifier(generateIdentifier())
- , m_keyCount(0)
+ : m_keyCount(0)
, m_tableSize(0)
, m_pendingVisitedLinksTimer(RunLoop::main(), this, &VisitedLinkStore::pendingVisitedLinksTimerFired)
{
@@ -75,7 +67,7 @@
if (!m_processes.add(&process).isNewEntry)
return;
- process.addMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), m_identifier, *this);
+ process.addMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier(), *this);
if (!m_keyCount)
return;
@@ -90,7 +82,7 @@
ASSERT(m_processes.contains(&process));
m_processes.remove(&process);
- process.removeMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), m_identifier);
+ process.removeMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier());
}
void VisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
@@ -111,7 +103,7 @@
for (WebProcessProxy* process : m_processes) {
ASSERT(process->processPool().processes().contains(process));
- process->send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), m_identifier);
+ process->send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), identifier());
}
}
@@ -194,9 +186,9 @@
ASSERT(process->processPool().processes().contains(process));
if (addedVisitedLinks.size() > 20)
- process->send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), m_identifier);
+ process->send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), identifier());
else
- process->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedVisitedLinks), m_identifier);
+ process->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedVisitedLinks), identifier());
}
}
@@ -253,7 +245,7 @@
if (!m_table.sharedMemory()->createHandle(handle, SharedMemory::Protection::ReadOnly))
return;
- process.send(Messages::VisitedLinkTableController::SetVisitedLinkTable(handle), m_identifier);
+ process.send(Messages::VisitedLinkTableController::SetVisitedLinkTable(handle), identifier());
}
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/VisitedLinkStore.h (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/VisitedLinkStore.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/VisitedLinkStore.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -34,6 +34,7 @@
#include <WebCore/LinkHash.h>
#include <wtf/Forward.h>
#include <wtf/HashSet.h>
+#include <wtf/Identified.h>
#include <wtf/RefCounted.h>
#include <wtf/RunLoop.h>
@@ -42,7 +43,7 @@
class WebPageProxy;
class WebProcessProxy;
-class VisitedLinkStore final : public API::ObjectImpl<API::Object::Type::VisitedLinkStore>, private IPC::MessageReceiver, public WebProcessLifetimeObserver {
+class VisitedLinkStore final : public API::ObjectImpl<API::Object::Type::VisitedLinkStore>, private IPC::MessageReceiver, public WebProcessLifetimeObserver, public Identified<VisitedLinkStore> {
public:
static Ref<VisitedLinkStore> create();
@@ -49,8 +50,6 @@
explicit VisitedLinkStore();
virtual ~VisitedLinkStore();
- uint64_t identifier() const { return m_identifier; }
-
void addProcess(WebProcessProxy&);
void removeProcess(WebProcessProxy&);
@@ -74,8 +73,6 @@
HashSet<WebProcessProxy*> m_processes;
- uint64_t m_identifier;
-
unsigned m_keyCount;
unsigned m_tableSize;
VisitedLinkTable m_table;
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -54,13 +54,6 @@
namespace WebKit {
-static uint64_t generateIdentifier()
-{
- static uint64_t identifier;
-
- return ++identifier;
-}
-
Ref<WebsiteDataStore> WebsiteDataStore::createNonPersistent()
{
return adoptRef(*new WebsiteDataStore(PAL::SessionID::generateEphemeralSessionID()));
@@ -72,8 +65,7 @@
}
WebsiteDataStore::WebsiteDataStore(Configuration configuration, PAL::SessionID sessionID)
- : m_identifier(generateIdentifier())
- , m_sessionID(sessionID)
+ : m_sessionID(sessionID)
, m_configuration(WTFMove(configuration))
, m_storageManager(StorageManager::create(m_configuration.localStorageDirectory))
, m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore"))
@@ -82,8 +74,7 @@
}
WebsiteDataStore::WebsiteDataStore(PAL::SessionID sessionID)
- : m_identifier(generateIdentifier())
- , m_sessionID(sessionID)
+ : m_sessionID(sessionID)
, m_configuration()
, m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore"))
{
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (221398 => 221399)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -32,6 +32,7 @@
#include <pal/SessionID.h>
#include <wtf/Function.h>
#include <wtf/HashSet.h>
+#include <wtf/Identified.h>
#include <wtf/OptionSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -64,7 +65,7 @@
enum class ShouldClearFirst { No, Yes };
-class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver {
+class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore> {
public:
struct Configuration {
String cacheStorageDirectory;
@@ -85,8 +86,6 @@
static Ref<WebsiteDataStore> create(Configuration, PAL::SessionID);
virtual ~WebsiteDataStore();
- uint64_t identifier() const { return m_identifier; }
-
bool isPersistent() const { return !m_sessionID.isEphemeral(); }
PAL::SessionID sessionID() const { return m_sessionID; }
@@ -159,7 +158,6 @@
static void removeMediaKeys(const String& mediaKeysStorageDirectory, std::chrono::system_clock::time_point modifiedSince);
static void removeMediaKeys(const String& mediaKeysStorageDirectory, const HashSet<WebCore::SecurityOriginData>&);
- const uint64_t m_identifier;
const PAL::SessionID m_sessionID;
const Configuration m_configuration;
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp (221398 => 221399)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp 2017-08-30 21:50:27 UTC (rev 221399)
@@ -41,8 +41,6 @@
namespace WebKit {
-static uint64_t nextAvailableIdentifier = 1;
-
static HashMap<uint64_t, WebSocketStream*>& globalWebSocketStreamMap()
{
static NeverDestroyed<HashMap<uint64_t, WebSocketStream*>> globalMap;
@@ -72,19 +70,18 @@
WebSocketStream::WebSocketStream(const WebCore::URL& url, WebCore::SocketStreamHandleClient& client, PAL::SessionID sessionID, const String& cachePartition)
: SocketStreamHandle(url, client)
- , m_identifier(nextAvailableIdentifier++)
, m_client(client)
{
- WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, sessionID, cachePartition, m_identifier), 0);
+ WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, sessionID, cachePartition, identifier()), 0);
- ASSERT(!globalWebSocketStreamMap().contains(m_identifier));
- globalWebSocketStreamMap().set(m_identifier, this);
+ ASSERT(!globalWebSocketStreamMap().contains(identifier()));
+ globalWebSocketStreamMap().set(identifier(), this);
}
WebSocketStream::~WebSocketStream()
{
- ASSERT(globalWebSocketStreamMap().contains(m_identifier));
- globalWebSocketStreamMap().remove(m_identifier);
+ ASSERT(globalWebSocketStreamMap().contains(identifier()));
+ globalWebSocketStreamMap().remove(identifier());
}
IPC::Connection* WebSocketStream::messageSenderConnection()
@@ -94,7 +91,7 @@
uint64_t WebSocketStream::messageSenderDestinationID()
{
- return m_identifier;
+ return identifier();
}
void WebSocketStream::platformSend(const char* data, size_t length, Function<void(bool)>&& completionHandler)
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h (221398 => 221399)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h 2017-08-30 21:36:04 UTC (rev 221398)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketStream.h 2017-08-30 21:50:27 UTC (rev 221399)
@@ -29,6 +29,7 @@
#include "MessageSender.h"
#include <WebCore/SocketStreamHandle.h>
#include <pal/SessionID.h>
+#include <wtf/Identified.h>
namespace IPC {
class Connection;
@@ -42,7 +43,7 @@
namespace WebKit {
-class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle {
+class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle, public Identified<WebSocketStream> {
public:
static Ref<WebSocketStream> create(const WebCore::URL&, WebCore::SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition);
static void networkProcessCrashed();
@@ -74,7 +75,6 @@
~WebSocketStream();
size_t m_bufferedAmount { 0 };
- uint64_t m_identifier { 0 };
WebCore::SocketStreamHandleClient& m_client;
HashMap<uint64_t, Function<void(bool)>> m_sendDataCallbacks;
};