| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // Determine whether to drop the begin/end pair. | 588 // Determine whether to drop the begin/end pair. |
| 589 TimeDelta elapsed = now - logged_events_[begin_i].timestamp(); | 589 TimeDelta elapsed = now - logged_events_[begin_i].timestamp(); |
| 590 if (elapsed < TimeDelta::FromMicroseconds(threshold)) { | 590 if (elapsed < TimeDelta::FromMicroseconds(threshold)) { |
| 591 // Remove begin event and do not add end event. | 591 // Remove begin event and do not add end event. |
| 592 // This will be expensive if there have been other events in the | 592 // This will be expensive if there have been other events in the |
| 593 // mean time (should be rare). | 593 // mean time (should be rare). |
| 594 logged_events_.erase(logged_events_.begin() + begin_i); | 594 logged_events_.erase(logged_events_.begin() + begin_i); |
| 595 return -1; | 595 return -1; |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 |
| 599 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) |
| 600 id ^= process_id_hash_; |
| 601 |
| 598 ret_begin_id = static_cast<int>(logged_events_.size()); | 602 ret_begin_id = static_cast<int>(logged_events_.size()); |
| 599 logged_events_.push_back( | 603 logged_events_.push_back( |
| 600 TraceEvent(thread_id, | 604 TraceEvent(thread_id, |
| 601 now, phase, category_enabled, name, id, | 605 now, phase, category_enabled, name, id, |
| 602 num_args, arg_names, arg_types, arg_values, | 606 num_args, arg_names, arg_types, arg_values, |
| 603 flags)); | 607 flags)); |
| 604 | 608 |
| 605 if (logged_events_.size() == kTraceEventBufferSize) { | 609 if (logged_events_.size() == kTraceEventBufferSize) { |
| 606 buffer_full_callback_copy = buffer_full_callback_; | 610 buffer_full_callback_copy = buffer_full_callback_; |
| 607 } | 611 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // Create a FNV hash from the process ID for XORing. | 714 // Create a FNV hash from the process ID for XORing. |
| 711 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. | 715 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. |
| 712 unsigned long long offset_basis = 14695981039346656037ull; | 716 unsigned long long offset_basis = 14695981039346656037ull; |
| 713 unsigned long long fnv_prime = 1099511628211ull; | 717 unsigned long long fnv_prime = 1099511628211ull; |
| 714 unsigned long long pid = static_cast<unsigned long long>(process_id_); | 718 unsigned long long pid = static_cast<unsigned long long>(process_id_); |
| 715 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; | 719 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; |
| 716 } | 720 } |
| 717 | 721 |
| 718 } // namespace debug | 722 } // namespace debug |
| 719 } // namespace base | 723 } // namespace base |
| OLD | NEW |