1 // Copyright 2012 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <gtest/gtest.h> 6 7 #include "include/prop_registry.h" 8 9 #ifndef GESTURES_TRACER_H__ 10 #define GESTURES_TRACER_H__ 11 12 namespace gestures { 13 14 typedef void (*WriteFn)(const char*); 15 16 // This class will automatically help us manage tracing stuff. 17 // It has a X Property "Tracing Enabled". You can set it true to 18 // enable tracing. 19 // In the main program, you can simply use Trace function provided 20 // by this class to write tracing messages, and it will handle 21 // whether to output the message or not automatically. 22 23 class Tracer { 24 FRIEND_TEST(TracerTest, TraceTest); 25 public: 26 Tracer(PropRegistry* prop_reg, WriteFn write_fn); ~Tracer()27 ~Tracer() {}; 28 void Trace(const char* message, const char* name); 29 30 private: 31 WriteFn write_fn_; 32 // Disable and enable tracing by setting false and true respectively 33 BoolProperty tracing_enabled_; 34 }; 35 } // namespace gestures 36 37 #endif // GESTURES_TRACER_H__ 38