Commit a789d735 authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

[PM] Add the script URL to the worker node

Bug: 993029
Change-Id: Ic3fa5a2b02a15b25814ad8231d7cd6d3abe78ce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764404
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690087}
parent c24d5b81
......@@ -122,9 +122,10 @@ struct TestNodeWrapper<WorkerNodeImpl>::Factory {
GraphImpl* graph,
WorkerNode::WorkerType worker_type,
ProcessNodeImpl* process_node,
const GURL& url = GURL(),
const base::UnguessableToken& token = base::UnguessableToken::Create()) {
return std::make_unique<WorkerNodeImpl>(graph, worker_type, process_node,
token);
url, token);
}
};
......
......@@ -12,10 +12,12 @@ namespace performance_manager {
WorkerNodeImpl::WorkerNodeImpl(GraphImpl* graph,
WorkerType worker_type,
ProcessNodeImpl* process_node,
const GURL& url,
const base::UnguessableToken& dev_tools_token)
: TypedNodeBase(graph),
worker_type_(worker_type),
process_node_(process_node),
url_(url),
dev_tools_token_(dev_tools_token) {
DETACH_FROM_SEQUENCE(sequence_checker_);
DCHECK(process_node);
......@@ -101,6 +103,11 @@ ProcessNodeImpl* WorkerNodeImpl::process_node() const {
return process_node_;
}
const GURL& WorkerNodeImpl::url() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return url_;
}
const base::UnguessableToken& WorkerNodeImpl::dev_tools_token() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return dev_tools_token_;
......@@ -146,6 +153,11 @@ const ProcessNode* WorkerNodeImpl::GetProcessNode() const {
return process_node();
}
const GURL& WorkerNodeImpl::GetURL() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return url();
}
const base::UnguessableToken& WorkerNodeImpl::GetDevToolsToken() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return dev_tools_token();
......
......@@ -13,6 +13,7 @@
#include "base/unguessable_token.h"
#include "chrome/browser/performance_manager/graph/node_base.h"
#include "chrome/browser/performance_manager/public/graph/worker_node.h"
#include "url/gurl.h"
namespace performance_manager {
......@@ -29,6 +30,7 @@ class WorkerNodeImpl : public PublicNodeImpl<WorkerNodeImpl, WorkerNode>,
WorkerNodeImpl(GraphImpl* graph,
WorkerType worker_type,
ProcessNodeImpl* process_node,
const GURL& url,
const base::UnguessableToken& dev_tools_token);
~WorkerNodeImpl() override;
......@@ -43,6 +45,7 @@ class WorkerNodeImpl : public PublicNodeImpl<WorkerNodeImpl, WorkerNode>,
// Getters for const properties. These can be called from any thread.
WorkerType worker_type() const;
ProcessNodeImpl* process_node() const;
const GURL& url() const;
const base::UnguessableToken& dev_tools_token() const;
// Getters for non-const properties. These are not thread safe.
......@@ -58,6 +61,7 @@ class WorkerNodeImpl : public PublicNodeImpl<WorkerNodeImpl, WorkerNode>,
// impl use the private getters rather than the public interface.
WorkerType GetWorkerType() const override;
const ProcessNode* GetProcessNode() const override;
const GURL& GetURL() const override;
const base::UnguessableToken& GetDevToolsToken() const override;
const base::flat_set<const FrameNode*> GetClientFrames() const override;
const base::flat_set<const WorkerNode*> GetClientWorkers() const override;
......@@ -73,6 +77,9 @@ class WorkerNodeImpl : public PublicNodeImpl<WorkerNodeImpl, WorkerNode>,
// The process in which this worker lives.
ProcessNodeImpl* const process_node_;
// The URL of the worker script.
const GURL url_;
// A unique identifier shared with all representations of this node across
// content and blink. The token is only defined by the browser process and
// is never sent back from the renderer in control calls.
......
......@@ -47,15 +47,17 @@ TEST_F(WorkerNodeImplDeathTest, SafeDowncast) {
TEST_F(WorkerNodeImplTest, ConstProperties) {
const WorkerNode::WorkerType kWorkerType = WorkerNode::WorkerType::kShared;
auto process = CreateNode<ProcessNodeImpl>();
static const GURL kTestUrl("testurl.com");
static const base::UnguessableToken kTestDevToolsToken =
base::UnguessableToken::Create();
auto worker_impl = CreateNode<WorkerNodeImpl>(kWorkerType, process.get(),
kTestDevToolsToken);
kTestUrl, kTestDevToolsToken);
// Test private interface.
EXPECT_EQ(worker_impl->worker_type(), kWorkerType);
EXPECT_EQ(worker_impl->process_node(), process.get());
EXPECT_EQ(worker_impl->url(), kTestUrl);
EXPECT_EQ(worker_impl->dev_tools_token(), kTestDevToolsToken);
// Test public interface.
......@@ -63,6 +65,7 @@ TEST_F(WorkerNodeImplTest, ConstProperties) {
EXPECT_EQ(worker->GetWorkerType(), kWorkerType);
EXPECT_EQ(worker->GetProcessNode(), process.get());
EXPECT_EQ(worker->GetURL(), kTestUrl);
EXPECT_EQ(worker->GetDevToolsToken(), kTestDevToolsToken);
}
......
......@@ -187,10 +187,11 @@ std::unique_ptr<ProcessNodeImpl> PerformanceManager::CreateProcessNode(
std::unique_ptr<WorkerNodeImpl> PerformanceManager::CreateWorkerNode(
WorkerNode::WorkerType worker_type,
ProcessNodeImpl* process_node,
const GURL& url,
const base::UnguessableToken& dev_tools_token) {
return CreateNodeImpl<WorkerNodeImpl>(
base::OnceCallback<void(WorkerNodeImpl*)>(), worker_type, process_node,
dev_tools_token);
url, dev_tools_token);
}
void PerformanceManager::BatchDeleteNodes(
......
......@@ -24,6 +24,8 @@
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/connector.h"
class GURL;
namespace ukm {
class MojoUkmRecorder;
} // namespace ukm
......@@ -111,6 +113,7 @@ class PerformanceManager {
std::unique_ptr<WorkerNodeImpl> CreateWorkerNode(
WorkerNode::WorkerType worker_type,
ProcessNodeImpl* process_node,
const GURL& url,
const base::UnguessableToken& dev_tools_token);
// Destroys a node returned from the creation functions above.
......
......@@ -9,6 +9,8 @@
#include "base/macros.h"
#include "chrome/browser/performance_manager/public/graph/node.h"
class GURL;
namespace base {
class UnguessableToken;
}
......@@ -63,6 +65,9 @@ class WorkerNode : public Node {
// over the lifetime of the frame.
virtual const ProcessNode* GetProcessNode() const = 0;
// Returns the URL of the worker script.
virtual const GURL& GetURL() const = 0;
// Returns the dev tools token for this worker.
virtual const base::UnguessableToken& GetDevToolsToken() const = 0;
......
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