Commit 977eedd6 authored by tasak@google.com's avatar tasak@google.com

Make classes and structures in core/events and core/fetch fast-allocated.

Added STATIC_ONLY, STACK_ALLOCATED, DISALLOW_ALLOCATION, or ALLOW_ONLY_INLINE_ALLOCATION
instead of WTF_MAKE_FAST_ALLOCATED(_WILL_BE_REMOVED) if possible.

BUG=523249

Review URL: https://codereview.chromium.org/1310643003

git-svn-id: svn://svn.chromium.org/blink/trunk@201203 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f7a823fe
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define EventFactory_h #define EventFactory_h
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "wtf/Allocator.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
#include "wtf/text/AtomicString.h" #include "wtf/text/AtomicString.h"
...@@ -35,6 +36,7 @@ namespace blink { ...@@ -35,6 +36,7 @@ namespace blink {
class Event; class Event;
class EventFactoryBase { class EventFactoryBase {
WTF_MAKE_FAST_ALLOCATED(EventFactory);
public: public:
virtual PassRefPtrWillBeRawPtr<Event> create(const String& eventType) = 0; virtual PassRefPtrWillBeRawPtr<Event> create(const String& eventType) = 0;
virtual ~EventFactoryBase() { } virtual ~EventFactoryBase() { }
......
...@@ -45,6 +45,8 @@ class TouchList; ...@@ -45,6 +45,8 @@ class TouchList;
class TreeScope; class TreeScope;
class CORE_EXPORT EventPath final : public NoBaseWillBeGarbageCollectedFinalized<EventPath> { class CORE_EXPORT EventPath final : public NoBaseWillBeGarbageCollectedFinalized<EventPath> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(EventPath);
WTF_MAKE_NONCOPYABLE(EventPath);
public: public:
explicit EventPath(Node&, Event* = nullptr); explicit EventPath(Node&, Event* = nullptr);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "core/EventTypeNames.h" #include "core/EventTypeNames.h"
#include "core/events/EventListenerMap.h" #include "core/events/EventListenerMap.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h" #include "wtf/text/AtomicString.h"
namespace blink { namespace blink {
...@@ -50,6 +51,7 @@ class MessagePort; ...@@ -50,6 +51,7 @@ class MessagePort;
class Node; class Node;
struct FiringEventIterator { struct FiringEventIterator {
ALLOW_ONLY_INLINE_ALLOCATION();
FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& end) FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& end)
: eventType(eventType) : eventType(eventType)
, iterator(iterator) , iterator(iterator)
......
...@@ -31,11 +31,14 @@ ...@@ -31,11 +31,14 @@
#ifndef NavigatorEvents_h #ifndef NavigatorEvents_h
#define NavigatorEvents_h #define NavigatorEvents_h
#include "wtf/Allocator.h"
namespace blink { namespace blink {
class Navigator; class Navigator;
class NavigatorEvents { class NavigatorEvents {
STATIC_ONLY(NavigatorEvents);
public: public:
static long maxTouchPoints(Navigator&); static long maxTouchPoints(Navigator&);
}; };
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef PointerIdManager_h #ifndef PointerIdManager_h
#define PointerIdManager_h #define PointerIdManager_h
#include "wtf/Allocator.h"
#include "wtf/ListHashSet.h" #include "wtf/ListHashSet.h"
namespace blink { namespace blink {
...@@ -13,6 +14,7 @@ namespace blink { ...@@ -13,6 +14,7 @@ namespace blink {
Helper class for tracking the primary pointer id for each type of PointerEvents. Helper class for tracking the primary pointer id for each type of PointerEvents.
*/ */
class PointerIdManager { class PointerIdManager {
DISALLOW_ALLOCATION();
public: public:
// TODO(mustaq): Move this enum to PointerEvent.h? Change the spec to use enums? // TODO(mustaq): Move this enum to PointerEvent.h? Change the spec to use enums?
enum PointerType { enum PointerType {
......
...@@ -66,7 +66,7 @@ private: ...@@ -66,7 +66,7 @@ private:
class EventQueueScope { class EventQueueScope {
WTF_MAKE_NONCOPYABLE(EventQueueScope); WTF_MAKE_NONCOPYABLE(EventQueueScope);
STACK_ALLOCATED();
public: public:
EventQueueScope() { ScopedEventQueue::instance()->incrementScopingLevel(); } EventQueueScope() { ScopedEventQueue::instance()->incrementScopingLevel(); }
~EventQueueScope() { ScopedEventQueue::instance()->decrementScopingLevel(); } ~EventQueueScope() { ScopedEventQueue::instance()->decrementScopingLevel(); }
......
...@@ -39,6 +39,8 @@ class Node; ...@@ -39,6 +39,8 @@ class Node;
class NodeEventContext; class NodeEventContext;
class WindowEventContext : public NoBaseWillBeGarbageCollected<WindowEventContext> { class WindowEventContext : public NoBaseWillBeGarbageCollected<WindowEventContext> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(WindowEventContext);
WTF_MAKE_NONCOPYABLE(WindowEventContext);
public: public:
WindowEventContext(Event&, const NodeEventContext& topNodeEventContext); WindowEventContext(Event&, const NodeEventContext& topNodeEventContext);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ClientHintsPreferences_h #define ClientHintsPreferences_h
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "wtf/Allocator.h"
#include "wtf/text/WTFString.h" #include "wtf/text/WTFString.h"
namespace blink { namespace blink {
...@@ -13,6 +14,7 @@ namespace blink { ...@@ -13,6 +14,7 @@ namespace blink {
class ResourceFetcher; class ResourceFetcher;
class CORE_EXPORT ClientHintsPreferences { class CORE_EXPORT ClientHintsPreferences {
DISALLOW_ALLOCATION();
public: public:
ClientHintsPreferences(); ClientHintsPreferences();
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "core/fetch/ResourceLoaderOptions.h" #include "core/fetch/ResourceLoaderOptions.h"
#include "platform/network/ResourceRequest.h" #include "platform/network/ResourceRequest.h"
#include "wtf/Allocator.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/HashSet.h" #include "wtf/HashSet.h"
...@@ -44,6 +45,7 @@ class ResourceResponse; ...@@ -44,6 +45,7 @@ class ResourceResponse;
class SecurityOrigin; class SecurityOrigin;
class CrossOriginAccessControl { class CrossOriginAccessControl {
STATIC_ONLY(CrossOriginAccessControl);
public: public:
// Given the new request URL, returns true if // Given the new request URL, returns true if
// - the URL has a CORS supported scheme and // - the URL has a CORS supported scheme and
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
namespace blink { namespace blink {
class DocumentResourceReference final : public DocumentResourceClient { class DocumentResourceReference final : public DocumentResourceClient {
WTF_MAKE_FAST_ALLOCATED(DocumentResourceReference);
public: public:
DocumentResourceReference(DocumentResource* document) : m_document(document) { m_document->addClient(this); } DocumentResourceReference(DocumentResource* document) : m_document(document) { m_document->addClient(this); }
~DocumentResourceReference() override { m_document->removeClient(this); } ~DocumentResourceReference() override { m_document->removeClient(this); }
......
...@@ -26,12 +26,14 @@ ...@@ -26,12 +26,14 @@
#ifndef FetchInitiatorInfo_h #ifndef FetchInitiatorInfo_h
#define FetchInitiatorInfo_h #define FetchInitiatorInfo_h
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h" #include "wtf/text/AtomicString.h"
#include "wtf/text/TextPosition.h" #include "wtf/text/TextPosition.h"
namespace blink { namespace blink {
struct FetchInitiatorInfo { struct FetchInitiatorInfo {
DISALLOW_ALLOCATION();
FetchInitiatorInfo() FetchInitiatorInfo()
: name() : name()
, position(TextPosition::belowRangePosition()) , position(TextPosition::belowRangePosition())
...@@ -48,6 +50,7 @@ struct FetchInitiatorInfo { ...@@ -48,6 +50,7 @@ struct FetchInitiatorInfo {
// Encode AtomicString as String to cross threads. // Encode AtomicString as String to cross threads.
struct CrossThreadFetchInitiatorInfoData { struct CrossThreadFetchInitiatorInfoData {
DISALLOW_ALLOCATION();
explicit CrossThreadFetchInitiatorInfoData(const FetchInitiatorInfo& info) explicit CrossThreadFetchInitiatorInfoData(const FetchInitiatorInfo& info)
: name(info.name.string().isolatedCopy()) : name(info.name.string().isolatedCopy())
, position(info.position) , position(info.position)
......
...@@ -32,17 +32,20 @@ ...@@ -32,17 +32,20 @@
#include "core/fetch/ResourceLoaderOptions.h" #include "core/fetch/ResourceLoaderOptions.h"
#include "platform/network/ResourceLoadPriority.h" #include "platform/network/ResourceLoadPriority.h"
#include "platform/network/ResourceRequest.h" #include "platform/network/ResourceRequest.h"
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h" #include "wtf/text/AtomicString.h"
namespace blink { namespace blink {
class SecurityOrigin; class SecurityOrigin;
class CORE_EXPORT FetchRequest { class CORE_EXPORT FetchRequest {
STACK_ALLOCATED();
public: public:
enum DeferOption { NoDefer, LazyLoad, DeferredByClient }; enum DeferOption { NoDefer, LazyLoad, DeferredByClient };
enum OriginRestriction { UseDefaultOriginRestrictionForType, RestrictToSameOrigin, NoOriginRestriction }; enum OriginRestriction { UseDefaultOriginRestrictionForType, RestrictToSameOrigin, NoOriginRestriction };
struct ResourceWidth { struct ResourceWidth {
DISALLOW_ALLOCATION();
float width; float width;
bool isSet; bool isSet;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define FetchUtils_h #define FetchUtils_h
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "wtf/Allocator.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
namespace blink { namespace blink {
...@@ -13,6 +14,7 @@ namespace blink { ...@@ -13,6 +14,7 @@ namespace blink {
class HTTPHeaderMap; class HTTPHeaderMap;
class CORE_EXPORT FetchUtils { class CORE_EXPORT FetchUtils {
STATIC_ONLY(FetchUtils);
public: public:
static bool isSimpleMethod(const String& method); static bool isSimpleMethod(const String& method);
static bool isSimpleHeader(const AtomicString& name, const AtomicString& value); static bool isSimpleHeader(const AtomicString& name, const AtomicString& value);
...@@ -23,9 +25,6 @@ public: ...@@ -23,9 +25,6 @@ public:
static bool isForbiddenResponseHeaderName(const String& name); static bool isForbiddenResponseHeaderName(const String& name);
static bool isSimpleOrForbiddenRequest(const String& method, const HTTPHeaderMap&); static bool isSimpleOrForbiddenRequest(const String& method, const HTTPHeaderMap&);
static AtomicString normalizeMethod(const AtomicString& method); static AtomicString normalizeMethod(const AtomicString& method);
private:
FetchUtils(); // = delete;
}; };
} // namespace blink } // namespace blink
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "core/fetch/Resource.h" #include "core/fetch/Resource.h"
#include "core/fetch/ResourcePtr.h" #include "core/fetch/ResourcePtr.h"
#include "public/platform/WebThread.h" #include "public/platform/WebThread.h"
#include "wtf/Allocator.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
#include "wtf/Noncopyable.h" #include "wtf/Noncopyable.h"
#include "wtf/Vector.h" #include "wtf/Vector.h"
...@@ -137,6 +138,7 @@ public: ...@@ -137,6 +138,7 @@ public:
DECLARE_TRACE(); DECLARE_TRACE();
struct TypeStatistic { struct TypeStatistic {
STACK_ALLOCATED();
size_t count; size_t count;
size_t size; size_t size;
size_t liveSize; size_t liveSize;
...@@ -162,6 +164,7 @@ public: ...@@ -162,6 +164,7 @@ public:
}; };
struct Statistics { struct Statistics {
STACK_ALLOCATED();
TypeStatistic images; TypeStatistic images;
TypeStatistic cssStyleSheets; TypeStatistic cssStyleSheets;
TypeStatistic scripts; TypeStatistic scripts;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "platform/network/ResourceRequest.h" #include "platform/network/ResourceRequest.h"
#include "platform/network/ResourceResponse.h" #include "platform/network/ResourceResponse.h"
#include "public/platform/WebDataConsumerHandle.h" #include "public/platform/WebDataConsumerHandle.h"
#include "wtf/Allocator.h"
#include "wtf/HashCountedSet.h" #include "wtf/HashCountedSet.h"
#include "wtf/HashSet.h" #include "wtf/HashSet.h"
#include "wtf/OwnPtr.h" #include "wtf/OwnPtr.h"
...@@ -324,6 +325,7 @@ protected: ...@@ -324,6 +325,7 @@ protected:
bool hasClient(ResourceClient* client) { return m_clients.contains(client) || m_clientsAwaitingCallback.contains(client); } bool hasClient(ResourceClient* client) { return m_clients.contains(client) || m_clientsAwaitingCallback.contains(client); }
struct RedirectPair { struct RedirectPair {
ALLOW_ONLY_INLINE_ALLOCATION();
public: public:
explicit RedirectPair(const ResourceRequest& request, const ResourceResponse& redirectResponse) explicit RedirectPair(const ResourceRequest& request, const ResourceResponse& redirectResponse)
: m_request(request) : m_request(request)
...@@ -421,6 +423,7 @@ private: ...@@ -421,6 +423,7 @@ private:
}; };
class ResourceFactory { class ResourceFactory {
STACK_ALLOCATED();
public: public:
virtual Resource* create(const ResourceRequest&, const String&) const = 0; virtual Resource* create(const ResourceRequest&, const String&) const = 0;
Resource::Type type() const { return m_type; } Resource::Type type() const { return m_type; }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define ResourceClientWalker_h #define ResourceClientWalker_h
#include "core/fetch/ResourceClient.h" #include "core/fetch/ResourceClient.h"
#include "wtf/Allocator.h"
#include "wtf/HashCountedSet.h" #include "wtf/HashCountedSet.h"
#include "wtf/Vector.h" #include "wtf/Vector.h"
...@@ -34,6 +35,7 @@ namespace blink { ...@@ -34,6 +35,7 @@ namespace blink {
// Call this "walker" instead of iterator so people won't expect Qt or STL-style iterator interface. // Call this "walker" instead of iterator so people won't expect Qt or STL-style iterator interface.
// Just keep calling next() on this. It's safe from deletions of items. // Just keep calling next() on this. It's safe from deletions of items.
template<typename T> class ResourceClientWalker { template<typename T> class ResourceClientWalker {
STACK_ALLOCATED();
public: public:
ResourceClientWalker(const HashCountedSet<ResourceClient*>& set) ResourceClientWalker(const HashCountedSet<ResourceClient*>& set)
: m_clientSet(set), m_clientVector(set.size()), m_index(0) : m_clientSet(set), m_clientVector(set.size()), m_index(0)
......
...@@ -201,6 +201,7 @@ private: ...@@ -201,6 +201,7 @@ private:
// Used in hit rate histograms. // Used in hit rate histograms.
class DeadResourceStatsRecorder { class DeadResourceStatsRecorder {
DISALLOW_ALLOCATION();
public: public:
DeadResourceStatsRecorder(); DeadResourceStatsRecorder();
~DeadResourceStatsRecorder(); ~DeadResourceStatsRecorder();
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
namespace blink { namespace blink {
class ResourceLoadPriorityOptimizer { class ResourceLoadPriorityOptimizer {
WTF_MAKE_FAST_ALLOCATED(ResourceLoadPriorityOptimizer);
WTF_MAKE_NONCOPYABLE(ResourceLoadPriorityOptimizer);
public: public:
enum VisibilityStatus { enum VisibilityStatus {
NotVisible, NotVisible,
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "core/fetch/FetchInitiatorInfo.h" #include "core/fetch/FetchInitiatorInfo.h"
#include "platform/CrossThreadCopier.h" #include "platform/CrossThreadCopier.h"
#include "platform/weborigin/SecurityOrigin.h" #include "platform/weborigin/SecurityOrigin.h"
#include "wtf/Allocator.h"
namespace blink { namespace blink {
...@@ -79,6 +80,8 @@ enum CORSEnabled { ...@@ -79,6 +80,8 @@ enum CORSEnabled {
}; };
struct ResourceLoaderOptions { struct ResourceLoaderOptions {
WTF_MAKE_FAST_ALLOCATED(ResourceLoaderOptions);
public:
ResourceLoaderOptions() ResourceLoaderOptions()
: dataBufferingPolicy(BufferData) : dataBufferingPolicy(BufferData)
, allowCredentials(DoNotAllowStoredCredentials) , allowCredentials(DoNotAllowStoredCredentials)
...@@ -137,6 +140,7 @@ struct ResourceLoaderOptions { ...@@ -137,6 +140,7 @@ struct ResourceLoaderOptions {
// Encode AtomicString (in FetchInitiatorInfo) as String to cross threads. // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads.
struct CrossThreadResourceLoaderOptionsData { struct CrossThreadResourceLoaderOptionsData {
DISALLOW_ALLOCATION();
explicit CrossThreadResourceLoaderOptionsData(const ResourceLoaderOptions& options) explicit CrossThreadResourceLoaderOptionsData(const ResourceLoaderOptions& options)
: dataBufferingPolicy(options.dataBufferingPolicy) : dataBufferingPolicy(options.dataBufferingPolicy)
, allowCredentials(options.allowCredentials) , allowCredentials(options.allowCredentials)
......
...@@ -28,10 +28,12 @@ ...@@ -28,10 +28,12 @@
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "core/fetch/Resource.h" #include "core/fetch/Resource.h"
#include "wtf/Allocator.h"
namespace blink { namespace blink {
class CORE_EXPORT ResourcePtrBase { class CORE_EXPORT ResourcePtrBase {
ALLOW_ONLY_INLINE_ALLOCATION();
public: public:
Resource* get() const { return m_resource; } Resource* get() const { return m_resource; }
bool operator!() const { return !m_resource; } bool operator!() const { return !m_resource; }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "platform/SharedBuffer.h" #include "platform/SharedBuffer.h"
#include "platform/weborigin/KURL.h" #include "platform/weborigin/KURL.h"
#include "wtf/Allocator.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h" #include "wtf/RefPtr.h"
...@@ -39,6 +40,7 @@ enum SubstituteDataLoadPolicy { ...@@ -39,6 +40,7 @@ enum SubstituteDataLoadPolicy {
}; };
class SubstituteData { class SubstituteData {
DISALLOW_ALLOCATION();
public: public:
SubstituteData() SubstituteData()
: m_substituteDataLoadPolicy(LoadNormally) : m_substituteDataLoadPolicy(LoadNormally)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment