chromium/components/performance_manager/v8_memory/web_memory_impl.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/performance_manager/v8_memory/web_memory_impl.h"

#include <memory>
#include <utility>

#include "base/check.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/ranges/algorithm.h"
#include "components/performance_manager/public/graph/frame_node.h"
#include "components/performance_manager/public/graph/graph.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "components/performance_manager/public/graph/process_node.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/performance_manager/public/render_frame_host_proxy.h"
#include "components/performance_manager/public/v8_memory/web_memory.h"
#include "components/performance_manager/v8_memory/web_memory_aggregator.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace performance_manager {

namespace v8_memory {

namespace {

mojom::WebMemoryMeasurementPtr BuildMemoryUsageResult(
    const blink::LocalFrameToken& frame_token,
    const ProcessNode* process_node) {}

v8_memory::V8DetailedMemoryRequest::MeasurementMode
WebMeasurementModeToRequestMeasurementMode(
    mojom::WebMemoryMeasurement::Mode mode) {}

// Checks if the frame referenced by |rfh_proxy| is crossOriginIsolated. If so,
// invokes |measure_memory_callback| on the PM sequences. If not, invokes
// |bad_message_callback| instead. If the frame disappears at any point, does
// nothing.
void CheckIsCrossOriginIsolatedOnUISeq(
    const RenderFrameHostProxy& rfh_proxy,
    WebMeasureMemorySecurityChecker::MeasureMemoryCallback
        measure_memory_callback,
    mojo::ReportBadMessageCallback bad_message_callback) {}

}  // anonymous namespace

////////////////////////////////////////////////////////////////////////////////
// WebMemoryMeasurer

WebMemoryMeasurer::WebMemoryMeasurer(
    const blink::LocalFrameToken& frame_token,
    V8DetailedMemoryRequest::MeasurementMode mode,
    MeasurementCallback callback)
    :{}

WebMemoryMeasurer::~WebMemoryMeasurer() = default;

// static
void WebMemoryMeasurer::MeasureMemory(mojom::WebMemoryMeasurement::Mode mode,
                                      MeasurementCallback callback,
                                      base::WeakPtr<FrameNode> frame_node) {}

void WebMemoryMeasurer::MeasurementComplete(
    const ProcessNode* process_node,
    const V8DetailedMemoryProcessData*) {}

////////////////////////////////////////////////////////////////////////////////
// WebMeasureMemorySecurityCheckerImpl

// Implements the public function in public/v8_memory/web_memory.h
std::unique_ptr<WebMeasureMemorySecurityChecker>
WebMeasureMemorySecurityChecker::Create() {}

void WebMeasureMemorySecurityCheckerImpl::CheckMeasureMemoryIsAllowed(
    const FrameNode* frame,
    MeasureMemoryCallback measure_memory_callback,
    mojo::ReportBadMessageCallback bad_message_callback) const {}

////////////////////////////////////////////////////////////////////////////////
// Free functions

// Implements the public function in public/v8_memory/web_memory.h
void WebMeasureMemory(
    const FrameNode* frame_node,
    mojom::WebMemoryMeasurement::Mode mode,
    std::unique_ptr<WebMeasureMemorySecurityChecker> security_checker,
    base::OnceCallback<void(mojom::WebMemoryMeasurementPtr)> result_callback,
    mojo::ReportBadMessageCallback bad_message_callback) {}

}  // namespace v8_memory

}  // namespace performance_manager