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

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

Issue 2421743003: Fix race in TraceLog::AddEventWithTimestamp (Closed)
Patch Set: Remove extra changes. Created 4 years, 2 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 | 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 "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 <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 if ((flags & TRACE_EVENT_FLAG_FLOW_IN) || 1361 if ((flags & TRACE_EVENT_FLAG_FLOW_IN) ||
1362 (flags & TRACE_EVENT_FLAG_FLOW_OUT)) 1362 (flags & TRACE_EVENT_FLAG_FLOW_OUT))
1363 bind_id = MangleEventId(bind_id); 1363 bind_id = MangleEventId(bind_id);
1364 id = MangleEventId(id); 1364 id = MangleEventId(id);
1365 } 1365 }
1366 1366
1367 TimeTicks offset_event_timestamp = OffsetTimestamp(timestamp); 1367 TimeTicks offset_event_timestamp = OffsetTimestamp(timestamp);
1368 ThreadTicks thread_now = ThreadNow(); 1368 ThreadTicks thread_now = ThreadNow();
1369 1369
1370 ThreadLocalEventBuffer* thread_local_event_buffer = nullptr; 1370 ThreadLocalEventBuffer* thread_local_event_buffer = nullptr;
1371 if (enabled_modes_ & RECORDING_MODE) { 1371 if (*category_group_enabled & RECORDING_MODE) {
1372 // |thread_local_event_buffer_| can be null if the current thread doesn't 1372 // |thread_local_event_buffer_| can be null if the current thread doesn't
1373 // have a message loop or the message loop is blocked. 1373 // have a message loop or the message loop is blocked.
1374 InitializeThreadLocalEventBufferIfSupported(); 1374 InitializeThreadLocalEventBufferIfSupported();
1375 thread_local_event_buffer = thread_local_event_buffer_.Get(); 1375 thread_local_event_buffer = thread_local_event_buffer_.Get();
1376 } 1376 }
1377 1377
1378 // Check and update the current thread name only if the event is for the 1378 // Check and update the current thread name only if the event is for the
1379 // current thread to avoid locks in most cases. 1379 // current thread to avoid locks in most cases.
1380 if (thread_id == static_cast<int>(PlatformThread::CurrentId())) { 1380 if (thread_id == static_cast<int>(PlatformThread::CurrentId())) {
1381 const char* new_name = 1381 const char* new_name =
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 } 1928 }
1929 1929
1930 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1930 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1931 if (*category_group_enabled_) { 1931 if (*category_group_enabled_) {
1932 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1932 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1933 event_handle_); 1933 event_handle_);
1934 } 1934 }
1935 } 1935 }
1936 1936
1937 } // namespace trace_event_internal 1937 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698