| Index: services/resource_coordinator/tracing/coordinator_impl.h
|
| diff --git a/services/resource_coordinator/tracing/coordinator_impl.h b/services/resource_coordinator/tracing/coordinator_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..59cf7b4d295dabc858cbbe47d28d880cf9bb5e16
|
| --- /dev/null
|
| +++ b/services/resource_coordinator/tracing/coordinator_impl.h
|
| @@ -0,0 +1,80 @@
|
| +// Copyright 2017 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 SERVICES_RESOURCE_COORDINATOR_TRACING_COORDINATOR_IMPL_H_
|
| +#define SERVICES_RESOURCE_COORDINATOR_TRACING_COORDINATOR_IMPL_H_
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/sequenced_task_runner.h"
|
| +#include "mojo/public/cpp/system/data_pipe.h"
|
| +#include "services/resource_coordinator/public/interfaces/tracing/tracing.mojom.h"
|
| +#include "services/resource_coordinator/tracing/agent_set_impl.h"
|
| +#include "services/resource_coordinator/tracing/recorder_impl.h"
|
| +
|
| +namespace resource_coordinator {
|
| +namespace tracing {
|
| +
|
| +class CoordinatorImpl : public mojom::Coordinator {
|
| + public:
|
| + // The getter of the unique instance.
|
| + static CoordinatorImpl* GetInstance();
|
| +
|
| + CoordinatorImpl();
|
| +
|
| + void BindCoordinatorRequest(mojom::CoordinatorRequest request);
|
| + AgentSetImpl* agent_set() { return agent_set_.get(); }
|
| +
|
| + private:
|
| + friend std::default_delete<CoordinatorImpl>;
|
| + friend class Service;
|
| +
|
| + ~CoordinatorImpl() override;
|
| +
|
| + // mojom::Coordinator
|
| + void IsTracing(const IsTracingCallback& callback) override;
|
| + void GetCategories(const GetCategoriesCallback& callback) override;
|
| + void RequestBufferUsage(const RequestBufferUsageCallback& callback) override;
|
| + void StartTracing(mojo::ScopedDataPipeProducerHandle stream,
|
| + const std::string& config) override;
|
| + void StopAndFlush() override;
|
| +
|
| + bool IsTracing();
|
| +
|
| + void SendStartTracingToAgent(AgentSetImpl::Entry* entry);
|
| + void OnRecorderUpdated(const std::string& label);
|
| + bool ReadFromRecorders();
|
| + void OnFlushDone();
|
| + void OnRequestBufferStatusResponse(AgentSetImpl::Entry* entry,
|
| + uint32_t capacity,
|
| + uint32_t count);
|
| +
|
| + // Type of closures that may be run when an agent connection is closed.
|
| + static const char kRequestBufferUsageType[];
|
| +
|
| + mojo::Binding<mojom::Coordinator> binding_;
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| + scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
|
| + std::unique_ptr<AgentSetImpl> agent_set_;
|
| + std::string config_;
|
| + mojo::ScopedDataPipeProducerHandle stream_;
|
| + std::unordered_map<std::string, std::set<std::unique_ptr<RecorderImpl>>>
|
| + recorders_;
|
| + std::string recording_label_;
|
| + bool first_recorder_update_;
|
| + bool write_label_;
|
| +
|
| + // For computing trace buffer usage.
|
| + float maximum_trace_buffer_usage_;
|
| + uint32_t approximate_event_count_;
|
| + size_t pending_request_buffer_status_count_;
|
| + RequestBufferUsageCallback request_buffer_usage_callback_;
|
| +
|
| + GetCategoriesCallback get_categories_callback_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
|
| +};
|
| +
|
| +} // namespace tracing
|
| +} // namespace resource_coordinator
|
| +#endif // SERVICES_RESOURCE_COORDINATOR_TRACING_COORDINATOR_IMPL_H_
|
|
|