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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 1866483002: Add a new priority level, THROTTLED, below IDLE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated comments. Created 4 years, 7 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 unified diff | Download patch
« net/quic/quic_http_utils_test.cc ('K') | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 7889 matching lines...) Expand 10 before | Expand all | Expand 10 after
7900 std::unique_ptr<URLRequest> req( 7900 std::unique_ptr<URLRequest> req(
7901 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d)); 7901 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d));
7902 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE); 7902 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE);
7903 7903
7904 req->Start(); 7904 req->Start();
7905 base::RunLoop().Run(); 7905 base::RunLoop().Run();
7906 7906
7907 EXPECT_FALSE(req->response_info().network_accessed); 7907 EXPECT_FALSE(req->response_info().network_accessed);
7908 } 7908 }
7909 7909
7910 // Test that a single job with a throttled priority completes
7911 // correctly in the absence of contention.
7912 TEST_F(URLRequestTestHTTP, ThrottledPriority) {
7913 ASSERT_TRUE(http_test_server()->Start());
7914
7915 TestDelegate d;
7916 GURL test_url(http_test_server()->GetURL("/"));
7917 std::unique_ptr<URLRequest> req(
7918 default_context_.CreateRequest(test_url, THROTTLED, &d));
7919 req->Start();
7920 base::RunLoop().Run();
7921
7922 EXPECT_TRUE(req->status().is_success());
7923 }
7924
7910 class URLRequestInterceptorTestHTTP : public URLRequestTestHTTP { 7925 class URLRequestInterceptorTestHTTP : public URLRequestTestHTTP {
7911 public: 7926 public:
7912 // TODO(bengr): Merge this with the URLRequestInterceptorHTTPTest fixture, 7927 // TODO(bengr): Merge this with the URLRequestInterceptorHTTPTest fixture,
7913 // ideally remove the dependency on URLRequestTestJob, and maybe move these 7928 // ideally remove the dependency on URLRequestTestJob, and maybe move these
7914 // tests into the factory tests. 7929 // tests into the factory tests.
7915 URLRequestInterceptorTestHTTP() : URLRequestTestHTTP(), interceptor_(NULL) { 7930 URLRequestInterceptorTestHTTP() : URLRequestTestHTTP(), interceptor_(NULL) {
7916 } 7931 }
7917 7932
7918 void SetUpFactory() override { 7933 void SetUpFactory() override {
7919 interceptor_ = new MockURLRequestInterceptor(); 7934 interceptor_ = new MockURLRequestInterceptor();
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after
10116 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 10131 AddTestInterceptor()->set_main_intercept_job(std::move(job));
10117 10132
10118 req->Start(); 10133 req->Start();
10119 req->Cancel(); 10134 req->Cancel();
10120 base::RunLoop().RunUntilIdle(); 10135 base::RunLoop().RunUntilIdle();
10121 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); 10136 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status());
10122 EXPECT_EQ(0, d.received_redirect_count()); 10137 EXPECT_EQ(0, d.received_redirect_count());
10123 } 10138 }
10124 10139
10125 } // namespace net 10140 } // namespace net
OLDNEW
« net/quic/quic_http_utils_test.cc ('K') | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698