OLD | NEW |
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 "net/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "net/spdy/spdy_test_util_common.h" | 36 #include "net/spdy/spdy_test_util_common.h" |
37 #include "net/spdy/spdy_test_utils.h" | 37 #include "net/spdy/spdy_test_utils.h" |
38 #include "net/test/cert_test_util.h" | 38 #include "net/test/cert_test_util.h" |
39 #include "net/test/gtest_util.h" | 39 #include "net/test/gtest_util.h" |
40 #include "net/test/test_data_directory.h" | 40 #include "net/test/test_data_directory.h" |
41 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
42 #include "testing/platform_test.h" | 42 #include "testing/platform_test.h" |
43 | 43 |
44 using net::test::IsError; | 44 using net::test::IsError; |
45 using net::test::IsOk; | 45 using net::test::IsOk; |
| 46 using net::test::TestServerPushDelegate; |
46 | 47 |
47 namespace net { | 48 namespace net { |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 const char kHttpURLFromAnotherOrigin[] = "http://www.example2.org/a.dat"; | 52 const char kHttpURLFromAnotherOrigin[] = "http://www.example2.org/a.dat"; |
52 const char kHttpsURLFromAnotherOrigin[] = "https://www.example2.org/b.dat"; | 53 const char kHttpsURLFromAnotherOrigin[] = "https://www.example2.org/b.dat"; |
53 | 54 |
54 const char kBodyData[] = "Body data"; | 55 const char kBodyData[] = "Body data"; |
55 const size_t kBodyDataSize = arraysize(kBodyData); | 56 const size_t kBodyDataSize = arraysize(kBodyData); |
(...skipping 15 matching lines...) Expand all Loading... |
71 base::TimeTicks InstantaneousReads() { | 72 base::TimeTicks InstantaneousReads() { |
72 return g_time_now; | 73 return g_time_now; |
73 } | 74 } |
74 | 75 |
75 class MockRequireCTDelegate : public TransportSecurityState::RequireCTDelegate { | 76 class MockRequireCTDelegate : public TransportSecurityState::RequireCTDelegate { |
76 public: | 77 public: |
77 MOCK_METHOD1(IsCTRequiredForHost, | 78 MOCK_METHOD1(IsCTRequiredForHost, |
78 CTRequirementLevel(const std::string& host)); | 79 CTRequirementLevel(const std::string& host)); |
79 }; | 80 }; |
80 | 81 |
81 class TestServerPushDelegate : public ServerPushDelegate { | |
82 public: | |
83 explicit TestServerPushDelegate() {} | |
84 | |
85 void OnPush(std::unique_ptr<ServerPushHelper> push_helper) override { | |
86 push_helpers[push_helper->GetURL()] = std::move(push_helper); | |
87 } | |
88 | |
89 bool CancelPush(GURL url) { | |
90 auto itr = push_helpers.find(url); | |
91 if (itr == push_helpers.end()) | |
92 return false; | |
93 | |
94 itr->second->Cancel(); | |
95 push_helpers.erase(itr); | |
96 return true; | |
97 } | |
98 | |
99 private: | |
100 std::map<GURL, std::unique_ptr<ServerPushHelper>> push_helpers; | |
101 }; | |
102 | |
103 } // namespace | 82 } // namespace |
104 | 83 |
105 class SpdySessionTest : public PlatformTest { | 84 class SpdySessionTest : public PlatformTest { |
106 public: | 85 public: |
107 // Functions used with RunResumeAfterUnstallTest(). | 86 // Functions used with RunResumeAfterUnstallTest(). |
108 | 87 |
109 void StallSessionOnly(SpdyStream* stream) { StallSessionSend(); } | 88 void StallSessionOnly(SpdyStream* stream) { StallSessionSend(); } |
110 | 89 |
111 void StallStreamOnly(SpdyStream* stream) { StallStreamSend(stream); } | 90 void StallStreamOnly(SpdyStream* stream) { StallStreamSend(stream); } |
112 | 91 |
(...skipping 5791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5904 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5883 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
5905 "spdy_pooling.pem"); | 5884 "spdy_pooling.pem"); |
5906 ssl_info.is_issued_by_known_root = true; | 5885 ssl_info.is_issued_by_known_root = true; |
5907 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5886 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
5908 | 5887 |
5909 EXPECT_TRUE(SpdySession::CanPool( | 5888 EXPECT_TRUE(SpdySession::CanPool( |
5910 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5889 &tss, ssl_info, "www.example.org", "mail.example.org")); |
5911 } | 5890 } |
5912 | 5891 |
5913 } // namespace net | 5892 } // namespace net |
OLD | NEW |