summaryrefslogtreecommitdiffstats
path: root/base/debug
diff options
context:
space:
mode:
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 22:15:02 +0000
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 22:15:02 +0000
commit3b04bb0f7e9587df6575b29339da9538fe9c45db (patch)
treeb9ef70c74e41be6e1d5d18244bfaadf450d31658 /base/debug
parent12e400a10af6a47105c2294bb7b20084108eebe3 (diff)
downloadchromium_src-3b04bb0f7e9587df6575b29339da9538fe9c45db.zip
chromium_src-3b04bb0f7e9587df6575b29339da9538fe9c45db.tar.gz
chromium_src-3b04bb0f7e9587df6575b29339da9538fe9c45db.tar.bz2
Remove constructors of TraceEventHandle
The constructors of TraceEventHandle makes the constructor of ScopedTracer (which is called even when tracing is not enabled) initialize the Data structure which we wanted to avoid. BUG=trace-viewer:489 R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/33423006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug')
-rw-r--r--base/debug/trace_event_impl.cc24
-rw-r--r--base/debug/trace_event_impl.h19
2 files changed, 20 insertions, 23 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index 651ee56..69dcfdca 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -438,6 +438,18 @@ class TraceLog::OptionalAutoLock {
DISALLOW_COPY_AND_ASSIGN(OptionalAutoLock);
};
+// Use this function instead of TraceEventHandle constructor to keep the
+// overhead of ScopedTracer (trace_event.h) constructor minimum.
+void MakeHandle(uint32 chunk_seq, size_t chunk_index, size_t event_index,
+ TraceEventHandle* handle) {
+ DCHECK(chunk_seq);
+ DCHECK(chunk_index < (1u << 16));
+ DCHECK(event_index < (1u << 16));
+ handle->chunk_seq = chunk_seq;
+ handle->chunk_index = chunk_index;
+ handle->event_index = event_index;
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// TraceEvent
@@ -1049,7 +1061,8 @@ TraceEvent* TraceLog::ThreadLocalEventBuffer::AddTraceEvent(
size_t event_index;
TraceEvent* trace_event = chunk_->AddTraceEvent(&event_index);
if (trace_event && handle)
- *handle = TraceEventHandle(chunk_->seq(), chunk_index_, event_index);
+ MakeHandle(chunk_->seq(), chunk_index_, event_index, handle);
+
return trace_event;
}
@@ -1484,8 +1497,8 @@ TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked(
size_t event_index;
TraceEvent* trace_event = thread_shared_chunk_->AddTraceEvent(&event_index);
if (trace_event && handle) {
- *handle = TraceEventHandle(thread_shared_chunk_->seq(),
- thread_shared_chunk_index_, event_index);
+ MakeHandle(thread_shared_chunk_->seq(), thread_shared_chunk_index_,
+ event_index, handle);
}
return trace_event;
}
@@ -1716,7 +1729,7 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
const unsigned long long* arg_values,
const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
unsigned char flags) {
- TraceEventHandle handle;
+ TraceEventHandle handle = { 0, 0, 0 };
if (!*category_group_enabled)
return handle;
@@ -2011,6 +2024,9 @@ TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) {
TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle,
OptionalAutoLock* lock) {
+ if (!handle.chunk_seq)
+ return NULL;
+
if (thread_local_event_buffer_.Get()) {
TraceEvent* trace_event =
thread_local_event_buffer_.Get()->GetEventByHandle(handle);
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index 1d30153..a593f642 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -80,25 +80,6 @@ class ConvertableToTraceFormat : public RefCounted<ConvertableToTraceFormat> {
};
struct TraceEventHandle {
- TraceEventHandle()
- : chunk_seq(0),
- chunk_index(0),
- event_index(0) {
- }
-
- TraceEventHandle(uint32 a_chunk_seq,
- size_t a_chunk_index,
- size_t a_event_index)
- : chunk_seq(a_chunk_seq),
- chunk_index(static_cast<uint16>(a_chunk_index)),
- event_index(static_cast<uint16>(a_event_index)) {
- DCHECK(chunk_seq);
- DCHECK(a_chunk_index < (1u << 16));
- DCHECK(a_event_index < (1u << 16));
- }
-
- bool IsNull() const { return chunk_seq == 0; }
-
uint32 chunk_seq;
uint16 chunk_index;
uint16 event_index;