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

Side by Side Diff: base/debug/trace_event_impl.h

Issue 11345019: Make Chrome Trace work with Android ATrace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove redundant checking Created 8 years, 1 month 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 | Annotate | Revision Log
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 5
6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_
7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 unsigned char flags); 75 unsigned char flags);
76 ~TraceEvent(); 76 ~TraceEvent();
77 77
78 // Serialize event data to JSON 78 // Serialize event data to JSON
79 static void AppendEventsAsJSON(const std::vector<TraceEvent>& events, 79 static void AppendEventsAsJSON(const std::vector<TraceEvent>& events,
80 size_t start, 80 size_t start,
81 size_t count, 81 size_t count,
82 std::string* out); 82 std::string* out);
83 void AppendAsJSON(std::string* out) const; 83 void AppendAsJSON(std::string* out) const;
84 84
85 static void AppendValueAsJSON(unsigned char type,
86 TraceValue value,
87 std::string* out);
88
85 TimeTicks timestamp() const { return timestamp_; } 89 TimeTicks timestamp() const { return timestamp_; }
86 90
87 // Exposed for unittesting: 91 // Exposed for unittesting:
88 92
89 const base::RefCountedString* parameter_copy_storage() const { 93 const base::RefCountedString* parameter_copy_storage() const {
90 return parameter_copy_storage_.get(); 94 return parameter_copy_storage_.get();
91 } 95 }
92 96
93 const unsigned char* category_enabled() const { return category_enabled_; } 97 const unsigned char* category_enabled() const { return category_enabled_; }
94 const char* name() const { return name_; } 98 const char* name() const { return name_; }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // meaningful if |IsEnabled()| is true. 201 // meaningful if |IsEnabled()| is true.
198 void GetEnabledTraceCategories(std::vector<std::string>* included_out, 202 void GetEnabledTraceCategories(std::vector<std::string>* included_out,
199 std::vector<std::string>* excluded_out); 203 std::vector<std::string>* excluded_out);
200 204
201 // Disable tracing for all categories. 205 // Disable tracing for all categories.
202 void SetDisabled(); 206 void SetDisabled();
203 // Helper method to enable/disable tracing for all categories. 207 // Helper method to enable/disable tracing for all categories.
204 void SetEnabled(bool enabled); 208 void SetEnabled(bool enabled);
205 bool IsEnabled() { return enabled_; } 209 bool IsEnabled() { return enabled_; }
206 210
211 #if defined(OS_ANDROID)
212 static void InitATrace();
213 static bool IsATraceEnabled();
214 #endif
215
207 // Enabled state listeners give a callback when tracing is enabled or 216 // Enabled state listeners give a callback when tracing is enabled or
208 // disabled. This can be used to tie into other library's tracing systems 217 // disabled. This can be used to tie into other library's tracing systems
209 // on-demand. 218 // on-demand.
210 class EnabledStateChangedObserver { 219 class EnabledStateChangedObserver {
211 public: 220 public:
212 // Called just before the tracing system becomes 221 // Called just before the tracing system becomes
213 // enabled. TraceLog::IsEnabled will return false at this point and trace 222 // enabled. TraceLog::IsEnabled will return false at this point and trace
214 // macros and methods called within the observer will deadlock. 223 // macros and methods called within the observer will deadlock.
215 virtual void OnTraceLogWillEnable() { } 224 virtual void OnTraceLogWillEnable() { }
216 225
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 private: 336 private:
328 TraceLog* trace_log_; 337 TraceLog* trace_log_;
329 NotificationCallback callback_copy_; 338 NotificationCallback callback_copy_;
330 int notification_; 339 int notification_;
331 }; 340 };
332 341
333 TraceLog(); 342 TraceLog();
334 ~TraceLog(); 343 ~TraceLog();
335 const unsigned char* GetCategoryEnabledInternal(const char* name); 344 const unsigned char* GetCategoryEnabledInternal(const char* name);
336 void AddThreadNameMetadataEvents(); 345 void AddThreadNameMetadataEvents();
346
347 #if defined(OS_ANDROID)
348 void SendToATrace(char phase,
349 const char* category,
350 const char* name,
351 int num_args,
352 const char** arg_names,
353 const unsigned char* arg_types,
354 const unsigned long long* arg_values);
337 void AddClockSyncMetadataEvents(); 355 void AddClockSyncMetadataEvents();
356 #endif
338 357
339 // TODO(nduca): switch to per-thread trace buffers to reduce thread 358 // TODO(nduca): switch to per-thread trace buffers to reduce thread
340 // synchronization. 359 // synchronization.
341 // This lock protects TraceLog member accesses from arbitrary threads. 360 // This lock protects TraceLog member accesses from arbitrary threads.
342 Lock lock_; 361 Lock lock_;
343 bool enabled_; 362 bool enabled_;
344 NotificationCallback notification_callback_; 363 NotificationCallback notification_callback_;
345 std::vector<TraceEvent> logged_events_; 364 std::vector<TraceEvent> logged_events_;
346 std::vector<std::string> included_categories_; 365 std::vector<std::string> included_categories_;
347 std::vector<std::string> excluded_categories_; 366 std::vector<std::string> excluded_categories_;
(...skipping 11 matching lines...) Expand all
359 const unsigned char* watch_category_; 378 const unsigned char* watch_category_;
360 std::string watch_event_name_; 379 std::string watch_event_name_;
361 380
362 DISALLOW_COPY_AND_ASSIGN(TraceLog); 381 DISALLOW_COPY_AND_ASSIGN(TraceLog);
363 }; 382 };
364 383
365 } // namespace debug 384 } // namespace debug
366 } // namespace base 385 } // namespace base
367 386
368 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ 387 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698