OLD | NEW |
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 #include "base/debug/trace_event_impl.h" | 5 #include "base/debug/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // accessing the enabled flag. We don't care whether edge-case events are | 328 // accessing the enabled flag. We don't care whether edge-case events are |
329 // traced or not, so we allow races on the enabled flag to keep the trace | 329 // traced or not, so we allow races on the enabled flag to keep the trace |
330 // macros fast. | 330 // macros fast. |
331 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: | 331 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: |
332 // ANNOTATE_BENIGN_RACE_SIZED(g_category_enabled, sizeof(g_category_enabled), | 332 // ANNOTATE_BENIGN_RACE_SIZED(g_category_enabled, sizeof(g_category_enabled), |
333 // "trace_event category enabled"); | 333 // "trace_event category enabled"); |
334 for (int i = 0; i < TRACE_EVENT_MAX_CATEGORIES; ++i) { | 334 for (int i = 0; i < TRACE_EVENT_MAX_CATEGORIES; ++i) { |
335 ANNOTATE_BENIGN_RACE(&g_category_enabled[i], | 335 ANNOTATE_BENIGN_RACE(&g_category_enabled[i], |
336 "trace_event category enabled"); | 336 "trace_event category enabled"); |
337 } | 337 } |
| 338 #if defined(OS_NACL) // NaCl shouldn't expose the process id. |
| 339 SetProcessID(0); |
| 340 #else |
338 SetProcessID(static_cast<int>(base::GetCurrentProcId())); | 341 SetProcessID(static_cast<int>(base::GetCurrentProcId())); |
| 342 #endif |
339 } | 343 } |
340 | 344 |
341 TraceLog::~TraceLog() { | 345 TraceLog::~TraceLog() { |
342 } | 346 } |
343 | 347 |
344 const unsigned char* TraceLog::GetCategoryEnabled(const char* name) { | 348 const unsigned char* TraceLog::GetCategoryEnabled(const char* name) { |
345 TraceLog* tracelog = GetInstance(); | 349 TraceLog* tracelog = GetInstance(); |
346 if (!tracelog) { | 350 if (!tracelog) { |
347 DCHECK(!g_category_enabled[g_category_already_shutdown]); | 351 DCHECK(!g_category_enabled[g_category_already_shutdown]); |
348 return &g_category_enabled[g_category_already_shutdown]; | 352 return &g_category_enabled[g_category_already_shutdown]; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // Create a FNV hash from the process ID for XORing. | 760 // Create a FNV hash from the process ID for XORing. |
757 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. | 761 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. |
758 unsigned long long offset_basis = 14695981039346656037ull; | 762 unsigned long long offset_basis = 14695981039346656037ull; |
759 unsigned long long fnv_prime = 1099511628211ull; | 763 unsigned long long fnv_prime = 1099511628211ull; |
760 unsigned long long pid = static_cast<unsigned long long>(process_id_); | 764 unsigned long long pid = static_cast<unsigned long long>(process_id_); |
761 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; | 765 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; |
762 } | 766 } |
763 | 767 |
764 } // namespace debug | 768 } // namespace debug |
765 } // namespace base | 769 } // namespace base |
OLD | NEW |