| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/log/trace_net_log_observer.h" | 5 #include "net/log/trace_net_log_observer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED); | 312 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED); |
| 313 trace_net_log_observer()->StopWatchForTraceStart(); | 313 trace_net_log_observer()->StopWatchForTraceStart(); |
| 314 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE); | 314 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE); |
| 315 net_log()->AddGlobalEntry(NetLogEventType::URL_REQUEST_START_JOB); | 315 net_log()->AddGlobalEntry(NetLogEventType::URL_REQUEST_START_JOB); |
| 316 | 316 |
| 317 EndTraceAndFlush(); | 317 EndTraceAndFlush(); |
| 318 | 318 |
| 319 TestNetLogEntry::List entries; | 319 TestNetLogEntry::List entries; |
| 320 net_log()->GetEntries(&entries); | 320 net_log()->GetEntries(&entries); |
| 321 EXPECT_EQ(3u, entries.size()); | 321 EXPECT_EQ(3u, entries.size()); |
| 322 EXPECT_EQ(1u, trace_events()->GetSize()); |
| 323 } |
| 324 |
| 325 TEST_F(TraceNetLogObserverTest, |
| 326 CreateObserverAfterTracingStartsDisabledCategory) { |
| 327 set_trace_net_log_observer(nullptr); |
| 328 |
| 329 std::string disabled_netlog_category = |
| 330 std::string("-") + kNetLogTracingCategory; |
| 331 TraceLog::GetInstance()->SetEnabled( |
| 332 base::trace_event::TraceConfig(disabled_netlog_category, ""), |
| 333 TraceLog::RECORDING_MODE); |
| 334 |
| 335 set_trace_net_log_observer(new TraceNetLogObserver()); |
| 336 trace_net_log_observer()->WatchForTraceStart(net_log()); |
| 337 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED); |
| 338 trace_net_log_observer()->StopWatchForTraceStart(); |
| 339 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE); |
| 340 net_log()->AddGlobalEntry(NetLogEventType::URL_REQUEST_START_JOB); |
| 341 |
| 342 EndTraceAndFlush(); |
| 343 |
| 344 TestNetLogEntry::List entries; |
| 345 net_log()->GetEntries(&entries); |
| 346 EXPECT_EQ(3u, entries.size()); |
| 322 EXPECT_EQ(0u, trace_events()->GetSize()); | 347 EXPECT_EQ(0u, trace_events()->GetSize()); |
| 323 } | 348 } |
| 324 | 349 |
| 325 TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) { | 350 TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) { |
| 326 trace_net_log_observer()->WatchForTraceStart(net_log()); | 351 trace_net_log_observer()->WatchForTraceStart(net_log()); |
| 327 EnableTraceLog(); | 352 EnableTraceLog(); |
| 328 NetLogParametersCallback net_log_callback; | 353 NetLogParametersCallback net_log_callback; |
| 329 std::string param = "bar"; | 354 std::string param = "bar"; |
| 330 net_log_callback = NetLog::StringCallback("foo", ¶m); | 355 net_log_callback = NetLog::StringCallback("foo", ¶m); |
| 331 | 356 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); | 394 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); |
| 370 EXPECT_EQ("bar", item1_params); | 395 EXPECT_EQ("bar", item1_params); |
| 371 | 396 |
| 372 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); | 397 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); |
| 373 EXPECT_TRUE(item2_params.empty()); | 398 EXPECT_TRUE(item2_params.empty()); |
| 374 } | 399 } |
| 375 | 400 |
| 376 } // namespace | 401 } // namespace |
| 377 | 402 |
| 378 } // namespace net | 403 } // namespace net |
| OLD | NEW |