Commit 76506a5a authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

BlinkMemoryMgt: Annotate Blink's platform/testing with the macros of Allocator

As a step to annotate the macros of Allocator for the Onion Soup, this CL annotates
some classes of //third_party/blink/renderer/platform/testing with the macros of
Allocator.

After some analyzes, it was concluded that for the case of HistogramTester,
LayerTreeHostEmbedder, ScopedMainThreadOverrider, ScopedSchedulerOverrider classes,
they make sense to use USING_FAST_MALLOC because they have been used as a member variable
with new() or smart pointers.

In FuzzedDataProvider classes, it makes sense to use DISALLOW_NEW because it's used
as member variable with a reference type.

Lastly, the rest of classes this CL annotates make sense to use STACK_ALLOCATED.

Bug: 919389
Change-Id: I1599e8879f39952d9699218a906ec8e7e193b5fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506675Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#638463}
parent 13b62afb
......@@ -5,11 +5,15 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_BLINK_FUZZER_TEST_SUPPORT_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_BLINK_FUZZER_TEST_SUPPORT_H_
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
// Instantiating BlinkFuzzerTestSupport will spin up an environment similar to
// blink_unittests. It should be statically initialized and leaked in fuzzers.
class BlinkFuzzerTestSupport {
STACK_ALLOCATED();
public:
// Use this constructor in LLVMFuzzerTestOneInput.
BlinkFuzzerTestSupport();
......
......@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/test/fuzzed_data_provider.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/text/cstring.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
......@@ -15,6 +16,8 @@ namespace blink {
// This class simply wraps //base/test/fuzzed_data_provider and vends Blink
// friendly types.
class FuzzedDataProvider {
DISALLOW_NEW();
public:
FuzzedDataProvider(const uint8_t* bytes, size_t num_bytes);
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace base {
class HistogramTester;
......@@ -16,6 +17,8 @@ namespace blink {
// Blink interface for base::HistogramTester.
class HistogramTester {
USING_FAST_MALLOC(HistogramTester);
public:
HistogramTester();
~HistogramTester();
......
......@@ -11,6 +11,7 @@
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_settings.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
......@@ -18,6 +19,8 @@ namespace blink {
// for unit tests that need to instantiate only a cc::LayerTreeHost and not the
// full blink APIs that normally own and embed it.
class LayerTreeHostEmbedder {
USING_FAST_MALLOC(LayerTreeHostEmbedder);
public:
// Default constructor uses stub clients, and default LayerTreeSettings
// appropriate for blink unit tests.
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
......@@ -19,6 +20,8 @@ namespace blink {
// the constructor gets destructed.
class ScopedMainThreadOverrider final {
USING_FAST_MALLOC(ScopedMainThreadOverrider);
public:
explicit ScopedMainThreadOverrider(std::unique_ptr<Thread> main_thread);
~ScopedMainThreadOverrider();
......
......@@ -8,6 +8,7 @@
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_response.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
......@@ -17,6 +18,8 @@ namespace test {
// unregister it on destruction. This prevent mocked URL from leaking to other
// tests.
class ScopedMockedURL {
STACK_ALLOCATED();
public:
explicit ScopedMockedURL(const WebURL&);
virtual ~ScopedMockedURL();
......
......@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/testing/scoped_main_thread_overrider.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
......@@ -16,6 +17,8 @@ namespace blink {
// Overrider. Multi-thread is not supported.
class ScopedSchedulerOverrider final {
USING_FAST_MALLOC(ScopedSchedulerOverrider);
public:
// |scheduler| must be owned by the caller.
explicit ScopedSchedulerOverrider(ThreadScheduler* scheduler);
......
......@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_WTF_SCOPED_MOCK_CLOCK_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_WTF_SCOPED_MOCK_CLOCK_H_
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/time.h"
namespace WTF {
......@@ -13,6 +14,8 @@ namespace WTF {
// stack resets mock time to the zero point for WTF::Time and WTF::TimeTicks.
// Mock time may only flow forwards, not backwards.
class ScopedMockClock {
USING_FAST_MALLOC(ScopedMockClock);
public:
ScopedMockClock();
~ScopedMockClock();
......
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