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

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

Issue 1546033002: Switch to standard integer types in base/trace_event/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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_log.h ('k') | base/trace_event/trace_sampling_thread.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 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 "base/trace_event/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/base_switches.h" 11 #include "base/base_switches.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/leak_annotations.h" 14 #include "base/debug/leak_annotations.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/macros.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/singleton.h" 19 #include "base/memory/singleton.h"
19 #include "base/process/process_metrics.h" 20 #include "base/process/process_metrics.h"
20 #include "base/stl_util.h" 21 #include "base/stl_util.h"
21 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
22 #include "base/strings/string_tokenizer.h" 23 #include "base/strings/string_tokenizer.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "base/sys_info.h" 25 #include "base/sys_info.h"
25 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
26 #include "base/thread_task_runner_handle.h" 27 #include "base/thread_task_runner_handle.h"
27 #include "base/threading/platform_thread.h" 28 #include "base/threading/platform_thread.h"
28 #include "base/threading/thread_id_name_manager.h" 29 #include "base/threading/thread_id_name_manager.h"
29 #include "base/threading/worker_pool.h" 30 #include "base/threading/worker_pool.h"
30 #include "base/time/time.h" 31 #include "base/time/time.h"
31 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 32 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
32 #include "base/trace_event/memory_dump_manager.h" 33 #include "base/trace_event/memory_dump_manager.h"
33 #include "base/trace_event/memory_dump_provider.h" 34 #include "base/trace_event/memory_dump_provider.h"
34 #include "base/trace_event/process_memory_dump.h" 35 #include "base/trace_event/process_memory_dump.h"
35 #include "base/trace_event/trace_buffer.h" 36 #include "base/trace_event/trace_buffer.h"
36 #include "base/trace_event/trace_event.h" 37 #include "base/trace_event/trace_event.h"
37 #include "base/trace_event/trace_event_synthetic_delay.h" 38 #include "base/trace_event/trace_event_synthetic_delay.h"
38 #include "base/trace_event/trace_sampling_thread.h" 39 #include "base/trace_event/trace_sampling_thread.h"
40 #include "build/build_config.h"
39 41
40 #if defined(OS_WIN) 42 #if defined(OS_WIN)
41 #include "base/trace_event/trace_event_etw_export_win.h" 43 #include "base/trace_event/trace_event_etw_export_win.h"
42 #endif 44 #endif
43 45
44 // The thread buckets for the sampling profiler. 46 // The thread buckets for the sampling profiler.
45 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; 47 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
46 48
47 namespace base { 49 namespace base {
48 namespace internal { 50 namespace internal {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 159 }
158 ~AutoThreadLocalBoolean() { thread_local_boolean_->Set(false); } 160 ~AutoThreadLocalBoolean() { thread_local_boolean_->Set(false); }
159 161
160 private: 162 private:
161 ThreadLocalBoolean* thread_local_boolean_; 163 ThreadLocalBoolean* thread_local_boolean_;
162 DISALLOW_COPY_AND_ASSIGN(AutoThreadLocalBoolean); 164 DISALLOW_COPY_AND_ASSIGN(AutoThreadLocalBoolean);
163 }; 165 };
164 166
165 // Use this function instead of TraceEventHandle constructor to keep the 167 // Use this function instead of TraceEventHandle constructor to keep the
166 // overhead of ScopedTracer (trace_event.h) constructor minimum. 168 // overhead of ScopedTracer (trace_event.h) constructor minimum.
167 void MakeHandle(uint32 chunk_seq, 169 void MakeHandle(uint32_t chunk_seq,
168 size_t chunk_index, 170 size_t chunk_index,
169 size_t event_index, 171 size_t event_index,
170 TraceEventHandle* handle) { 172 TraceEventHandle* handle) {
171 DCHECK(chunk_seq); 173 DCHECK(chunk_seq);
172 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); 174 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex);
173 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); 175 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize);
174 handle->chunk_seq = chunk_seq; 176 handle->chunk_seq = chunk_seq;
175 handle->chunk_index = static_cast<uint16>(chunk_index); 177 handle->chunk_index = static_cast<uint16_t>(chunk_index);
176 handle->event_index = static_cast<uint16>(event_index); 178 handle->event_index = static_cast<uint16_t>(event_index);
177 } 179 }
178 180
179 } // namespace 181 } // namespace
180 182
181 // A helper class that allows the lock to be acquired in the middle of the scope 183 // A helper class that allows the lock to be acquired in the middle of the scope
182 // and unlocks at the end of scope if locked. 184 // and unlocks at the end of scope if locked.
183 class TraceLog::OptionalAutoLock { 185 class TraceLog::OptionalAutoLock {
184 public: 186 public:
185 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} 187 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {}
186 188
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (!tokens.GetNext()) 486 if (!tokens.GetNext())
485 continue; 487 continue;
486 TraceEventSyntheticDelay* delay = 488 TraceEventSyntheticDelay* delay =
487 TraceEventSyntheticDelay::Lookup(tokens.token()); 489 TraceEventSyntheticDelay::Lookup(tokens.token());
488 while (tokens.GetNext()) { 490 while (tokens.GetNext()) {
489 std::string token = tokens.token(); 491 std::string token = tokens.token();
490 char* duration_end; 492 char* duration_end;
491 double target_duration = strtod(token.c_str(), &duration_end); 493 double target_duration = strtod(token.c_str(), &duration_end);
492 if (duration_end != token.c_str()) { 494 if (duration_end != token.c_str()) {
493 delay->SetTargetDuration(TimeDelta::FromMicroseconds( 495 delay->SetTargetDuration(TimeDelta::FromMicroseconds(
494 static_cast<int64>(target_duration * 1e6))); 496 static_cast<int64_t>(target_duration * 1e6)));
495 } else if (token == "static") { 497 } else if (token == "static") {
496 delay->SetMode(TraceEventSyntheticDelay::STATIC); 498 delay->SetMode(TraceEventSyntheticDelay::STATIC);
497 } else if (token == "oneshot") { 499 } else if (token == "oneshot") {
498 delay->SetMode(TraceEventSyntheticDelay::ONE_SHOT); 500 delay->SetMode(TraceEventSyntheticDelay::ONE_SHOT);
499 } else if (token == "alternating") { 501 } else if (token == "alternating") {
500 delay->SetMode(TraceEventSyntheticDelay::ALTERNATING); 502 delay->SetMode(TraceEventSyntheticDelay::ALTERNATING);
501 } 503 }
502 } 504 }
503 } 505 }
504 } 506 }
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 watch_event_callback_ = callback; 1484 watch_event_callback_ = callback;
1483 } 1485 }
1484 1486
1485 void TraceLog::CancelWatchEvent() { 1487 void TraceLog::CancelWatchEvent() {
1486 AutoLock lock(lock_); 1488 AutoLock lock(lock_);
1487 subtle::NoBarrier_Store(&watch_category_, 0); 1489 subtle::NoBarrier_Store(&watch_category_, 0);
1488 watch_event_name_ = ""; 1490 watch_event_name_ = "";
1489 watch_event_callback_.Reset(); 1491 watch_event_callback_.Reset();
1490 } 1492 }
1491 1493
1492 uint64 TraceLog::MangleEventId(uint64 id) { 1494 uint64_t TraceLog::MangleEventId(uint64_t id) {
1493 return id ^ process_id_hash_; 1495 return id ^ process_id_hash_;
1494 } 1496 }
1495 1497
1496 void TraceLog::AddMetadataEventsWhileLocked() { 1498 void TraceLog::AddMetadataEventsWhileLocked() {
1497 lock_.AssertAcquired(); 1499 lock_.AssertAcquired();
1498 1500
1499 // Copy metadata added by |AddMetadataEvent| into the trace log. 1501 // Copy metadata added by |AddMetadataEvent| into the trace log.
1500 for (const scoped_ptr<TraceEvent>& event : metadata_events_) 1502 for (const scoped_ptr<TraceEvent>& event : metadata_events_)
1501 AddEventToThreadSharedChunkWhileLocked(nullptr, false)->CopyFrom(*event); 1503 AddEventToThreadSharedChunkWhileLocked(nullptr, false)->CopyFrom(*event);
1502 1504
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 } 1738 }
1737 1739
1738 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1740 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1739 if (*category_group_enabled_) { 1741 if (*category_group_enabled_) {
1740 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1742 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1741 event_handle_); 1743 event_handle_);
1742 } 1744 }
1743 } 1745 }
1744 1746
1745 } // namespace trace_event_internal 1747 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/trace_log.h ('k') | base/trace_event/trace_sampling_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698