| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/callback_forward.h" | 7 #include "base/callback_forward.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 base::WeakPtr<std::string> weak_result, | 115 base::WeakPtr<std::string> weak_result, |
| 116 const std::string& cookies) { | 116 const std::string& cookies) { |
| 117 *weak_is_called = true; | 117 *weak_is_called = true; |
| 118 *weak_result = cookies; | 118 *weak_result = cookies; |
| 119 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 119 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
| 120 } | 120 } |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 TEST_P(WebSocketStreamClientUseCookieTest, ClientUseCookie) { | 123 TEST_P(WebSocketStreamClientUseCookieTest, ClientUseCookie) { |
| 124 // For wss tests. | 124 // For wss tests. |
| 125 ssl_data_.push_back(base::WrapUnique(new SSLSocketDataProvider(ASYNC, OK))); | 125 ssl_data_.push_back(base::MakeUnique<SSLSocketDataProvider>(ASYNC, OK)); |
| 126 | 126 |
| 127 CookieStore* store = | 127 CookieStore* store = |
| 128 url_request_context_host_.GetURLRequestContext()->cookie_store(); | 128 url_request_context_host_.GetURLRequestContext()->cookie_store(); |
| 129 | 129 |
| 130 const GURL url(GetParam().url); | 130 const GURL url(GetParam().url); |
| 131 const GURL cookie_url(GetParam().cookie_url); | 131 const GURL cookie_url(GetParam().cookie_url); |
| 132 const url::Origin origin(GURL("http://www.example.com")); | 132 const url::Origin origin(GURL("http://www.example.com")); |
| 133 const GURL first_party_for_cookies("http://www.example.com/"); | 133 const GURL first_party_for_cookies("http://www.example.com/"); |
| 134 const std::string cookie_line(GetParam().cookie_line); | 134 const std::string cookie_line(GetParam().cookie_line); |
| 135 const std::string cookie_header(AddCRLFIfNotEmpty(GetParam().cookie_header)); | 135 const std::string cookie_header(AddCRLFIfNotEmpty(GetParam().cookie_header)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 150 ASSERT_TRUE(set_cookie_result); | 150 ASSERT_TRUE(set_cookie_result); |
| 151 | 151 |
| 152 CreateAndConnect(url, origin, first_party_for_cookies, cookie_header, | 152 CreateAndConnect(url, origin, first_party_for_cookies, cookie_header, |
| 153 WebSocketStandardResponse("")); | 153 WebSocketStandardResponse("")); |
| 154 WaitUntilConnectDone(); | 154 WaitUntilConnectDone(); |
| 155 EXPECT_FALSE(has_failed()); | 155 EXPECT_FALSE(has_failed()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 TEST_P(WebSocketStreamServerSetCookieTest, ServerSetCookie) { | 158 TEST_P(WebSocketStreamServerSetCookieTest, ServerSetCookie) { |
| 159 // For wss tests. | 159 // For wss tests. |
| 160 ssl_data_.push_back(base::WrapUnique(new SSLSocketDataProvider(ASYNC, OK))); | 160 ssl_data_.push_back(base::MakeUnique<SSLSocketDataProvider>(ASYNC, OK)); |
| 161 | 161 |
| 162 const GURL url(GetParam().url); | 162 const GURL url(GetParam().url); |
| 163 const GURL cookie_url(GetParam().cookie_url); | 163 const GURL cookie_url(GetParam().cookie_url); |
| 164 const url::Origin origin(GURL("http://www.example.com")); | 164 const url::Origin origin(GURL("http://www.example.com")); |
| 165 const GURL first_party_for_cookies("http://www.example.com/"); | 165 const GURL first_party_for_cookies("http://www.example.com/"); |
| 166 const std::string cookie_line(GetParam().cookie_line); | 166 const std::string cookie_line(GetParam().cookie_line); |
| 167 const std::string cookie_header(AddCRLFIfNotEmpty(GetParam().cookie_header)); | 167 const std::string cookie_header(AddCRLFIfNotEmpty(GetParam().cookie_header)); |
| 168 | 168 |
| 169 const std::string response = base::StringPrintf( | 169 const std::string response = base::StringPrintf( |
| 170 "HTTP/1.1 101 Switching Protocols\r\n" | 170 "HTTP/1.1 101 Switching Protocols\r\n" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 "", | 503 "", |
| 504 "Set-Cookie: test-cookie"}, | 504 "Set-Cookie: test-cookie"}, |
| 505 }; | 505 }; |
| 506 | 506 |
| 507 INSTANTIATE_TEST_CASE_P(WebSocketStreamServerSetCookieTest, | 507 INSTANTIATE_TEST_CASE_P(WebSocketStreamServerSetCookieTest, |
| 508 WebSocketStreamServerSetCookieTest, | 508 WebSocketStreamServerSetCookieTest, |
| 509 ValuesIn(kServerSetCookieParameters)); | 509 ValuesIn(kServerSetCookieParameters)); |
| 510 | 510 |
| 511 } // namespace | 511 } // namespace |
| 512 } // namespace net | 512 } // namespace net |
| OLD | NEW |