Commit 775f33ab authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Chromium LUCI CQ

Remove WebMemoryPressureLevel enum in blink

This CL removes all uses of WebMemoryPressureLevel enum
to make Blink public layer slim. Instead, this CL replaces
all uses of WebMemoryPressureLevel with
base::MemoryPressureListener::MemoryPressureLevel.

Bug: 919392
Change-Id: I85d466887483557b34f88b40fba4ce7c6ec1649b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2588681
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836586}
parent 7e64ab2c
......@@ -229,22 +229,6 @@ static_assert(
v8::MemoryPressureLevel::kCritical,
"critical level not align");
// WebMemoryPressureLevel should correspond to base::MemoryPressureListener.
static_assert(static_cast<blink::WebMemoryPressureLevel>(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) ==
blink::kWebMemoryPressureLevelNone,
"blink::WebMemoryPressureLevelNone not align");
static_assert(
static_cast<blink::WebMemoryPressureLevel>(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE) ==
blink::kWebMemoryPressureLevelModerate,
"blink::WebMemoryPressureLevelModerate not align");
static_assert(
static_cast<blink::WebMemoryPressureLevel>(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) ==
blink::kWebMemoryPressureLevelCritical,
"blink::WebMemoryPressureLevelCritical not align");
void* CreateHistogram(const char* name, int min, int max, size_t buckets) {
if (min <= 0)
min = 1;
......@@ -1785,10 +1769,8 @@ void RenderThreadImpl::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
TRACE_EVENT1("memory", "RenderThreadImpl::OnMemoryPressure", "level",
memory_pressure_level);
if (blink_platform_impl_) {
blink::WebMemoryPressureListener::OnMemoryPressure(
static_cast<blink::WebMemoryPressureLevel>(memory_pressure_level));
}
if (blink_platform_impl_)
blink::WebMemoryPressureListener::OnMemoryPressure(memory_pressure_level);
if (memory_pressure_level ==
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
ReleaseFreeMemory();
......
......@@ -224,7 +224,6 @@ source_set("blink_headers") {
"platform/web_media_player_encrypted_media_client.h",
"platform/web_media_player_source.h",
"platform/web_media_source.h",
"platform/web_memory_pressure_level.h",
"platform/web_memory_pressure_listener.h",
"platform/web_mixed_content.h",
"platform/web_mixed_content_context_type.h",
......
......@@ -9,6 +9,7 @@ include_rules = [
"+base/logging.h",
"+base/macros.h",
"+base/mac/scoped_cftyperef.h",
"+base/memory/memory_pressure_listener.h",
"+base/memory/ref_counted.h",
"+base/memory/scoped_refptr.h",
"+base/memory/weak_ptr.h",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEMORY_PRESSURE_LEVEL_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEMORY_PRESSURE_LEVEL_H_
namespace blink {
// These number must correspond to
// base::MemoryPressureListener::MemoryPressureLevel.
enum WebMemoryPressureLevel {
kWebMemoryPressureLevelNone,
kWebMemoryPressureLevelModerate,
kWebMemoryPressureLevelCritical,
};
} // namespace blink
#endif
......@@ -5,15 +5,16 @@
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEMORY_PRESSURE_LISTENER_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEMORY_PRESSURE_LISTENER_H_
#include "base/memory/memory_pressure_listener.h"
#include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_memory_pressure_level.h"
namespace blink {
class WebMemoryPressureListener {
public:
// Called when a memory pressure notification is received.
BLINK_PLATFORM_EXPORT static void OnMemoryPressure(WebMemoryPressureLevel);
BLINK_PLATFORM_EXPORT static void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel);
BLINK_PLATFORM_EXPORT static void OnPurgeMemory();
};
......
......@@ -9,7 +9,7 @@
namespace blink {
void WebMemoryPressureListener::OnMemoryPressure(
WebMemoryPressureLevel pressure_level) {
base::MemoryPressureListener::MemoryPressureLevel pressure_level) {
MemoryPressureListenerRegistry::Instance().OnMemoryPressure(pressure_level);
}
......
......@@ -100,7 +100,7 @@ void MemoryPressureListenerRegistry::UnregisterClient(
}
void MemoryPressureListenerRegistry::OnMemoryPressure(
WebMemoryPressureLevel level) {
base::MemoryPressureListener::MemoryPressureLevel level) {
TRACE_EVENT1("blink", "MemoryPressureListenerRegistry::onMemoryPressure",
"level", level);
CHECK(IsMainThread());
......
......@@ -6,7 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_INSTRUMENTATION_MEMORY_PRESSURE_LISTENER_H_
#include "base/macros.h"
#include "third_party/blink/public/platform/web_memory_pressure_level.h"
#include "base/memory/memory_pressure_listener.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/threading_primitives.h"
......@@ -19,7 +19,8 @@ class PLATFORM_EXPORT MemoryPressureListener : public GarbageCollectedMixin {
public:
virtual ~MemoryPressureListener() = default;
virtual void OnMemoryPressure(WebMemoryPressureLevel) {}
virtual void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel) {}
virtual void OnPurgeMemory() {}
};
......@@ -55,7 +56,7 @@ class PLATFORM_EXPORT MemoryPressureListenerRegistry final
void RegisterClient(MemoryPressureListener*);
void UnregisterClient(MemoryPressureListener*);
void OnMemoryPressure(WebMemoryPressureLevel);
void OnMemoryPressure(base::MemoryPressureListener::MemoryPressureLevel);
void OnPurgeMemory();
......
......@@ -447,7 +447,8 @@ bool MemoryCache::OnMemoryDump(WebMemoryDumpLevelOfDetail level_of_detail,
return true;
}
void MemoryCache::OnMemoryPressure(WebMemoryPressureLevel level) {
void MemoryCache::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel level) {
PruneAll();
}
......
......@@ -151,7 +151,8 @@ class PLATFORM_EXPORT MemoryCache final : public GarbageCollected<MemoryCache>,
// Take memory usage snapshot for tracing.
bool OnMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) override;
void OnMemoryPressure(WebMemoryPressureLevel) override;
void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel) override;
private:
enum PruneStrategy {
......
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