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

Side by Side Diff: base/trace_event/trace_sampling_thread.cc

Issue 2032603002: Migrate WaitableEvent to enum-based constructor in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: undo incorrect template change Created 4 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 | « base/trace_event/trace_event_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "base/trace_event/trace_event_impl.h" 8 #include "base/trace_event/trace_event_impl.h"
9 #include "base/trace_event/trace_log.h" 9 #include "base/trace_event/trace_log.h"
10 #include "base/trace_event/trace_sampling_thread.h" 10 #include "base/trace_event/trace_sampling_thread.h"
11 11
12 namespace base { 12 namespace base {
13 namespace trace_event { 13 namespace trace_event {
14 14
15 class TraceBucketData { 15 class TraceBucketData {
16 public: 16 public:
17 TraceBucketData(base::subtle::AtomicWord* bucket, 17 TraceBucketData(base::subtle::AtomicWord* bucket,
18 const char* name, 18 const char* name,
19 TraceSampleCallback callback); 19 TraceSampleCallback callback);
20 ~TraceBucketData(); 20 ~TraceBucketData();
21 21
22 TRACE_EVENT_API_ATOMIC_WORD* bucket; 22 TRACE_EVENT_API_ATOMIC_WORD* bucket;
23 const char* bucket_name; 23 const char* bucket_name;
24 TraceSampleCallback callback; 24 TraceSampleCallback callback;
25 }; 25 };
26 26
27 TraceSamplingThread::TraceSamplingThread() 27 TraceSamplingThread::TraceSamplingThread()
28 : thread_running_(false), waitable_event_for_testing_(false, false) {} 28 : thread_running_(false),
29 waitable_event_for_testing_(WaitableEvent::ResetPolicy::AUTOMATIC,
30 WaitableEvent::InitialState::NOT_SIGNALED) {}
29 31
30 TraceSamplingThread::~TraceSamplingThread() {} 32 TraceSamplingThread::~TraceSamplingThread() {}
31 33
32 void TraceSamplingThread::ThreadMain() { 34 void TraceSamplingThread::ThreadMain() {
33 PlatformThread::SetName("Sampling Thread"); 35 PlatformThread::SetName("Sampling Thread");
34 thread_running_ = true; 36 thread_running_ = true;
35 const int kSamplingFrequencyMicroseconds = 1000; 37 const int kSamplingFrequencyMicroseconds = 1000;
36 while (!cancellation_flag_.IsSet()) { 38 while (!cancellation_flag_.IsSet()) {
37 PlatformThread::Sleep( 39 PlatformThread::Sleep(
38 TimeDelta::FromMicroseconds(kSamplingFrequencyMicroseconds)); 40 TimeDelta::FromMicroseconds(kSamplingFrequencyMicroseconds));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 98
97 TraceBucketData::TraceBucketData(base::subtle::AtomicWord* bucket, 99 TraceBucketData::TraceBucketData(base::subtle::AtomicWord* bucket,
98 const char* name, 100 const char* name,
99 TraceSampleCallback callback) 101 TraceSampleCallback callback)
100 : bucket(bucket), bucket_name(name), callback(callback) {} 102 : bucket(bucket), bucket_name(name), callback(callback) {}
101 103
102 TraceBucketData::~TraceBucketData() {} 104 TraceBucketData::~TraceBucketData() {}
103 105
104 } // namespace trace_event 106 } // namespace trace_event
105 } // namespace base 107 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698