| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/bounded_file_net_log_observer.h" | 5 #include "net/log/bounded_file_net_log_observer.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 765 |
| 766 logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, | 766 logger_->StartObserving(&net_log_, log_path_, nullptr, nullptr, |
| 767 kLargeFileSize, kTotalNumFiles); | 767 kLargeFileSize, kTotalNumFiles); |
| 768 | 768 |
| 769 // Create unique context. | 769 // Create unique context. |
| 770 TestURLRequestContext context(true); | 770 TestURLRequestContext context(true); |
| 771 context.set_net_log(&net_log_); | 771 context.set_net_log(&net_log_); |
| 772 const int kDummyParam = 75; | 772 const int kDummyParam = 75; |
| 773 std::unique_ptr<HttpNetworkSession::Params> params( | 773 std::unique_ptr<HttpNetworkSession::Params> params( |
| 774 new HttpNetworkSession::Params); | 774 new HttpNetworkSession::Params); |
| 775 params->quic_max_number_of_lossy_connections = kDummyParam; |
| 775 params->quic_idle_connection_timeout_seconds = kDummyParam; | 776 params->quic_idle_connection_timeout_seconds = kDummyParam; |
| 776 context.set_http_network_session_params(std::move(params)); | 777 context.set_http_network_session_params(std::move(params)); |
| 777 context.Init(); | 778 context.Init(); |
| 778 | 779 |
| 779 logger_->StopObserving(&context, closure.closure()); | 780 logger_->StopObserving(&context, closure.closure()); |
| 780 | 781 |
| 781 closure.WaitForResult(); | 782 closure.WaitForResult(); |
| 782 | 783 |
| 783 std::string input; | 784 std::string input; |
| 784 AddAllFiles(&input); | 785 AddAllFiles(&input); |
| 785 ASSERT_FALSE(input.empty()); | 786 ASSERT_FALSE(input.empty()); |
| 786 | 787 |
| 787 base::JSONReader reader; | 788 base::JSONReader reader; |
| 788 std::unique_ptr<base::Value> root(reader.ReadToValue(input)); | 789 std::unique_ptr<base::Value> root(reader.ReadToValue(input)); |
| 789 ASSERT_TRUE(root) << reader.GetErrorMessage(); | 790 ASSERT_TRUE(root) << reader.GetErrorMessage(); |
| 790 | 791 |
| 791 // Check that no events were written. | 792 // Check that no events were written. |
| 792 base::DictionaryValue* dict; | 793 base::DictionaryValue* dict; |
| 793 ASSERT_TRUE(root->GetAsDictionary(&dict)); | 794 ASSERT_TRUE(root->GetAsDictionary(&dict)); |
| 794 base::ListValue* events; | 795 base::ListValue* events; |
| 795 ASSERT_TRUE(dict->GetList("events", &events)); | 796 ASSERT_TRUE(dict->GetList("events", &events)); |
| 796 ASSERT_EQ(0u, events->GetSize()); | 797 ASSERT_EQ(0u, events->GetSize()); |
| 797 | 798 |
| 798 // Make sure additional information is present and validate it. | 799 // Make sure additional information is present and validate it. |
| 799 base::DictionaryValue* tab_info; | 800 base::DictionaryValue* tab_info; |
| 800 base::DictionaryValue* quic_info; | 801 base::DictionaryValue* quic_info; |
| 801 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); | 802 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); |
| 802 ASSERT_TRUE(tab_info->GetDictionary("quicInfo", &quic_info)); | 803 ASSERT_TRUE(tab_info->GetDictionary("quicInfo", &quic_info)); |
| 803 base::Value* timeout_value = nullptr; | 804 base::Value* timeout_value = nullptr; |
| 804 int timeout; | 805 base::Value* lossy_value = nullptr; |
| 806 int timeout, lossy; |
| 805 ASSERT_TRUE( | 807 ASSERT_TRUE( |
| 806 quic_info->Get("idle_connection_timeout_seconds", &timeout_value)); | 808 quic_info->Get("idle_connection_timeout_seconds", &timeout_value)); |
| 807 ASSERT_TRUE(timeout_value->GetAsInteger(&timeout)); | 809 ASSERT_TRUE(timeout_value->GetAsInteger(&timeout)); |
| 808 ASSERT_EQ(timeout, kDummyParam); | 810 ASSERT_EQ(timeout, kDummyParam); |
| 811 ASSERT_TRUE(quic_info->Get("max_number_of_lossy_connections", &lossy_value)); |
| 812 ASSERT_TRUE(lossy_value->GetAsInteger(&lossy)); |
| 813 ASSERT_EQ(lossy, kDummyParam); |
| 809 } | 814 } |
| 810 | 815 |
| 811 TEST_F(BoundedFileNetLogObserverTest, | 816 TEST_F(BoundedFileNetLogObserverTest, |
| 812 GeneratesValidJSONWithContextWithActiveRequest) { | 817 GeneratesValidJSONWithContextWithActiveRequest) { |
| 813 TestClosure closure; | 818 TestClosure closure; |
| 814 | 819 |
| 815 // Create context, start a request. | 820 // Create context, start a request. |
| 816 TestURLRequestContext context(true); | 821 TestURLRequestContext context(true); |
| 817 context.set_net_log(&net_log_); | 822 context.set_net_log(&net_log_); |
| 818 context.Init(); | 823 context.Init(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 847 ASSERT_EQ(1u, events->GetSize()); | 852 ASSERT_EQ(1u, events->GetSize()); |
| 848 | 853 |
| 849 // Make sure additional information is present, but don't validate it. | 854 // Make sure additional information is present, but don't validate it. |
| 850 base::DictionaryValue* tab_info; | 855 base::DictionaryValue* tab_info; |
| 851 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); | 856 ASSERT_TRUE(dict->GetDictionary("tabInfo", &tab_info)); |
| 852 } | 857 } |
| 853 | 858 |
| 854 } // namespace | 859 } // namespace |
| 855 | 860 |
| 856 } // namespace net | 861 } // namespace net |
| OLD | NEW |