Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / metrics / perf_provider_chromeos.h
blob28227107830e6215be58cb763456962a3172550b
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_
6 #define CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
15 #include "components/metrics/proto/perf_data.pb.h"
17 namespace metrics {
19 class WindowedIncognitoObserver;
21 // Provides access to ChromeOS perf data. perf aka "perf events" is a
22 // performance profiling infrastructure built into the linux kernel. For more
23 // information, see: https://perf.wiki.kernel.org/index.php/Main_Page.
24 class PerfProvider : public base::NonThreadSafe {
25 public:
26 PerfProvider();
27 ~PerfProvider();
29 // Writes collected perf data protobufs to |perf_data|. Clears all the stored
30 // perf data. Returns true if it wrote to |perf_data|.
31 bool GetPerfData(std::vector<PerfDataProto>* perf_data);
33 private:
34 // Starts an internal timer to start collecting perf data. The timer is set to
35 // trigger |interval| after this function call.
36 void ScheduleCollection(const base::TimeDelta& interval);
38 // Collects perf data if it has not been consumed by calling GetPerfData()
39 // (see above).
40 void CollectIfNecessary();
42 // Collects perf data by calling CollectIfNecessary() and reschedules it to be
43 // collected again.
44 void CollectIfNecessaryAndReschedule();
46 // Parses a protobuf from the |data| passed in only if the
47 // |incognito_observer| indicates that no incognito window had been opened
48 // during the profile collection period.
49 void ParseProtoIfValid(
50 scoped_ptr<WindowedIncognitoObserver> incognito_observer,
51 const std::vector<uint8>& data);
53 // Vector of perf data protobufs.
54 std::vector<PerfDataProto> cached_perf_data_;
56 // For scheduling collection of perf data.
57 base::OneShotTimer<PerfProvider> timer_;
59 // To pass around the "this" pointer across threads safely.
60 base::WeakPtrFactory<PerfProvider> weak_factory_;
62 DISALLOW_COPY_AND_ASSIGN(PerfProvider);
65 } // namespace metrics
67 #endif // CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_