| 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/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 int threshold_begin_id, | 620 int threshold_begin_id, |
| 621 long long threshold, | 621 long long threshold, |
| 622 unsigned char flags) { | 622 unsigned char flags) { |
| 623 DCHECK(name); | 623 DCHECK(name); |
| 624 | 624 |
| 625 #if defined(OS_ANDROID) | 625 #if defined(OS_ANDROID) |
| 626 SendToATrace(phase, GetCategoryName(category_enabled), name, | 626 SendToATrace(phase, GetCategoryName(category_enabled), name, |
| 627 num_args, arg_names, arg_types, arg_values); | 627 num_args, arg_names, arg_types, arg_values); |
| 628 #endif | 628 #endif |
| 629 | 629 |
| 630 TimeTicks now = TimeTicks::NowFromSystemTraceTime(); | 630 TimeTicks now = TimeTicks::NowFromSystemTraceTime() - time_offset_; |
| 631 NotificationHelper notifier(this); | 631 NotificationHelper notifier(this); |
| 632 int ret_begin_id = -1; | 632 int ret_begin_id = -1; |
| 633 { | 633 { |
| 634 AutoLock lock(lock_); | 634 AutoLock lock(lock_); |
| 635 if (*category_enabled != CATEGORY_ENABLED) | 635 if (*category_enabled != CATEGORY_ENABLED) |
| 636 return -1; | 636 return -1; |
| 637 if (logged_events_.size() >= kTraceEventBufferSize) | 637 if (logged_events_.size() >= kTraceEventBufferSize) |
| 638 return -1; | 638 return -1; |
| 639 | 639 |
| 640 int thread_id = static_cast<int>(PlatformThread::CurrentId()); | 640 int thread_id = static_cast<int>(PlatformThread::CurrentId()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 void TraceLog::SetProcessID(int process_id) { | 797 void TraceLog::SetProcessID(int process_id) { |
| 798 process_id_ = process_id; | 798 process_id_ = process_id; |
| 799 // Create a FNV hash from the process ID for XORing. | 799 // Create a FNV hash from the process ID for XORing. |
| 800 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. | 800 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. |
| 801 unsigned long long offset_basis = 14695981039346656037ull; | 801 unsigned long long offset_basis = 14695981039346656037ull; |
| 802 unsigned long long fnv_prime = 1099511628211ull; | 802 unsigned long long fnv_prime = 1099511628211ull; |
| 803 unsigned long long pid = static_cast<unsigned long long>(process_id_); | 803 unsigned long long pid = static_cast<unsigned long long>(process_id_); |
| 804 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; | 804 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; |
| 805 } | 805 } |
| 806 | 806 |
| 807 void TraceLog::SetTimeOffset(TimeDelta offset) { |
| 808 time_offset_ = offset; |
| 809 } |
| 810 |
| 807 } // namespace debug | 811 } // namespace debug |
| 808 } // namespace base | 812 } // namespace base |
| OLD | NEW |