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

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

Issue 2130493002: Implement THROTTLED priority semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NetworkStreamThrottler
Patch Set: Incorporate Charles' first set of comments. Created 4 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 unified diff | Download patch
« net/base/network_throttle_manager_unittest.cc ('K') | « net/net.gypi ('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 7873 matching lines...) Expand 10 before | Expand all | Expand 10 after
7884 std::unique_ptr<URLRequest> req( 7884 std::unique_ptr<URLRequest> req(
7885 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d)); 7885 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d));
7886 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE); 7886 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE);
7887 7887
7888 req->Start(); 7888 req->Start();
7889 base::RunLoop().Run(); 7889 base::RunLoop().Run();
7890 7890
7891 EXPECT_FALSE(req->response_info().network_accessed); 7891 EXPECT_FALSE(req->response_info().network_accessed);
7892 } 7892 }
7893 7893
7894 // Test that a single job with a throttled priority completes 7894 // Test that a single job with a THROTTLED priority completes
7895 // correctly in the absence of contention. 7895 // correctly in the absence of contention.
7896 TEST_F(URLRequestTestHTTP, ThrottledPriority) { 7896 TEST_F(URLRequestTestHTTP, ThrottledPriority) {
7897 ASSERT_TRUE(http_test_server()->Start()); 7897 ASSERT_TRUE(http_test_server()->Start());
7898 7898
7899 TestDelegate d; 7899 TestDelegate d;
7900 GURL test_url(http_test_server()->GetURL("/")); 7900 GURL test_url(http_test_server()->GetURL("/"));
7901 std::unique_ptr<URLRequest> req( 7901 std::unique_ptr<URLRequest> req(
7902 default_context_.CreateRequest(test_url, THROTTLED, &d)); 7902 default_context_.CreateRequest(test_url, THROTTLED, &d));
7903 req->Start(); 7903 req->Start();
7904 base::RunLoop().Run(); 7904 base::RunLoop().Run();
7905 7905
7906 EXPECT_TRUE(req->status().is_success()); 7906 EXPECT_TRUE(req->status().is_success());
7907 } 7907 }
7908 7908
7909 // Test that three jobs with THROTTLED priorities complete
7910 // correctly in the absence of contention (the completion of the
7911 // first one will unthrottle the third, but there is no visibility
7912 // to that at this level).
7913 TEST_F(URLRequestTestHTTP, MultiThrottledPriority) {
7914 ASSERT_TRUE(http_test_server()->Start());
7915
7916 TestDelegate d;
7917 GURL test_url(http_test_server()->GetURL("/"));
7918 std::unique_ptr<URLRequest> req1(
7919 default_context_.CreateRequest(test_url, THROTTLED, &d));
7920 std::unique_ptr<URLRequest> req2(
7921 default_context_.CreateRequest(test_url, THROTTLED, &d));
7922 std::unique_ptr<URLRequest> req3(
7923 default_context_.CreateRequest(test_url, THROTTLED, &d));
7924 req1->Start();
7925 req2->Start();
7926 req3->Start();
7927 base::RunLoop().Run();
7928
7929 EXPECT_TRUE(req1->status().is_success());
7930 EXPECT_TRUE(req2->status().is_success());
7931 EXPECT_TRUE(req3->status().is_success());
7932 }
7933
7909 class URLRequestInterceptorTestHTTP : public URLRequestTestHTTP { 7934 class URLRequestInterceptorTestHTTP : public URLRequestTestHTTP {
7910 public: 7935 public:
7911 // TODO(bengr): Merge this with the URLRequestInterceptorHTTPTest fixture, 7936 // TODO(bengr): Merge this with the URLRequestInterceptorHTTPTest fixture,
7912 // ideally remove the dependency on URLRequestTestJob, and maybe move these 7937 // ideally remove the dependency on URLRequestTestJob, and maybe move these
7913 // tests into the factory tests. 7938 // tests into the factory tests.
7914 URLRequestInterceptorTestHTTP() : URLRequestTestHTTP(), interceptor_(NULL) { 7939 URLRequestInterceptorTestHTTP() : URLRequestTestHTTP(), interceptor_(NULL) {
7915 } 7940 }
7916 7941
7917 void SetUpFactory() override { 7942 void SetUpFactory() override {
7918 interceptor_ = new MockURLRequestInterceptor(); 7943 interceptor_ = new MockURLRequestInterceptor();
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
10114 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 10139 AddTestInterceptor()->set_main_intercept_job(std::move(job));
10115 10140
10116 req->Start(); 10141 req->Start();
10117 req->Cancel(); 10142 req->Cancel();
10118 base::RunLoop().RunUntilIdle(); 10143 base::RunLoop().RunUntilIdle();
10119 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); 10144 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status());
10120 EXPECT_EQ(0, d.received_redirect_count()); 10145 EXPECT_EQ(0, d.received_redirect_count());
10121 } 10146 }
10122 10147
10123 } // namespace net 10148 } // namespace net
OLDNEW
« net/base/network_throttle_manager_unittest.cc ('K') | « net/net.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698