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

Unified Diff: content/browser/tracing/tracing_controller_impl_data_sinks.cc

Issue 1502583003: [Tracing] Add metadata filter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile failure on win Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.cc ('k') | content/public/browser/tracing_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tracing/tracing_controller_impl_data_sinks.cc
diff --git a/content/browser/tracing/tracing_controller_impl_data_sinks.cc b/content/browser/tracing/tracing_controller_impl_data_sinks.cc
index 0f67ac357bd057f29787a08de0355df40d8493f0..1f717745c9ef31b062065ca249ef827f952c67a2 100644
--- a/content/browser/tracing/tracing_controller_impl_data_sinks.cc
+++ b/content/browser/tracing/tracing_controller_impl_data_sinks.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/json/json_writer.h"
+#include "base/strings/pattern.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/zlib/zlib.h"
@@ -143,7 +144,7 @@ class StringTraceDataSink : public TracingController::TraceDataSink {
AddTraceChunkAndPassToEndpoint(",\"systemTraceEvents\": " +
system_trace_);
std::string metadataJSON;
- if (base::JSONWriter::Write(GetMetadata(), &metadataJSON) &&
+ if (base::JSONWriter::Write(*GetMetadataCopy(), &metadataJSON) &&
!metadataJSON.empty())
AddTraceChunkAndPassToEndpoint(",\"metadata\": " + metadataJSON);
if (!power_trace_.empty()) {
@@ -153,8 +154,7 @@ class StringTraceDataSink : public TracingController::TraceDataSink {
AddTraceChunkAndPassToEndpoint("}");
- scoped_ptr<const base::DictionaryValue> metadata(GetMetadata().DeepCopy());
- endpoint_->ReceiveTraceFinalContents(metadata.Pass(), trace_);
+ endpoint_->ReceiveTraceFinalContents(GetMetadataCopy(), trace_);
}
private:
@@ -278,7 +278,7 @@ class CompressedStringTraceDataSink : public TracingController::TraceDataSink {
",\"systemTraceEvents\": " + system_trace_, false);
}
std::string metadataJSON;
- if (base::JSONWriter::Write(GetMetadata(), &metadataJSON) &&
+ if (base::JSONWriter::Write(*GetMetadataCopy(), &metadataJSON) &&
!metadataJSON.empty()) {
AddTraceChunkAndCompressOnFileThread(",\"metadata\": " + metadataJSON,
false);
@@ -292,8 +292,7 @@ class CompressedStringTraceDataSink : public TracingController::TraceDataSink {
deflateEnd(stream_.get());
stream_.reset();
- scoped_ptr<const base::DictionaryValue> metadata(GetMetadata().DeepCopy());
- endpoint_->ReceiveTraceFinalContents(metadata.Pass(),
+ endpoint_->ReceiveTraceFinalContents(GetMetadataCopy(),
compressed_trace_data_);
}
@@ -309,14 +308,34 @@ class CompressedStringTraceDataSink : public TracingController::TraceDataSink {
} // namespace
+TracingController::TraceDataSink::TraceDataSink() {}
+
+TracingController::TraceDataSink::~TraceDataSink() {}
+
void TracingController::TraceDataSink::AddMetadata(
const base::DictionaryValue& data) {
metadata_.MergeDictionary(&data);
}
-const base::DictionaryValue&
- TracingController::TraceDataSink::GetMetadata() const {
- return metadata_;
+void TracingController::TraceDataSink::SetMetadataFilterPredicate(
+ const MetadataFilterPredicate& metadata_filter_predicate) {
+ metadata_filter_predicate_ = metadata_filter_predicate;
+}
+
+scoped_ptr<const base::DictionaryValue>
+ TracingController::TraceDataSink::GetMetadataCopy() const {
+ if (metadata_filter_predicate_.is_null())
+ return scoped_ptr<const base::DictionaryValue>(metadata_.DeepCopy()).Pass();
+
+ scoped_ptr<base::DictionaryValue> metadata_copy(new base::DictionaryValue);
+ for (base::DictionaryValue::Iterator it(metadata_); !it.IsAtEnd();
+ it.Advance()) {
+ if (metadata_filter_predicate_.Run(it.key()))
+ metadata_copy->Set(it.key(), it.value().DeepCopy());
+ else
+ metadata_copy->SetString(it.key(), "__stripped__");
+ }
+ return metadata_copy.Pass();
}
scoped_refptr<TracingController::TraceDataSink>
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.cc ('k') | content/public/browser/tracing_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698