Commit ed42a1e7 authored by wtc@chromium.org's avatar wtc@chromium.org

Reimplement QuicCryptoClientStream::WasChannelIDSent with a boolean

member so we can free channel_id_key_ after we're finished with it.

This fixes a TODO in https://codereview.chromium.org/355293003/.

R=rch@chromium.org
BUG=none

Review URL: https://codereview.chromium.org/397803004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283569 0039d316-1c4b-4281-b951-d872f2087c98
parent 5096f7f6
...@@ -66,20 +66,6 @@ class TestPacketWriter : public QuicDefaultPacketWriter { ...@@ -66,20 +66,6 @@ class TestPacketWriter : public QuicDefaultPacketWriter {
QuicPacketHeader header_; QuicPacketHeader header_;
}; };
class FakeChannelIDKey : public ChannelIDKey {
public:
// ChannelIDKey implementation
virtual bool Sign(base::StringPiece signed_data,
std::string* out_signature) const OVERRIDE {
*out_signature = "";
return true;
}
virtual std::string SerializeKey() const OVERRIDE {
return "";
}
};
class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> {
protected: protected:
QuicClientSessionTest() QuicClientSessionTest()
...@@ -223,7 +209,7 @@ TEST_P(QuicClientSessionTest, ConnectionPooledWithTlsChannelId) { ...@@ -223,7 +209,7 @@ TEST_P(QuicClientSessionTest, ConnectionPooledWithTlsChannelId) {
session_.OnProofVerifyDetailsAvailable(details); session_.OnProofVerifyDetailsAvailable(details);
CompleteCryptoHandshake(); CompleteCryptoHandshake();
QuicClientSessionPeer::SetChannelIDKey(&session_, new FakeChannelIDKey); QuicClientSessionPeer::SetChannelIDSent(&session_, true);
EXPECT_TRUE(session_.CanPool("www.example.org")); EXPECT_TRUE(session_.CanPool("www.example.org"));
EXPECT_TRUE(session_.CanPool("mail.example.org")); EXPECT_TRUE(session_.CanPool("mail.example.org"));
......
...@@ -78,6 +78,7 @@ QuicCryptoClientStream::QuicCryptoClientStream( ...@@ -78,6 +78,7 @@ QuicCryptoClientStream::QuicCryptoClientStream(
crypto_config_(crypto_config), crypto_config_(crypto_config),
server_id_(server_id), server_id_(server_id),
generation_counter_(0), generation_counter_(0),
channel_id_sent_(false),
channel_id_source_callback_(NULL), channel_id_source_callback_(NULL),
verify_context_(verify_context), verify_context_(verify_context),
proof_verify_callback_(NULL) { proof_verify_callback_(NULL) {
...@@ -110,9 +111,7 @@ int QuicCryptoClientStream::num_sent_client_hellos() const { ...@@ -110,9 +111,7 @@ int QuicCryptoClientStream::num_sent_client_hellos() const {
} }
bool QuicCryptoClientStream::WasChannelIDSent() const { bool QuicCryptoClientStream::WasChannelIDSent() const {
// TODO(rch): we should replace this with a boolean member so we return channel_id_sent_;
// can free the memory associated with the key after we're finished with it.
return channel_id_key_.get() != NULL;
} }
// kMaxClientHellos is the maximum number of times that we'll send a client // kMaxClientHellos is the maximum number of times that we'll send a client
...@@ -203,6 +202,7 @@ void QuicCryptoClientStream::DoHandshakeLoop( ...@@ -203,6 +202,7 @@ void QuicCryptoClientStream::DoHandshakeLoop(
CloseConnectionWithDetails(error, error_details); CloseConnectionWithDetails(error, error_details);
return; return;
} }
channel_id_sent_ = (channel_id_key_.get() != NULL);
if (cached->proof_verify_details()) { if (cached->proof_verify_details()) {
client_session()->OnProofVerifyDetailsAvailable( client_session()->OnProofVerifyDetailsAvailable(
*cached->proof_verify_details()); *cached->proof_verify_details());
......
...@@ -133,6 +133,9 @@ class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { ...@@ -133,6 +133,9 @@ class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream {
// Generation counter from QuicCryptoClientConfig's CachedState. // Generation counter from QuicCryptoClientConfig's CachedState.
uint64 generation_counter_; uint64 generation_counter_;
// True if a channel ID was sent.
bool channel_id_sent_;
// channel_id_source_callback_ contains the callback object that we passed // channel_id_source_callback_ contains the callback object that we passed
// to an asynchronous channel ID lookup. The ChannelIDSource owns this // to an asynchronous channel ID lookup. The ChannelIDSource owns this
// object. // object.
......
...@@ -18,9 +18,9 @@ void QuicClientSessionPeer::SetMaxOpenStreams(QuicClientSession* session, ...@@ -18,9 +18,9 @@ void QuicClientSessionPeer::SetMaxOpenStreams(QuicClientSession* session,
} }
// static // static
void QuicClientSessionPeer::SetChannelIDKey(QuicClientSession* session, void QuicClientSessionPeer::SetChannelIDSent(QuicClientSession* session,
ChannelIDKey* channel_id_key) { bool channel_id_sent) {
session->crypto_stream_->channel_id_key_.reset(channel_id_key); session->crypto_stream_->channel_id_sent_ = channel_id_sent;
} }
} // namespace test } // namespace test
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
namespace net { namespace net {
class ChannelIDKey;
class QuicClientSession; class QuicClientSession;
namespace test { namespace test {
...@@ -20,8 +19,8 @@ class QuicClientSessionPeer { ...@@ -20,8 +19,8 @@ class QuicClientSessionPeer {
size_t max_streams, size_t max_streams,
size_t default_streams); size_t default_streams);
static void SetChannelIDKey(QuicClientSession* session, static void SetChannelIDSent(QuicClientSession* session,
ChannelIDKey* channel_id_key); bool channel_id_sent);
private: private:
DISALLOW_COPY_AND_ASSIGN(QuicClientSessionPeer); DISALLOW_COPY_AND_ASSIGN(QuicClientSessionPeer);
......
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