Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: net/quic/chromium/quic_chromium_client_session.h

Issue 2848923004: Move the "wait for QUIC handshake confirmation" logic to QuicChromiumClientSession::StreamRequest (Closed)
Patch Set: fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/quic/chromium/quic_chromium_client_session.h
diff --git a/net/quic/chromium/quic_chromium_client_session.h b/net/quic/chromium/quic_chromium_client_session.h
index 857aa7efaba934f0003668b856144b5388c32e0e..8576051f88d37eb9b4393b7ae68d56d0befe5523 100644
--- a/net/quic/chromium/quic_chromium_client_session.h
+++ b/net/quic/chromium/quic_chromium_client_session.h
@@ -94,7 +94,25 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
private:
friend class QuicChromiumClientSession;
- StreamRequest(const base::WeakPtr<QuicChromiumClientSession>& session);
+ enum State {
+ STATE_NONE,
+ STATE_WAIT_FOR_CONFIRMATION,
+ STATE_WAIT_FOR_CONFIRMATION_COMPLETE,
+ STATE_REQUEST_STREAM,
+ STATE_REQUEST_STREAM_COMPLETE,
+ };
+
+ StreamRequest(const base::WeakPtr<QuicChromiumClientSession>& session,
+ bool requires_confirmation);
+
+ void OnIOComplete(int rv);
+ void DoCallback(int rv);
+
+ int DoLoop(int rv);
+ int DoWaitForConfirmation();
+ int DoWaitForConfirmationComplete(int rv);
+ int DoRequestStream();
+ int DoRequestStreamComplete(int rv);
// Called by |session_| for an asynchronous request when the stream
// request has finished successfully.
@@ -106,10 +124,14 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
void OnRequestCompleteFailure(int rv);
base::WeakPtr<QuicChromiumClientSession> session_;
+ const bool requires_confirmation_;
CompletionCallback callback_;
QuicChromiumClientStream* stream_;
// For tracking how much time pending stream requests wait.
base::TimeTicks pending_start_time_;
+ State next_state_;
+
+ base::WeakPtrFactory<StreamRequest> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(StreamRequest);
};
@@ -147,7 +169,18 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
- std::unique_ptr<StreamRequest> CreateStreamRequest();
+ // Waits for the handshake to be confirmed and invokes |callback| when
+ // that happens. If the handshake has already been confirmed, returns OK.
+ // If the connection has already been closed, returns a net error. If the
+ // connection closes before the handshake is confirmed, |callback| will
+ // be invoked with an error.
+ int WaitForHandshakeConfirmation(const CompletionCallback& callback);
+
+ // Returns a new stream request which can be used to create a new
+ // QUIC stream. If |requires_confirmation| is true, then the requested
+ // stream will not be created until the handshake as been confirmed.
+ std::unique_ptr<StreamRequest> CreateStreamRequest(
+ bool requires_confirmation);
// Attempts to create a new stream. If the stream can be
// created immediately, returns OK. If the open stream limit
@@ -340,6 +373,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
void CloseAllStreams(int net_error);
void CloseAllObservers(int net_error);
void CancelAllRequests(int net_error);
+ void NotifyRequestsOfConfirmation(int net_error);
// Notifies the factory that this session is going away and no more streams
// should be created from it. This needs to be called before closing any
@@ -366,6 +400,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
bool pkp_bypassed_;
ObserverSet observers_;
StreamRequestQueue stream_requests_;
+ std::vector<CompletionCallback> waiting_for_confirmation_callbacks_;
CompletionCallback callback_;
size_t num_total_streams_;
base::TaskRunner* task_runner_;
« no previous file with comments | « net/quic/chromium/bidirectional_stream_quic_impl_unittest.cc ('k') | net/quic/chromium/quic_chromium_client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698