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

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

Issue 2912843002: Replace deprecated base::NonThreadSafe in chrome/browser/metrics/perf in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/metrics/perf/perf_provider_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PERF_PROVIDER_CHROMEOS_H_ 5 #ifndef CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_
6 #define CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ 6 #define CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/sequence_checker.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "chrome/browser/metrics/perf/cpu_identity.h" 17 #include "chrome/browser/metrics/perf/cpu_identity.h"
18 #include "chrome/browser/metrics/perf/perf_output.h" 18 #include "chrome/browser/metrics/perf/perf_output.h"
19 #include "chrome/browser/metrics/perf/random_selector.h" 19 #include "chrome/browser/metrics/perf/random_selector.h"
20 #include "chrome/browser/sessions/session_restore.h" 20 #include "chrome/browser/sessions/session_restore.h"
21 #include "chromeos/dbus/power_manager_client.h" 21 #include "chromeos/dbus/power_manager_client.h"
22 #include "chromeos/login/login_state.h" 22 #include "chromeos/login/login_state.h"
23 #include "components/metrics/proto/sampled_profile.pb.h" 23 #include "components/metrics/proto/sampled_profile.pb.h"
24 24
25 namespace metrics { 25 namespace metrics {
26 26
27 class WindowedIncognitoObserver; 27 class WindowedIncognitoObserver;
28 28
29 // Provides access to ChromeOS perf data. perf aka "perf events" is a 29 // Provides access to ChromeOS perf data. perf aka "perf events" is a
30 // performance profiling infrastructure built into the linux kernel. For more 30 // performance profiling infrastructure built into the linux kernel. For more
31 // information, see: https://perf.wiki.kernel.org/index.php/Main_Page. 31 // information, see: https://perf.wiki.kernel.org/index.php/Main_Page.
32 class PerfProvider : public base::NonThreadSafe, 32 class PerfProvider : public chromeos::PowerManagerClient::Observer {
33 public chromeos::PowerManagerClient::Observer {
34 public: 33 public:
35 PerfProvider(); 34 PerfProvider();
36 ~PerfProvider() override; 35 ~PerfProvider() override;
37 36
38 void Init(); 37 void Init();
39 38
40 // Stores collected perf data protobufs in |sampled_profiles|. Clears all the 39 // Stores collected perf data protobufs in |sampled_profiles|. Clears all the
41 // stored profile data. Returns true if it wrote to |sampled_profiles|. 40 // stored profile data. Returns true if it wrote to |sampled_profiles|.
42 bool GetSampledProfiles(std::vector<SampledProfile>* sampled_profiles); 41 bool GetSampledProfiles(std::vector<SampledProfile>* sampled_profiles);
43 42
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 base::TimeTicks last_session_restore_collection_time_; 247 base::TimeTicks last_session_restore_collection_time_;
249 248
250 // Points to the on-session-restored callback that was registered with 249 // Points to the on-session-restored callback that was registered with
251 // SessionRestore's callback list. When objects of this class are destroyed, 250 // SessionRestore's callback list. When objects of this class are destroyed,
252 // the subscription object's destructor will automatically unregister the 251 // the subscription object's destructor will automatically unregister the
253 // callback in SessionRestore, so that the callback list does not contain any 252 // callback in SessionRestore, so that the callback list does not contain any
254 // obsolete callbacks. 253 // obsolete callbacks.
255 SessionRestore::CallbackSubscription 254 SessionRestore::CallbackSubscription
256 on_session_restored_callback_subscription_; 255 on_session_restored_callback_subscription_;
257 256
257 SEQUENCE_CHECKER(sequence_checker_);
258
258 // To pass around the "this" pointer across threads safely. 259 // To pass around the "this" pointer across threads safely.
259 base::WeakPtrFactory<PerfProvider> weak_factory_; 260 base::WeakPtrFactory<PerfProvider> weak_factory_;
260 261
261 DISALLOW_COPY_AND_ASSIGN(PerfProvider); 262 DISALLOW_COPY_AND_ASSIGN(PerfProvider);
262 }; 263 };
263 264
264 // Exposed for unit testing. 265 // Exposed for unit testing.
265 namespace internal { 266 namespace internal {
266 267
267 // Return the default set of perf commands and their odds of selection given 268 // Return the default set of perf commands and their odds of selection given
268 // the identity of the CPU in |cpuid|. 269 // the identity of the CPU in |cpuid|.
269 std::vector<RandomSelector::WeightAndValue> GetDefaultCommandsForCpu( 270 std::vector<RandomSelector::WeightAndValue> GetDefaultCommandsForCpu(
270 const CPUIdentity& cpuid); 271 const CPUIdentity& cpuid);
271 272
272 // For the "PerfCommand::"-prefixed keys in |params|, return the cpu specifier 273 // For the "PerfCommand::"-prefixed keys in |params|, return the cpu specifier
273 // that is the narrowest match for the CPU identified by |cpuid|. 274 // that is the narrowest match for the CPU identified by |cpuid|.
274 // Valid CPU specifiers, in increasing order of specificity, are: 275 // Valid CPU specifiers, in increasing order of specificity, are:
275 // "default", a system architecture (e.g. "x86_64"), a CPU microarchitecture 276 // "default", a system architecture (e.g. "x86_64"), a CPU microarchitecture
276 // (currently only Intel uarchs supported), or a CPU model name substring. 277 // (currently only Intel uarchs supported), or a CPU model name substring.
277 std::string FindBestCpuSpecifierFromParams( 278 std::string FindBestCpuSpecifierFromParams(
278 const std::map<std::string, std::string>& params, 279 const std::map<std::string, std::string>& params,
279 const CPUIdentity& cpuid); 280 const CPUIdentity& cpuid);
280 281
281 } // namespace internal 282 } // namespace internal
282 283
283 } // namespace metrics 284 } // namespace metrics
284 285
285 #endif // CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_ 286 #endif // CHROME_BROWSER_METRICS_PERF_PERF_PROVIDER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/perf/perf_provider_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698