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