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

Side by Side Diff: third_party/WebKit/Source/platform/TraceEvent.h

Issue 1447563002: Implement frame attribution (FrameBlamer) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // TraceID encapsulates an ID that can either be an integer or pointer; 289 // TraceID encapsulates an ID that can either be an integer or pointer;
290 // optionally, it can be paired with a scope string, too. Pointers are mangled 290 // optionally, it can be paired with a scope string, too. Pointers are mangled
291 // with the Process ID so that they are unlikely to collide when the same 291 // with the Process ID so that they are unlikely to collide when the same
292 // pointer is used on different processes. 292 // pointer is used on different processes.
293 class TraceID final { 293 class TraceID final {
294 STACK_ALLOCATED(); 294 STACK_ALLOCATED();
295 WTF_MAKE_NONCOPYABLE(TraceID); 295 WTF_MAKE_NONCOPYABLE(TraceID);
296 public: 296 public:
297 class WithScope final { 297 class WithScope final {
298 STACK_ALLOCATED(); 298 STACK_ALLOCATED();
299
299 public: 300 public:
300 template<typename T> WithScope(const char* scope, T id) 301 template<typename T> WithScope(const char* scope, T id)
301 : m_scope(scope), m_data(reinterpret_cast<unsigned long long>(id)) { } 302 : m_scope(scope), m_data(reinterpret_cast<unsigned long long>(id)) { }
302 const char* scope() const { return m_scope; } 303 const char* scope() const { return m_scope; }
303 unsigned long long data() const { return m_data; } 304 unsigned long long data() const { return m_data; }
304 private: 305 private:
305 const char* m_scope = kGlobalScope; 306 const char* m_scope = kGlobalScope;
306 unsigned long long m_data; 307 unsigned long long m_data;
307 }; 308 };
308 309
309 template<bool dummyMangle> class MangleBehavior final { 310 template<bool dummyMangle> class MangleBehavior final {
310 STACK_ALLOCATED(); 311 STACK_ALLOCATED();
312
311 public: 313 public:
312 template<typename T> explicit MangleBehavior(T id) : m_data(reinterpret_ cast<unsigned long long>(id)) { } 314 template<typename T> explicit MangleBehavior(T id) : m_data(reinterpret_ cast<unsigned long long>(id)) { }
313 explicit MangleBehavior(WithScope scopedID) : m_scope(scopedID.scope()), m_data(scopedID.data()) { } 315 explicit MangleBehavior(WithScope scopedID) : m_scope(scopedID.scope()), m_data(scopedID.data()) { }
314 const char* scope() const { return m_scope; } 316 const char* scope() const { return m_scope; }
315 unsigned long long data() const { return m_data; } 317 unsigned long long data() const { return m_data; }
316 private: 318 private:
317 const char* m_scope = kGlobalScope; 319 const char* m_scope = kGlobalScope;
318 unsigned long long m_data; 320 unsigned long long m_data;
319 }; 321 };
320 typedef MangleBehavior<false> DontMangle; 322 typedef MangleBehavior<false> DontMangle;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 unsigned long long m_uint; 365 unsigned long long m_uint;
364 long long m_int; 366 long long m_int;
365 double m_double; 367 double m_double;
366 const void* m_pointer; 368 const void* m_pointer;
367 const char* m_string; 369 const char* m_string;
368 }; 370 };
369 371
370 // Simple container for const char* that should be copied instead of retained. 372 // Simple container for const char* that should be copied instead of retained.
371 class TraceStringWithCopy { 373 class TraceStringWithCopy {
372 STACK_ALLOCATED(); 374 STACK_ALLOCATED();
375
373 public: 376 public:
374 explicit TraceStringWithCopy(const char* str) : m_str(str) { } 377 explicit TraceStringWithCopy(const char* str) : m_str(str) { }
375 const char* str() const { return m_str; } 378 const char* str() const { return m_str; }
376 private: 379 private:
377 const char* m_str; 380 const char* m_str;
378 }; 381 };
379 382
380 // Define setTraceValue for each allowed type. It stores the type and 383 // Define setTraceValue for each allowed type. It stores the type and
381 // value in the return arguments. This allows this API to avoid declaring any 384 // value in the return arguments. This allows this API to avoid declaring any
382 // structures so that it is portable to third_party libraries. 385 // structures so that it is portable to third_party libraries.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 m_pdata = &m_data; 616 m_pdata = &m_data;
614 } 617 }
615 618
616 private: 619 private:
617 // This Data struct workaround is to avoid initializing all the members 620 // This Data struct workaround is to avoid initializing all the members
618 // in Data during construction of this object, since this object is always 621 // in Data during construction of this object, since this object is always
619 // constructed, even when tracing is disabled. If the members of Data were 622 // constructed, even when tracing is disabled. If the members of Data were
620 // members of this class instead, compiler warnings occur about potential 623 // members of this class instead, compiler warnings occur about potential
621 // uninitialized accesses. 624 // uninitialized accesses.
622 struct Data { 625 struct Data {
623 DISALLOW_NEW(); 626 STACK_ALLOCATED();
624 const unsigned char* categoryGroupEnabled; 627 const unsigned char* categoryGroupEnabled;
625 const char* name; 628 const char* name;
626 TraceEventHandle eventHandle; 629 TraceEventHandle eventHandle;
627 }; 630 };
628 Data* m_pdata; 631 Data* m_pdata;
629 Data m_data; 632 Data m_data;
630 }; 633 };
631 634
632 // TraceEventSamplingStateScope records the current sampling state 635 // TraceEventSamplingStateScope records the current sampling state
633 // and sets a new sampling state. When the scope exists, it restores 636 // and sets a new sampling state. When the scope exists, it restores
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 const char* m_categoryGroup; 684 const char* m_categoryGroup;
682 const char* m_name; 685 const char* m_name;
683 IDType m_id; 686 IDType m_id;
684 }; 687 };
685 688
686 } // namespace TraceEvent 689 } // namespace TraceEvent
687 690
688 } // namespace blink 691 } // namespace blink
689 692
690 #endif 693 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698