| 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 |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/trace_event/trace_buffer.h" | 17 #include "base/trace_event/trace_buffer.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "base/trace_event/trace_event_impl.h" | 19 #include "base/trace_event/trace_event_impl.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "net/log/net_log.h" | |
| 22 #include "net/log/net_log_event_type.h" | 21 #include "net/log/net_log_event_type.h" |
| 22 #include "net/log/net_log_parameters_callback_typedef.h" |
| 23 #include "net/log/net_log_source_type.h" | 23 #include "net/log/net_log_source_type.h" |
| 24 #include "net/log/net_log_with_source.h" |
| 24 #include "net/log/test_net_log.h" | 25 #include "net/log/test_net_log.h" |
| 25 #include "net/log/test_net_log_entry.h" | 26 #include "net/log/test_net_log_entry.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 using base::trace_event::TraceLog; | 29 using base::trace_event::TraceLog; |
| 29 | 30 |
| 30 namespace net { | 31 namespace net { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 318 |
| 318 TestNetLogEntry::List entries; | 319 TestNetLogEntry::List entries; |
| 319 net_log()->GetEntries(&entries); | 320 net_log()->GetEntries(&entries); |
| 320 EXPECT_EQ(3u, entries.size()); | 321 EXPECT_EQ(3u, entries.size()); |
| 321 EXPECT_EQ(0u, trace_events()->GetSize()); | 322 EXPECT_EQ(0u, trace_events()->GetSize()); |
| 322 } | 323 } |
| 323 | 324 |
| 324 TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) { | 325 TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) { |
| 325 trace_net_log_observer()->WatchForTraceStart(net_log()); | 326 trace_net_log_observer()->WatchForTraceStart(net_log()); |
| 326 EnableTraceLog(); | 327 EnableTraceLog(); |
| 327 NetLog::ParametersCallback net_log_callback; | 328 NetLogParametersCallback net_log_callback; |
| 328 std::string param = "bar"; | 329 std::string param = "bar"; |
| 329 net_log_callback = NetLog::StringCallback("foo", ¶m); | 330 net_log_callback = NetLog::StringCallback("foo", ¶m); |
| 330 | 331 |
| 331 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED, net_log_callback); | 332 net_log()->AddGlobalEntry(NetLogEventType::CANCELLED, net_log_callback); |
| 332 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE); | 333 net_log()->AddGlobalEntry(NetLogEventType::REQUEST_ALIVE); |
| 333 | 334 |
| 334 EndTraceAndFlush(); | 335 EndTraceAndFlush(); |
| 335 trace_net_log_observer()->StopWatchForTraceStart(); | 336 trace_net_log_observer()->StopWatchForTraceStart(); |
| 336 | 337 |
| 337 TestNetLogEntry::List entries; | 338 TestNetLogEntry::List entries; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 368 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); | 369 EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); |
| 369 EXPECT_EQ("bar", item1_params); | 370 EXPECT_EQ("bar", item1_params); |
| 370 | 371 |
| 371 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); | 372 EXPECT_TRUE(item2->GetString("args.params", &item2_params)); |
| 372 EXPECT_TRUE(item2_params.empty()); | 373 EXPECT_TRUE(item2_params.empty()); |
| 373 } | 374 } |
| 374 | 375 |
| 375 } // namespace | 376 } // namespace |
| 376 | 377 |
| 377 } // namespace net | 378 } // namespace net |
| OLD | NEW |