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

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: Async error 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 262265340a524f2561affab7bd7d8e56eab6fc49..a4c0e8496110bb583aeef92d2a724d31c063befb 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_;
+ bool requires_confirmation_;
xunjieli 2017/05/01 20:15:06 nit: add a const so we know this variable is not c
Ryan Hamilton 2017/05/01 21:42:35 Done.
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 an new stream request which can be used to create a new
xunjieli 2017/05/01 20:15:06 nit: s/an/a
Ryan Hamilton 2017/05/01 21:42:35 Done.
+ // QUIC stream. If |requires_confirmation| is true, then the requested
+ // stream will no be created until the handshake as been confirmed.
xunjieli 2017/05/01 20:15:06 nit: s/will no/will not s/as/has
Ryan Hamilton 2017/05/01 21:42:35 Done.
+ 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
@@ -352,6 +385,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
void CloseAllStreams(int net_error);
void CloseAllObservers(int net_error);
void CancelAllRequests(int net_error);
+ void NotifyAllWaitingForConfirmation(int net_error);
xunjieli 2017/05/01 20:15:06 nit: maybe mention "Request" or "StreamRequest" so
Ryan Hamilton 2017/05/01 21:42:35 Done.
// 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
@@ -378,6 +412,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_;

Powered by Google App Engine
This is Rietveld 408576698