blob: 4c8507480bea1f25a0ed4e07236391ccc6655788 [file] [log] [blame]
// Copyright 2019 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.
#include "base/memory/scoped_refptr.h"
#include "base/unguessable_token.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "v8/include/v8.h"
namespace blink {
namespace scheduler {
class EventLoop;
class ExecutionContext;
// Corresponding spec concept is:
// Agent is a group of browsing contexts that can access each other
// synchronously. E.g. same-site iframes share the same agent, Workers and
// Worklets have their own agent.
// While an WindowAgentFactory is shared across a group of reachable frames,
// Agent is shared across a group of reachable and same-site frames.
class CORE_EXPORT Agent : public GarbageCollected<Agent> {
// Do not create the instance directly.
// Use MakeGarbageCollected<Agent>() or
// WindowAgentFactory::GetAgentForOrigin().
Agent(v8::Isolate* isolate,
const base::UnguessableToken& cluster_id,
std::unique_ptr<v8::MicrotaskQueue> microtask_queue = nullptr);
virtual ~Agent();
const scoped_refptr<scheduler::EventLoop>& event_loop() const {
return event_loop_;
virtual void Trace(Visitor*);
void AttachExecutionContext(ExecutionContext*);
void DetachExecutionContext(ExecutionContext*);
const base::UnguessableToken& cluster_id() const { return cluster_id_; }
scoped_refptr<scheduler::EventLoop> event_loop_;
const base::UnguessableToken cluster_id_;
} // namespace blink