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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 19866006: [Net] Propagate priority changes from HttpNetworkTransaction to its request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_stream_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction_unittest.cc
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 64e0026668c38ad94ba47f18adfb61ee85b9704a..a565b4ab8202d34e38c154ecce6aaa2238709015 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -11679,4 +11679,80 @@ TEST_P(HttpNetworkTransactionTest, GetFullRequestHeadersIncludesExtraHeader) {
EXPECT_EQ("bar", foo);
}
+// Make sure that SetPriority actually sets the
+// HttpNetworkTransaction's priority.
+TEST_P(HttpNetworkTransactionTest, SetPriorityBasic) {
+ scoped_ptr<HttpNetworkTransaction> trans(
+ new HttpNetworkTransaction(
+ DEFAULT_PRIORITY, CreateSession(&session_deps_)));
+ EXPECT_EQ(DEFAULT_PRIORITY, trans->priority_);
+
+ trans->SetPriority(LOWEST);
+ EXPECT_EQ(LOWEST, trans->priority_);
+
+ trans->SetPriority(LOW);
+ EXPECT_EQ(LOW, trans->priority_);
+}
+
+namespace {
+
+// Fake HttpStreamRequest that simply records calls to SetPriority().
+class FakeStreamRequest : public HttpStreamRequest {
+ public:
+ FakeStreamRequest() : priority_(DEFAULT_PRIORITY) {}
+ virtual ~FakeStreamRequest() {}
+
+ RequestPriority priority() const { return priority_; }
+
+ virtual int RestartTunnelWithProxyAuth(
+ const AuthCredentials& credentials) OVERRIDE {
+ ADD_FAILURE();
+ return ERR_UNEXPECTED;
+ }
+
+ virtual LoadState GetLoadState() const OVERRIDE {
+ ADD_FAILURE();
+ return LoadState();
+ }
+
+ virtual void SetPriority(RequestPriority priority) OVERRIDE {
+ priority_ = priority;
+ }
+
+ virtual bool was_npn_negotiated() const OVERRIDE {
+ ADD_FAILURE();
+ return false;
+ }
+
+ virtual NextProto protocol_negotiated() const OVERRIDE {
+ ADD_FAILURE();
+ return kProtoUnknown;
+ }
+
+ virtual bool using_spdy() const OVERRIDE {
+ ADD_FAILURE();
+ return false;
+ }
+
+ private:
+ RequestPriority priority_;
+};
+
+} // namespace
+
+// Make sure that HttpNetworkTransaction passes on its priority
+// updates to its stream request.
+TEST_P(HttpNetworkTransactionTest, SetStreamRequestPriority) {
+ scoped_ptr<HttpNetworkTransaction> trans(
+ new HttpNetworkTransaction(
+ DEFAULT_PRIORITY, CreateSession(&session_deps_)));
+ EXPECT_EQ(DEFAULT_PRIORITY, trans->priority_);
+
+ FakeStreamRequest* request = new FakeStreamRequest();
+ trans->stream_request_.reset(request);
+
+ trans->SetPriority(MEDIUM);
+ EXPECT_EQ(MEDIUM, request->priority());
mmenke 2013/07/23 18:33:33 Again, these requests that just write directly to
akalin 2013/08/09 18:53:35 Ah, I was missing HttpNetworkSessionPeer. Rewrote
+}
+
} // namespace net
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_stream_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698