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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 19 matching lines...) Expand all
30 #ifndef TraceEvent_h 30 #ifndef TraceEvent_h
31 #define TraceEvent_h 31 #define TraceEvent_h
32 32
33 #include "platform/EventTracer.h" 33 #include "platform/EventTracer.h"
34 #include "platform/TraceEventCommon.h" 34 #include "platform/TraceEventCommon.h"
35 35
36 #include "platform/TracedValue.h" 36 #include "platform/TracedValue.h"
37 #include "wtf/Allocator.h" 37 #include "wtf/Allocator.h"
38 #include "wtf/DynamicAnnotations.h" 38 #include "wtf/DynamicAnnotations.h"
39 #include "wtf/Noncopyable.h" 39 #include "wtf/Noncopyable.h"
40 #include "wtf/PassOwnPtr.h"
40 #include "wtf/text/CString.h" 41 #include "wtf/text/CString.h"
41 #include <memory>
42 42
43 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
44 // Implementation specific tracing API definitions. 44 // Implementation specific tracing API definitions.
45 45
46 // By default, const char* argument values are assumed to have long-lived scope 46 // By default, const char* argument values are assumed to have long-lived scope
47 // and will not be copied. Use this macro to force a const char* to be copied. 47 // and will not be copied. Use this macro to force a const char* to be copied.
48 #define TRACE_STR_COPY(str) \ 48 #define TRACE_STR_COPY(str) \
49 blink::TraceEvent::TraceStringWithCopy(str) 49 blink::TraceEvent::TraceStringWithCopy(str)
50 50
51 // By default, uint64 ID argument values are not mangled with the Process ID in 51 // By default, uint64 ID argument values are not mangled with the Process ID in
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Add a trace event to the platform tracing system. 109 // Add a trace event to the platform tracing system.
110 // blink::TraceEvent::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT( 110 // blink::TraceEvent::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT(
111 // const char* name, 111 // const char* name,
112 // const char* scope, 112 // const char* scope,
113 // unsigned long long id, 113 // unsigned long long id,
114 // double timestamp, 114 // double timestamp,
115 // int num_args, 115 // int num_args,
116 // const char** arg_names, 116 // const char** arg_names,
117 // const unsigned char* arg_types, 117 // const unsigned char* arg_types,
118 // const unsigned long long* arg_values, 118 // const unsigned long long* arg_values,
119 // std::unique_ptr<TracedValue> tracedValues[], 119 // PassOwnPtr<TracedValue> tracedValues[],
120 // unsigned char flags) 120 // unsigned char flags)
121 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ 121 #define TRACE_EVENT_API_ADD_TRACE_EVENT \
122 blink::EventTracer::addTraceEvent 122 blink::EventTracer::addTraceEvent
123 123
124 // Set the duration field of a COMPLETE trace event. 124 // Set the duration field of a COMPLETE trace event.
125 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 125 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
126 // blink::TraceEvent::TraceEventHandle handle) 126 // blink::TraceEvent::TraceEventHandle handle)
127 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 127 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
128 blink::EventTracer::updateTraceEventDuration 128 blink::EventTracer::updateTraceEventDuration
129 129
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 typeValue.m_string = arg.data(); 420 typeValue.m_string = arg.data();
421 *type = TRACE_VALUE_TYPE_COPY_STRING; 421 *type = TRACE_VALUE_TYPE_COPY_STRING;
422 *value = typeValue.m_uint; 422 *value = typeValue.m_uint;
423 } 423 }
424 424
425 static inline void setTraceValue(TracedValue*, unsigned char* type, unsigned lon g long*) 425 static inline void setTraceValue(TracedValue*, unsigned char* type, unsigned lon g long*)
426 { 426 {
427 *type = TRACE_VALUE_TYPE_CONVERTABLE; 427 *type = TRACE_VALUE_TYPE_CONVERTABLE;
428 } 428 }
429 429
430 template<typename T> static inline void setTraceValue(const std::unique_ptr<T>& ptr, unsigned char* type, unsigned long long* value) 430 template<typename T> static inline void setTraceValue(const PassOwnPtr<T>& ptr, unsigned char* type, unsigned long long* value)
431 { 431 {
432 setTraceValue(ptr.get(), type, value); 432 setTraceValue(ptr.get(), type, value);
433 } 433 }
434 434
435 template<typename T> struct TracedValueTraits { 435 template<typename T> struct TracedValueTraits {
436 static const bool isTracedValue = false; 436 static const bool isTracedValue = false;
437 static std::unique_ptr<TracedValue> moveFromIfTracedValue(const T&) 437 static PassOwnPtr<TracedValue> moveFromIfTracedValue(const T&)
438 { 438 {
439 return nullptr; 439 return nullptr;
440 } 440 }
441 }; 441 };
442 442
443 template<typename T> struct TracedValueTraits<std::unique_ptr<T>> { 443 template<typename T> struct TracedValueTraits<PassOwnPtr<T>> {
444 static const bool isTracedValue = std::is_convertible<T*, TracedValue*>::val ue; 444 static const bool isTracedValue = std::is_convertible<T*, TracedValue*>::val ue;
445 static std::unique_ptr<TracedValue> moveFromIfTracedValue(std::unique_ptr<T> && tracedValue) 445 static PassOwnPtr<TracedValue> moveFromIfTracedValue(PassOwnPtr<T>&& tracedV alue)
446 { 446 {
447 return std::move(tracedValue); 447 return std::move(tracedValue);
448 } 448 }
449 }; 449 };
450 450
451 template<typename T> bool isTracedValue(const T&) 451 template<typename T> bool isTracedValue(const T&)
452 { 452 {
453 return TracedValueTraits<T>::isTracedValue; 453 return TracedValueTraits<T>::isTracedValue;
454 } 454 }
455 455
456 template<typename T> std::unique_ptr<TracedValue> moveFromIfTracedValue(T&& valu e) 456 template<typename T> PassOwnPtr<TracedValue> moveFromIfTracedValue(T&& value)
457 { 457 {
458 return TracedValueTraits<T>::moveFromIfTracedValue(std::forward<T>(value)); 458 return TracedValueTraits<T>::moveFromIfTracedValue(std::forward<T>(value));
459 } 459 }
460 460
461 // These addTraceEvent template functions are defined here instead of in the 461 // These addTraceEvent template functions are defined here instead of in the
462 // macro, because the arg values could be temporary string objects. In order to 462 // macro, because the arg values could be temporary string objects. In order to
463 // store pointers to the internal c_str and pass through to the tracing API, the 463 // store pointers to the internal c_str and pass through to the tracing API, the
464 // arg values must live throughout these procedures. 464 // arg values must live throughout these procedures.
465 465
466 static inline TraceEventHandle addTraceEvent( 466 static inline TraceEventHandle addTraceEvent(
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 const char* m_categoryGroup; 682 const char* m_categoryGroup;
683 const char* m_name; 683 const char* m_name;
684 IDType m_id; 684 IDType m_id;
685 }; 685 };
686 686
687 } // namespace TraceEvent 687 } // namespace TraceEvent
688 688
689 } // namespace blink 689 } // namespace blink
690 690
691 #endif 691 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/TimerTest.cpp ('k') | third_party/WebKit/Source/platform/TraceEventCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698