Commit f88d7835 authored by Kai Ninomiya's avatar Kai Ninomiya Committed by Commit Bot

Move dedicated worker MojoUkmRecorder creation to worker thread

Bug: 881144
Change-Id: Idc5292cecf9a3d4dbc101a9c44c47bd3db62dab6
Reviewed-on: https://chromium-review.googlesource.com/1208941Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590088}
parent 593f022c
...@@ -392,6 +392,7 @@ void Connector::WaitToReadMore() { ...@@ -392,6 +392,7 @@ void Connector::WaitToReadMore() {
CHECK(!paused_); CHECK(!paused_);
DCHECK(!handle_watcher_); DCHECK(!handle_watcher_);
DCHECK(task_runner_->RunsTasksInCurrentSequence());
handle_watcher_.reset(new SimpleWatcher( handle_watcher_.reset(new SimpleWatcher(
FROM_HERE, SimpleWatcher::ArmingPolicy::MANUAL, task_runner_)); FROM_HERE, SimpleWatcher::ArmingPolicy::MANUAL, task_runner_));
handle_watcher_->set_heap_profiler_tag(heap_profiler_tag_); handle_watcher_->set_heap_profiler_tag(heap_profiler_tag_);
......
...@@ -80,6 +80,7 @@ bool InterfacePtrStateBase::InitializeEndpointClient( ...@@ -80,6 +80,7 @@ bool InterfacePtrStateBase::InitializeEndpointClient(
: (has_sync_methods : (has_sync_methods
? MultiplexRouter::SINGLE_INTERFACE_WITH_SYNC_METHODS ? MultiplexRouter::SINGLE_INTERFACE_WITH_SYNC_METHODS
: MultiplexRouter::SINGLE_INTERFACE); : MultiplexRouter::SINGLE_INTERFACE);
DCHECK(runner_->RunsTasksInCurrentSequence());
router_ = new MultiplexRouter(std::move(handle_), config, true, runner_); router_ = new MultiplexRouter(std::move(handle_), config, true, runner_);
endpoint_client_.reset(new InterfaceEndpointClient( endpoint_client_.reset(new InterfaceEndpointClient(
router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr, router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_proxy.h" #include "third_party/blink/renderer/platform/scheduler/worker/worker_scheduler_proxy.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.h" #include "third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.h"
#include "third_party/blink/renderer/platform/scheduler/public/worker_scheduler.h" #include "third_party/blink/renderer/platform/scheduler/public/worker_scheduler.h"
...@@ -22,8 +21,10 @@ WorkerSchedulerProxy::WorkerSchedulerProxy(FrameOrWorkerScheduler* scheduler) { ...@@ -22,8 +21,10 @@ WorkerSchedulerProxy::WorkerSchedulerProxy(FrameOrWorkerScheduler* scheduler) {
initial_frame_status_ = GetFrameStatus(frame_scheduler); initial_frame_status_ = GetFrameStatus(frame_scheduler);
ukm_source_id_ = frame_scheduler->GetUkmSourceId(); ukm_source_id_ = frame_scheduler->GetUkmSourceId();
if (ukm_source_id_ != ukm::kInvalidSourceId) { if (ukm_source_id_ != ukm::kInvalidSourceId) {
ukm_recorder_ = // The connector must be cloned because it belongs to the main thread,
ukm::MojoUkmRecorder::Create(Platform::Current()->GetConnector()); // but we intend to acquire and use it from the worker thread. (It must
// be cloned on the original owning thread, not the destination thread.)
connector_ = Platform::Current()->GetConnector()->Clone();
} }
} }
} }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/service_manager/public/cpp/connector.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/scheduler/main_thread/frame_origin_type.h" #include "third_party/blink/renderer/platform/scheduler/main_thread/frame_origin_type.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_or_worker_scheduler.h" #include "third_party/blink/renderer/platform/scheduler/public/frame_or_worker_scheduler.h"
...@@ -62,13 +62,13 @@ class PLATFORM_EXPORT WorkerSchedulerProxy ...@@ -62,13 +62,13 @@ class PLATFORM_EXPORT WorkerSchedulerProxy
} }
// Accessed only during init. // Accessed only during init.
std::unique_ptr<ukm::UkmRecorder> TakeUkmRecorder() { std::unique_ptr<service_manager::Connector> TakeConnector() {
DCHECK(!initialized_); DCHECK(!initialized_);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(!ukm_recorder_taken_); DCHECK(!connector_taken_);
ukm_recorder_taken_ = true; connector_taken_ = true;
#endif #endif
return std::move(ukm_recorder_); return std::move(connector_);
} }
// Accessed only during init. // Accessed only during init.
...@@ -94,10 +94,10 @@ class PLATFORM_EXPORT WorkerSchedulerProxy ...@@ -94,10 +94,10 @@ class PLATFORM_EXPORT WorkerSchedulerProxy
base::Optional<FrameOriginType> parent_frame_type_; base::Optional<FrameOriginType> parent_frame_type_;
FrameStatus initial_frame_status_ = FrameStatus::kNone; FrameStatus initial_frame_status_ = FrameStatus::kNone;
ukm::SourceId ukm_source_id_ = ukm::kInvalidSourceId; ukm::SourceId ukm_source_id_ = ukm::kInvalidSourceId;
std::unique_ptr<ukm::UkmRecorder> ukm_recorder_; std::unique_ptr<service_manager::Connector> connector_;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
bool ukm_recorder_taken_ = false; bool connector_taken_ = false;
#endif #endif
THREAD_CHECKER(parent_thread_checker_); THREAD_CHECKER(parent_thread_checker_);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h" #include "base/trace_event/trace_event_argument.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/renderer/platform/histogram.h" #include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/scheduler/child/features.h" #include "third_party/blink/renderer/platform/scheduler/child/features.h"
...@@ -117,7 +118,10 @@ WorkerThreadScheduler::WorkerThreadScheduler( ...@@ -117,7 +118,10 @@ WorkerThreadScheduler::WorkerThreadScheduler(
initial_frame_status_(proxy ? proxy->initial_frame_status() initial_frame_status_(proxy ? proxy->initial_frame_status()
: FrameStatus::kNone), : FrameStatus::kNone),
ukm_source_id_(proxy ? proxy->ukm_source_id() : ukm::kInvalidSourceId), ukm_source_id_(proxy ? proxy->ukm_source_id() : ukm::kInvalidSourceId),
ukm_recorder_(proxy ? proxy->TakeUkmRecorder() : nullptr) { connector_(proxy ? proxy->TakeConnector() : nullptr) {
if (connector_) {
ukm_recorder_ = ukm::MojoUkmRecorder::Create(connector_.get());
}
thread_start_time_ = helper()->NowTicks(); thread_start_time_ = helper()->NowTicks();
load_tracker_.Resume(thread_start_time_); load_tracker_.Resume(thread_start_time_);
helper()->AddTaskTimeObserver(this); helper()->AddTaskTimeObserver(this);
......
...@@ -25,6 +25,10 @@ class SequenceManager; ...@@ -25,6 +25,10 @@ class SequenceManager;
} }
} // namespace base } // namespace base
namespace service_manager {
class Connector;
}
namespace ukm { namespace ukm {
class UkmRecorder; class UkmRecorder;
} }
...@@ -160,6 +164,7 @@ class PLATFORM_EXPORT WorkerThreadScheduler ...@@ -160,6 +164,7 @@ class PLATFORM_EXPORT WorkerThreadScheduler
const FrameStatus initial_frame_status_; const FrameStatus initial_frame_status_;
const ukm::SourceId ukm_source_id_; const ukm::SourceId ukm_source_id_;
std::unique_ptr<service_manager::Connector> connector_;
std::unique_ptr<ukm::UkmRecorder> ukm_recorder_; std::unique_ptr<ukm::UkmRecorder> ukm_recorder_;
DISALLOW_COPY_AND_ASSIGN(WorkerThreadScheduler); DISALLOW_COPY_AND_ASSIGN(WorkerThreadScheduler);
......
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