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

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

Issue 1067233002: Added a trace option for whitewashing trace args against a known-PII-less list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just base/trace/event/* 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 <math.h> 5 #include <math.h>
6 #include <cstdlib> 6 #include <cstdlib>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 EXPECT_EQ(0, int_value); 2197 EXPECT_EQ(0, int_value);
2198 2198
2199 dict = FindNamePhase("event15", "X"); 2199 dict = FindNamePhase("event15", "X");
2200 ASSERT_TRUE(dict); 2200 ASSERT_TRUE(dict);
2201 dict->GetDictionary("args", &args_dict); 2201 dict->GetDictionary("args", &args_dict);
2202 ASSERT_TRUE(args_dict); 2202 ASSERT_TRUE(args_dict);
2203 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); 2203 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value));
2204 EXPECT_EQ(1, int_value); 2204 EXPECT_EQ(1, int_value);
2205 } 2205 }
2206 2206
2207 namespace {
2208
2209 bool IsTraceEventArgsWhitelisted(const char* category_group_name,
2210 const char* event_name) {
2211 if (MatchPattern(category_group_name, "toplevel") &&
2212 MatchPattern(event_name, "*")) {
2213 return true;
2214 }
2215
2216 return false;
2217 }
2218
2219 } // namespace
2220
2221 TEST_F(TraceEventTestFixture, ArgsWhitelisting) {
2222 TraceOptions trace_options;
2223 trace_options.enable_args_whitelist = true;
2224 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
2225 TraceLog::RECORDING_MODE, trace_options);
2226
2227 TraceLog::GetInstance()->SetEventFilterPredicate(
2228 base::Bind(&IsTraceEventArgsWhitelisted));
2229
2230 TRACE_EVENT1("toplevel", "event1", "int_one", 1);
2231 TRACE_EVENT1("whitewashed", "event2", "int_two", 1);
2232 EndTraceAndFlush();
2233
2234 const DictionaryValue* args_dict = NULL;
2235 DictionaryValue* dict = NULL;
2236 int int_value;
2237
2238 dict = FindNamePhase("event1", "X");
2239 ASSERT_TRUE(dict);
2240 dict->GetDictionary("args", &args_dict);
2241 ASSERT_TRUE(args_dict);
2242 EXPECT_TRUE(args_dict->GetInteger("int_one", &int_value));
2243 EXPECT_EQ(1, int_value);
2244
2245 dict = FindNamePhase("event2", "X");
2246 ASSERT_TRUE(dict);
2247 dict->GetDictionary("args", &args_dict);
2248 ASSERT_TRUE(args_dict);
2249 EXPECT_FALSE(args_dict->GetInteger("int_two", &int_value));
2250 EXPECT_TRUE(args_dict->GetInteger("stripped", &int_value));
2251 }
2252
2207 class TraceEventCallbackTest : public TraceEventTestFixture { 2253 class TraceEventCallbackTest : public TraceEventTestFixture {
2208 public: 2254 public:
2209 void SetUp() override { 2255 void SetUp() override {
2210 TraceEventTestFixture::SetUp(); 2256 TraceEventTestFixture::SetUp();
2211 ASSERT_EQ(NULL, s_instance); 2257 ASSERT_EQ(NULL, s_instance);
2212 s_instance = this; 2258 s_instance = this;
2213 } 2259 }
2214 void TearDown() override { 2260 void TearDown() override {
2215 TraceLog::GetInstance()->SetDisabled(); 2261 TraceLog::GetInstance()->SetDisabled();
2216 ASSERT_TRUE(!!s_instance); 2262 ASSERT_TRUE(!!s_instance);
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 EXPECT_EQ(original_option.record_mode, new_options.record_mode); 3120 EXPECT_EQ(original_option.record_mode, new_options.record_mode);
3075 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); 3121 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling);
3076 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); 3122 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace);
3077 } 3123 }
3078 } 3124 }
3079 } 3125 }
3080 } 3126 }
3081 3127
3082 } // namespace trace_event 3128 } // namespace trace_event
3083 } // namespace base 3129 } // namespace base
OLDNEW
« base/trace_event/trace_event_impl.h ('K') | « base/trace_event/trace_event_impl_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698