Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/browser/metrics/perf_provider_chromeos.h

Issue 282093011: metrics: Use absolute interval-based perf collection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_ 5 #ifndef CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_
6 #define CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_ 6 #define CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "components/metrics/proto/perf_data.pb.h" 15 #include "components/metrics/proto/sampled_profile.pb.h"
16 16
17 namespace metrics { 17 namespace metrics {
18 18
19 class WindowedIncognitoObserver; 19 class WindowedIncognitoObserver;
20 20
21 // Provides access to ChromeOS perf data. perf aka "perf events" is a 21 // Provides access to ChromeOS perf data. perf aka "perf events" is a
22 // performance profiling infrastructure built into the linux kernel. For more 22 // performance profiling infrastructure built into the linux kernel. For more
23 // information, see: https://perf.wiki.kernel.org/index.php/Main_Page. 23 // information, see: https://perf.wiki.kernel.org/index.php/Main_Page.
24 class PerfProvider : public base::NonThreadSafe { 24 class PerfProvider : public base::NonThreadSafe {
25 public: 25 public:
26 PerfProvider(); 26 PerfProvider();
27 ~PerfProvider(); 27 ~PerfProvider();
28 28
29 // Writes collected perf data protobufs to |perf_data|. Clears all the stored 29 // Writes collected perf data protobufs to |perf_data|. Clears all the stored
30 // perf data. Returns true if it wrote to |perf_data|. 30 // perf data. Returns true if it wrote to |perf_data|.
31 bool GetPerfData(std::vector<PerfDataProto>* perf_data); 31 bool GetPerfData(std::vector<SampledProfile>* perf_data);
32 32
33 private: 33 private:
34 // Starts an internal timer to start collecting perf data. The timer is set to 34 // Starts an internal timer to start collecting perf data. The timer is set to
35 // trigger |interval| after this function call. 35 // trigger at a random point in either the current or the next profiling
36 void ScheduleCollection(const base::TimeDelta& interval); 36 // interval.
37 void ScheduleCollection();
37 38
38 // Collects perf data if it has not been consumed by calling GetPerfData() 39 // Collects perf data if it has not been consumed by calling GetPerfData()
39 // (see above). 40 // (see above).
40 void CollectIfNecessary(); 41 void CollectIfNecessary();
41 42
42 // Collects perf data by calling CollectIfNecessary() and reschedules it to be 43 // Collects perf data by calling CollectIfNecessary() and reschedules it to be
43 // collected again. 44 // collected again.
44 void CollectIfNecessaryAndReschedule(); 45 void CollectIfNecessaryAndReschedule();
45 46
46 // Parses a protobuf from the |data| passed in only if the 47 // Parses a protobuf from the |data| passed in only if the
47 // |incognito_observer| indicates that no incognito window had been opened 48 // |incognito_observer| indicates that no incognito window had been opened
48 // during the profile collection period. 49 // during the profile collection period.
49 void ParseProtoIfValid( 50 void ParseProtoIfValid(
50 scoped_ptr<WindowedIncognitoObserver> incognito_observer, 51 scoped_ptr<WindowedIncognitoObserver> incognito_observer,
51 const std::vector<uint8>& data); 52 const std::vector<uint8>& data);
52 53
53 // Vector of perf data protobufs. 54 // Vector of SampledProfile protobufs containing perf profiles.
54 std::vector<PerfDataProto> cached_perf_data_; 55 std::vector<SampledProfile> cached_perf_data_;
55 56
56 // For scheduling collection of perf data. 57 // For scheduling collection of perf data.
57 base::OneShotTimer<PerfProvider> timer_; 58 base::OneShotTimer<PerfProvider> timer_;
58 59
59 // To pass around the "this" pointer across threads safely. 60 // To pass around the "this" pointer across threads safely.
60 base::WeakPtrFactory<PerfProvider> weak_factory_; 61 base::WeakPtrFactory<PerfProvider> weak_factory_;
61 62
63 // Record of the last login time.
64 base::Time login_time_;
Ilya Sherman 2014/05/16 21:48:57 Did you mean TimeTicks?
Simon Que 2014/05/17 03:25:07 Done.
65
62 DISALLOW_COPY_AND_ASSIGN(PerfProvider); 66 DISALLOW_COPY_AND_ASSIGN(PerfProvider);
63 }; 67 };
64 68
65 } // namespace metrics 69 } // namespace metrics
66 70
67 #endif // CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_ 71 #endif // CHROME_BROWSER_METRICS_PERF_PROVIDER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698