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

Unified Diff: net/spdy/spdy_session.cc

Issue 2458793002: Server push cancellation: add PushPromiseHelper which reflects information on the push promise. (Closed)
Patch Set: sync and fix tests Created 4 years, 1 month 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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_session.cc
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index b79c5e62e3d17f2745c369428c8ac35d9d663349..2aba6f394958ebd77fc27a2b5a32d880ca93afea 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -295,6 +295,24 @@ class RequestEquals {
// the server permits more, we will never exceed this limit.
const size_t kMaxConcurrentStreamLimit = 256;
+class SpdyServerPushHelper : public ServerPushDelegate::ServerPushHelper {
+ public:
+ explicit SpdyServerPushHelper(base::WeakPtr<SpdySession> session,
+ const GURL& url)
+ : session_(session), request_url_(url) {}
+
+ void Cancel() override {
+ if (session_)
+ session_->CancelPush(request_url_);
+ }
+
+ const GURL& GetURL() override { return request_url_; }
+
+ private:
+ base::WeakPtr<SpdySession> session_;
+ const GURL request_url_;
+};
+
} // namespace
SpdyProtocolErrorDetails MapFramerErrorToProtocolError(
@@ -644,6 +662,7 @@ SpdySession::SpdySession(const SpdySessionKey& spdy_session_key,
stream_hi_water_mark_(kFirstStreamId),
last_accepted_push_stream_id_(0),
unclaimed_pushed_streams_(this),
+ push_delegate_(nullptr),
num_pushed_streams_(0u),
num_active_pushed_streams_(0u),
bytes_pushed_count_(0u),
@@ -782,6 +801,21 @@ int SpdySession::GetPushStream(const GURL& url,
return OK;
}
+void SpdySession::CancelPush(const GURL& url) {
+ UnclaimedPushedStreamContainer::const_iterator unclaimed_it =
+ unclaimed_pushed_streams_.find(url);
+ if (unclaimed_it == unclaimed_pushed_streams_.end())
+ return;
+
+ SpdyStreamId stream_id = unclaimed_it->second.stream_id;
+
+ if (active_streams_.find(stream_id) == active_streams_.end()) {
+ ResetStream(stream_id, RST_STREAM_CANCEL,
+ "Cancelled push stream with url: " + url.spec());
+ }
+ unclaimed_pushed_streams_.erase(unclaimed_it);
+}
+
// {,Try}CreateStream() can be called with |in_io_loop_| set if a stream is
// being created in response to another being closed due to received data.
@@ -2633,27 +2667,18 @@ bool SpdySession::TryCreatePushStream(SpdyStreamId stream_id,
return false;
}
+ // Notify the push_delegate that a push promise has been received.
+ if (push_delegate_) {
+ push_delegate_->OnPush(base::MakeUnique<SpdyServerPushHelper>(
+ weak_factory_.GetWeakPtr(), gurl));
+ }
+
active_it->second.stream->OnPushPromiseHeadersReceived(std::move(headers));
DCHECK(active_it->second.stream->IsReservedRemote());
num_pushed_streams_++;
return true;
}
-void SpdySession::CancelPush(const GURL& url) {
- UnclaimedPushedStreamContainer::const_iterator unclaimed_it =
- unclaimed_pushed_streams_.find(url);
- if (unclaimed_it == unclaimed_pushed_streams_.end())
- return;
-
- SpdyStreamId stream_id = unclaimed_it->second.stream_id;
-
- if (active_streams_.find(stream_id) == active_streams_.end()) {
- ResetStream(stream_id, RST_STREAM_CANCEL,
- "Cancelled push stream with url: " + url.spec());
- }
- unclaimed_pushed_streams_.erase(unclaimed_it);
-}
-
void SpdySession::OnPushPromise(SpdyStreamId stream_id,
SpdyStreamId promised_stream_id,
SpdyHeaderBlock headers) {
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698