| Index: base/trace_event/trace_event_impl.cc
|
| diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc
|
| index 2ac19623960f57dbf41c02bd0c1eaec8bbd1afcb..c0dc8436fa7ed601f0e065eca913001698c17dc3 100644
|
| --- a/base/trace_event/trace_event_impl.cc
|
| +++ b/base/trace_event/trace_event_impl.cc
|
| @@ -56,27 +56,27 @@ TraceEvent::TraceEvent()
|
| TraceEvent::~TraceEvent() {
|
| }
|
|
|
| -void TraceEvent::CopyFrom(const TraceEvent& other) {
|
| - timestamp_ = other.timestamp_;
|
| - thread_timestamp_ = other.thread_timestamp_;
|
| - duration_ = other.duration_;
|
| - scope_ = other.scope_;
|
| - id_ = other.id_;
|
| - category_group_enabled_ = other.category_group_enabled_;
|
| - name_ = other.name_;
|
| - if (other.flags_ & TRACE_EVENT_FLAG_HAS_PROCESS_ID)
|
| - process_id_ = other.process_id_;
|
| +void TraceEvent::MoveFrom(scoped_ptr<TraceEvent> other) {
|
| + timestamp_ = other->timestamp_;
|
| + thread_timestamp_ = other->thread_timestamp_;
|
| + duration_ = other->duration_;
|
| + scope_ = other->scope_;
|
| + id_ = other->id_;
|
| + category_group_enabled_ = other->category_group_enabled_;
|
| + name_ = other->name_;
|
| + if (other->flags_ & TRACE_EVENT_FLAG_HAS_PROCESS_ID)
|
| + process_id_ = other->process_id_;
|
| else
|
| - thread_id_ = other.thread_id_;
|
| - phase_ = other.phase_;
|
| - flags_ = other.flags_;
|
| - parameter_copy_storage_ = other.parameter_copy_storage_;
|
| + thread_id_ = other->thread_id_;
|
| + phase_ = other->phase_;
|
| + flags_ = other->flags_;
|
| + parameter_copy_storage_ = std::move(other->parameter_copy_storage_);
|
|
|
| for (int i = 0; i < kTraceMaxNumArgs; ++i) {
|
| - arg_names_[i] = other.arg_names_[i];
|
| - arg_types_[i] = other.arg_types_[i];
|
| - arg_values_[i] = other.arg_values_[i];
|
| - convertable_values_[i] = other.convertable_values_[i];
|
| + arg_names_[i] = other->arg_names_[i];
|
| + arg_types_[i] = other->arg_types_[i];
|
| + arg_values_[i] = other->arg_values_[i];
|
| + convertable_values_[i] = std::move(other->convertable_values_[i]);
|
| }
|
| }
|
|
|
| @@ -94,7 +94,7 @@ void TraceEvent::Initialize(
|
| const char** arg_names,
|
| const unsigned char* arg_types,
|
| const unsigned long long* arg_values,
|
| - const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
|
| + scoped_ptr<ConvertableToTraceFormat>* convertable_values,
|
| unsigned int flags) {
|
| timestamp_ = timestamp;
|
| thread_timestamp_ = thread_timestamp;
|
| @@ -115,15 +115,17 @@ void TraceEvent::Initialize(
|
| arg_names_[i] = arg_names[i];
|
| arg_types_[i] = arg_types[i];
|
|
|
| - if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE)
|
| - convertable_values_[i] = convertable_values[i];
|
| - else
|
| + if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) {
|
| + convertable_values_[i] = std::move(convertable_values[i]);
|
| + } else {
|
| arg_values_[i].as_uint = arg_values[i];
|
| + convertable_values_[i].reset();
|
| + }
|
| }
|
| for (; i < kTraceMaxNumArgs; ++i) {
|
| arg_names_[i] = NULL;
|
| arg_values_[i].as_uint = 0u;
|
| - convertable_values_[i] = NULL;
|
| + convertable_values_[i].reset();
|
| arg_types_[i] = TRACE_VALUE_TYPE_UINT;
|
| }
|
|
|
| @@ -151,9 +153,9 @@ void TraceEvent::Initialize(
|
| }
|
|
|
| if (alloc_size) {
|
| - parameter_copy_storage_ = new RefCountedString;
|
| - parameter_copy_storage_->data().resize(alloc_size);
|
| - char* ptr = string_as_array(¶meter_copy_storage_->data());
|
| + parameter_copy_storage_.reset(new std::string);
|
| + parameter_copy_storage_->resize(alloc_size);
|
| + char* ptr = string_as_array(parameter_copy_storage_.get());
|
| const char* end = ptr + alloc_size;
|
| if (copy) {
|
| CopyTraceEventParameter(&ptr, &name_, end);
|
| @@ -176,9 +178,9 @@ void TraceEvent::Reset() {
|
| // Only reset fields that won't be initialized in Initialize(), or that may
|
| // hold references to other objects.
|
| duration_ = TimeDelta::FromInternalValue(-1);
|
| - parameter_copy_storage_ = NULL;
|
| + parameter_copy_storage_.reset();
|
| for (int i = 0; i < kTraceMaxNumArgs; ++i)
|
| - convertable_values_[i] = NULL;
|
| + convertable_values_[i].reset();
|
| }
|
|
|
| void TraceEvent::UpdateDuration(const TimeTicks& now,
|
| @@ -196,11 +198,8 @@ void TraceEvent::EstimateTraceMemoryOverhead(
|
| TraceEventMemoryOverhead* overhead) {
|
| overhead->Add("TraceEvent", sizeof(*this));
|
|
|
| - // TODO(primiano): parameter_copy_storage_ is refcounted and, in theory,
|
| - // could be shared by several events and we might overcount. In practice
|
| - // this is unlikely but it's worth checking.
|
| if (parameter_copy_storage_)
|
| - overhead->AddRefCountedString(*parameter_copy_storage_.get());
|
| + overhead->AddString(*parameter_copy_storage_);
|
|
|
| for (size_t i = 0; i < kTraceMaxNumArgs; ++i) {
|
| if (arg_types_[i] == TRACE_VALUE_TYPE_CONVERTABLE)
|
|
|