1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/gonk/libui/Trace.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* 1.5 + * Copyright (C) 2012 The Android Open Source Project 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * Unless required by applicable law or agreed to in writing, software 1.14 + * distributed under the License is distributed on an "AS IS" BASIS, 1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.16 + * See the License for the specific language governing permissions and 1.17 + * limitations under the License. 1.18 + */ 1.19 + 1.20 +#ifndef ANDROID_TRACE_H 1.21 +#define ANDROID_TRACE_H 1.22 + 1.23 +#include <fcntl.h> 1.24 +#include <stdint.h> 1.25 +#include <stdio.h> 1.26 +#include <string.h> 1.27 +#include <sys/stat.h> 1.28 +#include <sys/types.h> 1.29 +#include <unistd.h> 1.30 + 1.31 +#include <cutils/compiler.h> 1.32 +#include <utils/threads.h> 1.33 +#include "cutils_trace.h" 1.34 + 1.35 +// See <cutils/trace.h> for more ATRACE_* macros. 1.36 + 1.37 +// ATRACE_NAME traces the beginning and end of the current scope. To trace 1.38 +// the correct start and end times this macro should be declared first in the 1.39 +// scope body. 1.40 +#define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) 1.41 +// ATRACE_CALL is an ATRACE_NAME that uses the current function name. 1.42 +#define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) 1.43 + 1.44 +namespace android { 1.45 + 1.46 +class ScopedTrace { 1.47 +public: 1.48 +inline ScopedTrace(uint64_t tag, const char* name) 1.49 + : mTag(tag) { 1.50 +#ifdef HAVE_ANDROID_OS 1.51 + atrace_begin(mTag,name); 1.52 +#endif 1.53 +} 1.54 + 1.55 +inline ~ScopedTrace() { 1.56 +#ifdef HAVE_ANDROID_OS 1.57 + atrace_end(mTag); 1.58 +#endif 1.59 +} 1.60 + 1.61 +private: 1.62 + uint64_t mTag; 1.63 +}; 1.64 + 1.65 +}; // namespace android 1.66 + 1.67 +#endif // ANDROID_TRACE_H