Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: base/debug/trace_event_android.cc

Issue 12221047: Support JellyBean MR2 style of systrace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For landing Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/debug/trace_event_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 12
13 namespace { 13 namespace {
14 14
15 int g_atrace_fd = -1; 15 int g_atrace_fd = -1;
16 const char* kATraceMarkerFile = "/sys/kernel/debug/tracing/trace_marker"; 16 const char* kATraceMarkerFile = "/sys/kernel/debug/tracing/trace_marker";
17 17
18 } // namespace 18 } // namespace
19 19
20 namespace base { 20 namespace base {
21 namespace debug { 21 namespace debug {
22 22
23 // static 23 void TraceLog::StartATrace() {
24 void TraceLog::InitATrace() { 24 AutoLock lock(lock_);
25 DCHECK(g_atrace_fd == -1); 25 if (g_atrace_fd == -1) {
26 g_atrace_fd = open(kATraceMarkerFile, O_WRONLY | O_APPEND); 26 g_atrace_fd = open(kATraceMarkerFile, O_WRONLY);
27 if (g_atrace_fd == -1) 27 if (g_atrace_fd == -1)
28 LOG(WARNING) << "Couldn't open " << kATraceMarkerFile; 28 LOG(WARNING) << "Couldn't open " << kATraceMarkerFile;
29 }
30 }
31
32 void TraceLog::StopATrace() {
33 AutoLock lock(lock_);
34 if (g_atrace_fd != -1) {
35 close(g_atrace_fd);
36 g_atrace_fd = -1;
37 }
29 } 38 }
30 39
31 void TraceLog::SendToATrace(char phase, 40 void TraceLog::SendToATrace(char phase,
32 const char* category, 41 const char* category,
33 const char* name, 42 const char* name,
34 int num_args, 43 int num_args,
35 const char** arg_names, 44 const char** arg_names,
36 const unsigned char* arg_types, 45 const unsigned char* arg_types,
37 const unsigned long long* arg_values) { 46 const unsigned long long* arg_values) {
38 if (g_atrace_fd == -1) 47 if (g_atrace_fd == -1)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 default: 93 default:
85 // Do nothing. 94 // Do nothing.
86 break; 95 break;
87 } 96 }
88 } 97 }
89 98
90 // Must be called with lock_ locked. 99 // Must be called with lock_ locked.
91 void TraceLog::ApplyATraceEnabledFlag(unsigned char* category_enabled) { 100 void TraceLog::ApplyATraceEnabledFlag(unsigned char* category_enabled) {
92 if (g_atrace_fd != -1) 101 if (g_atrace_fd != -1)
93 *category_enabled |= ATRACE_ENABLED; 102 *category_enabled |= ATRACE_ENABLED;
103 else
104 *category_enabled &= ~ATRACE_ENABLED;
94 } 105 }
95 106
96 } // namespace debug 107 } // namespace debug
97 } // namespace base 108 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698