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