| 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 "net/websockets/websocket_stream_create_test_base.h" | 5 #include "net/websockets/websocket_stream_create_test_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 DeterministicKeyWebSocketHandshakeStreamCreateHelper); | 43 DeterministicKeyWebSocketHandshakeStreamCreateHelper); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class WebSocketStreamCreateTestBase::TestConnectDelegate | 46 class WebSocketStreamCreateTestBase::TestConnectDelegate |
| 47 : public WebSocketStream::ConnectDelegate { | 47 : public WebSocketStream::ConnectDelegate { |
| 48 public: | 48 public: |
| 49 TestConnectDelegate(WebSocketStreamCreateTestBase* owner, | 49 TestConnectDelegate(WebSocketStreamCreateTestBase* owner, |
| 50 const base::Closure& done_callback) | 50 const base::Closure& done_callback) |
| 51 : owner_(owner), done_callback_(done_callback) {} | 51 : owner_(owner), done_callback_(done_callback) {} |
| 52 | 52 |
| 53 void OnCreateRequest(URLRequest* request) override { |
| 54 owner_->url_request_ = request; |
| 55 } |
| 56 |
| 53 void OnSuccess(std::unique_ptr<WebSocketStream> stream) override { | 57 void OnSuccess(std::unique_ptr<WebSocketStream> stream) override { |
| 54 stream.swap(owner_->stream_); | 58 stream.swap(owner_->stream_); |
| 55 done_callback_.Run(); | 59 done_callback_.Run(); |
| 56 } | 60 } |
| 57 | 61 |
| 58 void OnFailure(const std::string& message) override { | 62 void OnFailure(const std::string& message) override { |
| 59 owner_->has_failed_ = true; | 63 owner_->has_failed_ = true; |
| 60 owner_->failure_message_ = message; | 64 owner_->failure_message_ = message; |
| 61 done_callback_.Run(); | 65 done_callback_.Run(); |
| 62 } | 66 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 85 owner_->ssl_fatal_ = fatal; | 89 owner_->ssl_fatal_ = fatal; |
| 86 } | 90 } |
| 87 | 91 |
| 88 private: | 92 private: |
| 89 WebSocketStreamCreateTestBase* owner_; | 93 WebSocketStreamCreateTestBase* owner_; |
| 90 base::Closure done_callback_; | 94 base::Closure done_callback_; |
| 91 DISALLOW_COPY_AND_ASSIGN(TestConnectDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(TestConnectDelegate); |
| 92 }; | 96 }; |
| 93 | 97 |
| 94 WebSocketStreamCreateTestBase::WebSocketStreamCreateTestBase() | 98 WebSocketStreamCreateTestBase::WebSocketStreamCreateTestBase() |
| 95 : has_failed_(false), ssl_fatal_(false) { | 99 : has_failed_(false), ssl_fatal_(false), url_request_(nullptr) {} |
| 96 } | |
| 97 | 100 |
| 98 WebSocketStreamCreateTestBase::~WebSocketStreamCreateTestBase() { | 101 WebSocketStreamCreateTestBase::~WebSocketStreamCreateTestBase() { |
| 99 } | 102 } |
| 100 | 103 |
| 101 void WebSocketStreamCreateTestBase::CreateAndConnectStream( | 104 void WebSocketStreamCreateTestBase::CreateAndConnectStream( |
| 102 const GURL& socket_url, | 105 const GURL& socket_url, |
| 103 const std::vector<std::string>& sub_protocols, | 106 const std::vector<std::string>& sub_protocols, |
| 104 const url::Origin& origin, | 107 const url::Origin& origin, |
| 105 const GURL& first_party_for_cookies, | 108 const GURL& first_party_for_cookies, |
| 106 const std::string& additional_headers, | 109 const std::string& additional_headers, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 149 |
| 147 void WebSocketStreamCreateTestBase::WaitUntilConnectDone() { | 150 void WebSocketStreamCreateTestBase::WaitUntilConnectDone() { |
| 148 connect_run_loop_.Run(); | 151 connect_run_loop_.Run(); |
| 149 } | 152 } |
| 150 | 153 |
| 151 std::vector<std::string> WebSocketStreamCreateTestBase::NoSubProtocols() { | 154 std::vector<std::string> WebSocketStreamCreateTestBase::NoSubProtocols() { |
| 152 return std::vector<std::string>(); | 155 return std::vector<std::string>(); |
| 153 } | 156 } |
| 154 | 157 |
| 155 } // namespace net | 158 } // namespace net |
| OLD | NEW |