summaryrefslogtreecommitdiffstats
path: root/base/test/trace_to_file.h
blob: 43087367c3086a245ab507d213f831b771fe0fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2014 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 BASE_TEST_TRACE_TO_FILE_H_
#define BASE_TEST_TRACE_TO_FILE_H_

#include "base/files/file_path.h"

namespace base {
namespace test {

class TraceToFile {
 public:
  TraceToFile();
  ~TraceToFile();

  void BeginTracingFromCommandLineOptions();
  void BeginTracing(const base::FilePath& path, const std::string& categories);
  void EndTracingIfNeeded();

 private:
  void WriteFileHeader();
  void AppendFileFooter();

  void TraceOutputCallback(const std::string& data);

  base::FilePath path_;
  bool started_;
};

}  // namespace test
}  // namespace base

#endif  // BASE_TEST_TRACE_TO_FILE_H_