| Index: chrome/browser/chromeos/arc/trace/arc_trace_reader.h
|
| diff --git a/chrome/browser/chromeos/arc/trace/arc_trace_reader.h b/chrome/browser/chromeos/arc/trace/arc_trace_reader.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c598cc67adc4a862ea252f276e484d2757bcd408
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/arc/trace/arc_trace_reader.h
|
| @@ -0,0 +1,64 @@
|
| +// 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 CHROME_BROWSER_CHROMEOS_ARC_TRACE_ARC_TRACE_READER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_ARC_TRACE_ARC_TRACE_READER_H_
|
| +
|
| +#include <inttypes.h>
|
| +
|
| +#include <memory>
|
| +#include <queue>
|
| +#include <string>
|
| +
|
| +#include "base/files/scoped_file.h"
|
| +#include "base/macros.h"
|
| +#include "base/threading/simple_thread.h"
|
| +#include "chromeos/trace/arc_trace_agent.h"
|
| +
|
| +namespace arc {
|
| +
|
| +// The class is for reading ARC trace data from the given socket FD, transform
|
| +// data into the JSON format, and store it in a circular buffer.
|
| +class ArcTraceReader : public base::DelegateSimpleThread::Delegate {
|
| + public:
|
| + using StopTracingCallback =
|
| + chromeos::ArcTraceAgent::Delegate::StopTracingCallback;
|
| +
|
| + ArcTraceReader();
|
| +
|
| + // Sets the input socket FD for reading ARC trace data.
|
| + void SetInputFD(base::ScopedFD fd);
|
| +
|
| + void StartRecord();
|
| +
|
| + void StopRecord(const StopTracingCallback& callback);
|
| +
|
| + // DelegateSimpleThread::Delegate overrides:
|
| + void Run() override;
|
| +
|
| + private:
|
| + void WriteTraceEvent(char ph,
|
| + int pid,
|
| + int tid,
|
| + uint64_t ts,
|
| + uint64_t tts,
|
| + const std::string* name = nullptr,
|
| + const int* count = nullptr,
|
| + const int* id = nullptr);
|
| +
|
| + void ParseAndSaveData(std::string data);
|
| +
|
| + bool is_recording_;
|
| + std::queue<std::string> trace_buffer_;
|
| + int current_data_size_;
|
| + base::ScopedFD input_fd_;
|
| + // Thread used for reading data from the input socket.
|
| + std::unique_ptr<base::SimpleThread> recording_thread_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ArcTraceReader);
|
| +};
|
| +
|
| +} // namespace arc
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_TRACE_ARC_TRACE_READER_H_
|
|
|