| Index: base/debug/trace_event_android.cc
|
| diff --git a/base/debug/trace_event_android.cc b/base/debug/trace_event_android.cc
|
| index 29e684a659d6e17aa51f0087aae3860b16d4c206..2901a3427f22fdc815c0b5fa5c3d380a89c416ee 100644
|
| --- a/base/debug/trace_event_android.cc
|
| +++ b/base/debug/trace_event_android.cc
|
| @@ -20,12 +20,21 @@ const char* kATraceMarkerFile = "/sys/kernel/debug/tracing/trace_marker";
|
| namespace base {
|
| namespace debug {
|
|
|
| -// static
|
| -void TraceLog::InitATrace() {
|
| - DCHECK(g_atrace_fd == -1);
|
| - g_atrace_fd = open(kATraceMarkerFile, O_WRONLY | O_APPEND);
|
| - if (g_atrace_fd == -1)
|
| - LOG(WARNING) << "Couldn't open " << kATraceMarkerFile;
|
| +void TraceLog::StartATrace() {
|
| + AutoLock lock(lock_);
|
| + if (g_atrace_fd == -1) {
|
| + g_atrace_fd = open(kATraceMarkerFile, O_WRONLY);
|
| + if (g_atrace_fd == -1)
|
| + LOG(WARNING) << "Couldn't open " << kATraceMarkerFile;
|
| + }
|
| +}
|
| +
|
| +void TraceLog::StopATrace() {
|
| + AutoLock lock(lock_);
|
| + if (g_atrace_fd != -1) {
|
| + close(g_atrace_fd);
|
| + g_atrace_fd = -1;
|
| + }
|
| }
|
|
|
| void TraceLog::SendToATrace(char phase,
|
| @@ -91,6 +100,8 @@ void TraceLog::SendToATrace(char phase,
|
| void TraceLog::ApplyATraceEnabledFlag(unsigned char* category_enabled) {
|
| if (g_atrace_fd != -1)
|
| *category_enabled |= ATRACE_ENABLED;
|
| + else
|
| + *category_enabled &= ~ATRACE_ENABLED;
|
| }
|
|
|
| } // namespace debug
|
|
|