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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 424753005: Rename ResourceThrottle::OnBeforeNetworkStart to WillStartUsingNetwork. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | content/browser/loader/throttling_resource_handler.cc » ('j') | 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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 private: 273 private:
274 virtual ~ForwardingFilter() {} 274 virtual ~ForwardingFilter() {}
275 275
276 IPC::Sender* dest_; 276 IPC::Sender* dest_;
277 277
278 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter); 278 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter);
279 }; 279 };
280 280
281 // This class is a variation on URLRequestTestJob that will call 281 // This class is a variation on URLRequestTestJob that will call
282 // URLRequest::OnBeforeNetworkStart before starting. 282 // URLRequest::WillStartUsingNetwork before starting.
283 class URLRequestTestDelayedNetworkJob : public net::URLRequestTestJob { 283 class URLRequestTestDelayedNetworkJob : public net::URLRequestTestJob {
284 public: 284 public:
285 URLRequestTestDelayedNetworkJob(net::URLRequest* request, 285 URLRequestTestDelayedNetworkJob(net::URLRequest* request,
286 net::NetworkDelegate* network_delegate) 286 net::NetworkDelegate* network_delegate)
287 : net::URLRequestTestJob(request, network_delegate) {} 287 : net::URLRequestTestJob(request, network_delegate) {}
288 288
289 // Only start if not deferred for network start. 289 // Only start if not deferred for network start.
290 virtual void Start() OVERRIDE { 290 virtual void Start() OVERRIDE {
291 bool defer = false; 291 bool defer = false;
292 NotifyBeforeNetworkStart(&defer); 292 NotifyBeforeNetworkStart(&defer);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 590 }
591 591
592 virtual void WillProcessResponse(bool* defer) OVERRIDE { 592 virtual void WillProcessResponse(bool* defer) OVERRIDE {
593 ASSERT_EQ(NULL, active_throttle_); 593 ASSERT_EQ(NULL, active_throttle_);
594 if (flags_ & DEFER_PROCESSING_RESPONSE) { 594 if (flags_ & DEFER_PROCESSING_RESPONSE) {
595 active_throttle_ = this; 595 active_throttle_ = this;
596 *defer = true; 596 *defer = true;
597 } 597 }
598 } 598 }
599 599
600 virtual void OnBeforeNetworkStart(bool* defer) OVERRIDE { 600 virtual void WillStartUsingNetwork(bool* defer) OVERRIDE {
601 ASSERT_EQ(NULL, active_throttle_); 601 ASSERT_EQ(NULL, active_throttle_);
602 602
603 if (flags_ & DEFER_NETWORK_START) { 603 if (flags_ & DEFER_NETWORK_START) {
604 active_throttle_ = this; 604 active_throttle_ = this;
605 *defer = true; 605 *defer = true;
606 } 606 }
607 } 607 }
608 608
609 virtual const char* GetNameForLogging() const OVERRIDE { 609 virtual const char* GetNameForLogging() const OVERRIDE {
610 return "GenericResourceThrottle"; 610 return "GenericResourceThrottle";
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_error()); 1360 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_error());
1361 CompleteStartRequest(1); 1361 CompleteStartRequest(1);
1362 1362
1363 // flush all the pending requests 1363 // flush all the pending requests
1364 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1364 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1365 base::MessageLoop::current()->RunUntilIdle(); 1365 base::MessageLoop::current()->RunUntilIdle();
1366 1366
1367 EXPECT_EQ(0, host_.pending_requests()); 1367 EXPECT_EQ(0, host_.pending_requests());
1368 } 1368 }
1369 1369
1370 // Test the OnBeforeNetworkStart throttle. 1370 // Test the WillStartUsingNetwork throttle.
1371 TEST_F(ResourceDispatcherHostTest, ThrottleNetworkStart) { 1371 TEST_F(ResourceDispatcherHostTest, ThrottleNetworkStart) {
1372 // Arrange to have requests deferred before processing response headers. 1372 // Arrange to have requests deferred before processing response headers.
1373 TestResourceDispatcherHostDelegate delegate; 1373 TestResourceDispatcherHostDelegate delegate;
1374 delegate.set_flags(DEFER_NETWORK_START); 1374 delegate.set_flags(DEFER_NETWORK_START);
1375 host_.SetDelegate(&delegate); 1375 host_.SetDelegate(&delegate);
1376 1376
1377 job_factory_->SetNetworkStartNotificationJobGeneration(true); 1377 job_factory_->SetNetworkStartNotificationJobGeneration(true);
1378 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_2()); 1378 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_2());
1379 1379
1380 // Should have deferred for network start. 1380 // Should have deferred for network start.
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 } else { 2918 } else {
2919 return new net::URLRequestTestJob( 2919 return new net::URLRequestTestJob(
2920 request, network_delegate, 2920 request, network_delegate,
2921 test_fixture_->response_headers_, test_fixture_->response_data_, 2921 test_fixture_->response_headers_, test_fixture_->response_data_,
2922 false); 2922 false);
2923 } 2923 }
2924 } 2924 }
2925 } 2925 }
2926 2926
2927 } // namespace content 2927 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/throttling_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698