Commit 7d0c74d5 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Use base::Optional for handshake_challenge_for_testing_.

Change-Id: I2c14a7c94d55b38b303a6b827fd5d1d06a8feca4
Reviewed-on: https://chromium-review.googlesource.com/946151
Commit-Queue: Adam Rice <ricea@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540793}
parent edaff9fe
......@@ -342,8 +342,8 @@ int WebSocketBasicHandshakeStream::SendRequest(
HttpRequestHeaders enriched_headers;
enriched_headers.CopyFrom(headers);
std::string handshake_challenge;
if (handshake_challenge_for_testing_) {
handshake_challenge = *handshake_challenge_for_testing_;
if (handshake_challenge_for_testing_.has_value()) {
handshake_challenge = handshake_challenge_for_testing_.value();
handshake_challenge_for_testing_.reset();
} else {
handshake_challenge = GenerateHandshakeChallenge();
......@@ -508,7 +508,7 @@ std::unique_ptr<WebSocketStream> WebSocketBasicHandshakeStream::Upgrade() {
void WebSocketBasicHandshakeStream::SetWebSocketKeyForTesting(
const std::string& key) {
handshake_challenge_for_testing_.reset(new std::string(key));
handshake_challenge_for_testing_ = key;
}
void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback(
......
......@@ -13,6 +13,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "net/base/completion_once_callback.h"
#include "net/base/net_export.h"
#include "net/http/http_basic_state.h"
......@@ -122,7 +123,7 @@ class NET_EXPORT_PRIVATE WebSocketBasicHandshakeStream
// The key to be sent in the next Sec-WebSocket-Key header. Usually NULL (the
// key is generated on the fly).
std::unique_ptr<std::string> handshake_challenge_for_testing_;
base::Optional<std::string> handshake_challenge_for_testing_;
// The required value for the Sec-WebSocket-Accept header.
std::string handshake_challenge_response_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment