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

Side by Side Diff: base/trace_event/trace_event_impl.cc

Issue 1115343002: Added a whitelist for trace events that are known to be PII-less. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved whitelist to chrome Created 5 years, 7 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 // 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 #include "base/trace_event/trace_event_impl.h" 5 #include "base/trace_event/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // trace. 61 // trace.
62 const int kOverheadReportThresholdInMicroseconds = 50; 62 const int kOverheadReportThresholdInMicroseconds = 50;
63 63
64 // String options that can be used to initialize TraceOptions. 64 // String options that can be used to initialize TraceOptions.
65 const char kRecordUntilFull[] = "record-until-full"; 65 const char kRecordUntilFull[] = "record-until-full";
66 const char kRecordContinuously[] = "record-continuously"; 66 const char kRecordContinuously[] = "record-continuously";
67 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible"; 67 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible";
68 const char kTraceToConsole[] = "trace-to-console"; 68 const char kTraceToConsole[] = "trace-to-console";
69 const char kEnableSampling[] = "enable-sampling"; 69 const char kEnableSampling[] = "enable-sampling";
70 const char kEnableSystrace[] = "enable-systrace"; 70 const char kEnableSystrace[] = "enable-systrace";
71 const char kEnableArgsWhitelist[] = "enable-args-whitelist";
71 72
72 // Controls the number of trace events we will buffer in-memory 73 // Controls the number of trace events we will buffer in-memory
73 // before throwing them away. 74 // before throwing them away.
74 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; 75 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize;
75 const size_t kTraceEventVectorBigBufferChunks = 76 const size_t kTraceEventVectorBigBufferChunks =
76 512000000 / kTraceBufferChunkSize; 77 512000000 / kTraceBufferChunkSize;
77 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; 78 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize;
78 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; 79 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4;
79 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; 80 const size_t kTraceEventBufferSizeInBytes = 100 * 1024;
80 // Can store results for 30 seconds with 1 ms sampling interval. 81 // Can store results for 30 seconds with 1 ms sampling interval.
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } else if (*iter == kRecordContinuously) { 1008 } else if (*iter == kRecordContinuously) {
1008 record_mode = RECORD_CONTINUOUSLY; 1009 record_mode = RECORD_CONTINUOUSLY;
1009 } else if (*iter == kTraceToConsole) { 1010 } else if (*iter == kTraceToConsole) {
1010 record_mode = ECHO_TO_CONSOLE; 1011 record_mode = ECHO_TO_CONSOLE;
1011 } else if (*iter == kRecordAsMuchAsPossible) { 1012 } else if (*iter == kRecordAsMuchAsPossible) {
1012 record_mode = RECORD_AS_MUCH_AS_POSSIBLE; 1013 record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
1013 } else if (*iter == kEnableSampling) { 1014 } else if (*iter == kEnableSampling) {
1014 enable_sampling = true; 1015 enable_sampling = true;
1015 } else if (*iter == kEnableSystrace) { 1016 } else if (*iter == kEnableSystrace) {
1016 enable_systrace = true; 1017 enable_systrace = true;
1018 } else if (*iter == kEnableArgsWhitelist) {
1019 enable_args_whitelist = true;
1017 } else { 1020 } else {
1018 return false; 1021 return false;
1019 } 1022 }
1020 } 1023 }
1021 return true; 1024 return true;
1022 } 1025 }
1023 1026
1024 std::string TraceOptions::ToString() const { 1027 std::string TraceOptions::ToString() const {
1025 std::string ret; 1028 std::string ret;
1026 switch (record_mode) { 1029 switch (record_mode) {
1027 case RECORD_UNTIL_FULL: 1030 case RECORD_UNTIL_FULL:
1028 ret = kRecordUntilFull; 1031 ret = kRecordUntilFull;
1029 break; 1032 break;
1030 case RECORD_CONTINUOUSLY: 1033 case RECORD_CONTINUOUSLY:
1031 ret = kRecordContinuously; 1034 ret = kRecordContinuously;
1032 break; 1035 break;
1033 case ECHO_TO_CONSOLE: 1036 case ECHO_TO_CONSOLE:
1034 ret = kTraceToConsole; 1037 ret = kTraceToConsole;
1035 break; 1038 break;
1036 case RECORD_AS_MUCH_AS_POSSIBLE: 1039 case RECORD_AS_MUCH_AS_POSSIBLE:
1037 ret = kRecordAsMuchAsPossible; 1040 ret = kRecordAsMuchAsPossible;
1038 break; 1041 break;
1039 default: 1042 default:
1040 NOTREACHED(); 1043 NOTREACHED();
1041 } 1044 }
1042 if (enable_sampling) 1045 if (enable_sampling)
1043 ret = ret + "," + kEnableSampling; 1046 ret = ret + "," + kEnableSampling;
1044 if (enable_systrace) 1047 if (enable_systrace)
1045 ret = ret + "," + kEnableSystrace; 1048 ret = ret + "," + kEnableSystrace;
1049 if (enable_args_whitelist)
1050 ret = ret + "," + kEnableArgsWhitelist;
1046 return ret; 1051 return ret;
1047 } 1052 }
1048 1053
1049 //////////////////////////////////////////////////////////////////////////////// 1054 ////////////////////////////////////////////////////////////////////////////////
1050 // 1055 //
1051 // TraceLog 1056 // TraceLog
1052 // 1057 //
1053 //////////////////////////////////////////////////////////////////////////////// 1058 ////////////////////////////////////////////////////////////////////////////////
1054 1059
1055 class TraceLog::ThreadLocalEventBuffer 1060 class TraceLog::ThreadLocalEventBuffer
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1498
1494 { 1499 {
1495 AutoLock lock(lock_); 1500 AutoLock lock(lock_);
1496 dispatching_to_observer_list_ = false; 1501 dispatching_to_observer_list_ = false;
1497 } 1502 }
1498 } 1503 }
1499 1504
1500 void TraceLog::SetEventFilterPredicate( 1505 void TraceLog::SetEventFilterPredicate(
1501 const TraceEvent::EventFilterPredicate& event_filter_predicate) { 1506 const TraceEvent::EventFilterPredicate& event_filter_predicate) {
1502 AutoLock lock(lock_); 1507 AutoLock lock(lock_);
1508 DCHECK(!event_filter_predicate.is_null());
1503 event_filter_predicate_ = event_filter_predicate; 1509 event_filter_predicate_ = event_filter_predicate;
1504 } 1510 }
1505 1511
1506 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions( 1512 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions(
1507 const TraceOptions& options) { 1513 const TraceOptions& options) {
1508 InternalTraceOptions ret = 1514 InternalTraceOptions ret =
1509 options.enable_sampling ? kInternalEnableSampling : kInternalNone; 1515 options.enable_sampling ? kInternalEnableSampling : kInternalNone;
1516 if (options.enable_args_whitelist)
1517 ret |= kInternalEnableArgsWhitelist;
1510 switch (options.record_mode) { 1518 switch (options.record_mode) {
1511 case RECORD_UNTIL_FULL: 1519 case RECORD_UNTIL_FULL:
1512 return ret | kInternalRecordUntilFull; 1520 return ret | kInternalRecordUntilFull;
1513 case RECORD_CONTINUOUSLY: 1521 case RECORD_CONTINUOUSLY:
1514 return ret | kInternalRecordContinuously; 1522 return ret | kInternalRecordContinuously;
1515 case ECHO_TO_CONSOLE: 1523 case ECHO_TO_CONSOLE:
1516 return ret | kInternalEchoToConsole; 1524 return ret | kInternalEchoToConsole;
1517 case RECORD_AS_MUCH_AS_POSSIBLE: 1525 case RECORD_AS_MUCH_AS_POSSIBLE:
1518 return ret | kInternalRecordAsMuchAsPossible; 1526 return ret | kInternalRecordAsMuchAsPossible;
1519 } 1527 }
1520 NOTREACHED(); 1528 NOTREACHED();
1521 return kInternalNone; 1529 return kInternalNone;
1522 } 1530 }
1523 1531
1524 CategoryFilter TraceLog::GetCurrentCategoryFilter() { 1532 CategoryFilter TraceLog::GetCurrentCategoryFilter() {
1525 AutoLock lock(lock_); 1533 AutoLock lock(lock_);
1526 return category_filter_; 1534 return category_filter_;
1527 } 1535 }
1528 1536
1529 TraceOptions TraceLog::GetCurrentTraceOptions() const { 1537 TraceOptions TraceLog::GetCurrentTraceOptions() const {
1530 TraceOptions ret; 1538 TraceOptions ret;
1531 InternalTraceOptions option = trace_options(); 1539 InternalTraceOptions option = trace_options();
1532 ret.enable_sampling = (option & kInternalEnableSampling) != 0; 1540 ret.enable_sampling = (option & kInternalEnableSampling) != 0;
1541 ret.enable_args_whitelist = (option & kInternalEnableArgsWhitelist) != 0;
1533 if (option & kInternalRecordUntilFull) 1542 if (option & kInternalRecordUntilFull)
1534 ret.record_mode = RECORD_UNTIL_FULL; 1543 ret.record_mode = RECORD_UNTIL_FULL;
1535 else if (option & kInternalRecordContinuously) 1544 else if (option & kInternalRecordContinuously)
1536 ret.record_mode = RECORD_CONTINUOUSLY; 1545 ret.record_mode = RECORD_CONTINUOUSLY;
1537 else if (option & kInternalEchoToConsole) 1546 else if (option & kInternalEchoToConsole)
1538 ret.record_mode = ECHO_TO_CONSOLE; 1547 ret.record_mode = ECHO_TO_CONSOLE;
1539 else if (option & kInternalRecordAsMuchAsPossible) 1548 else if (option & kInternalRecordAsMuchAsPossible)
1540 ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE; 1549 ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
1541 else 1550 else
1542 NOTREACHED(); 1551 NOTREACHED();
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 } 2675 }
2667 2676
2668 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2677 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2669 if (*category_group_enabled_) { 2678 if (*category_group_enabled_) {
2670 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2679 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2671 name_, event_handle_); 2680 name_, event_handle_);
2672 } 2681 }
2673 } 2682 }
2674 2683
2675 } // namespace trace_event_internal 2684 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698