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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
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 // The tests in this file attempt to verify the following through simulation: 5 // The tests in this file attempt to verify the following through simulation:
6 // a) That a server experiencing overload will actually benefit from the 6 // a) That a server experiencing overload will actually benefit from the
7 // anti-DDoS throttling logic, i.e. that its traffic spike will subside 7 // anti-DDoS throttling logic, i.e. that its traffic spike will subside
8 // and be distributed over a longer period of time; 8 // and be distributed over a longer period of time;
9 // b) That "well-behaved" clients of a server under DDoS attack actually 9 // b) That "well-behaved" clients of a server under DDoS attack actually
10 // benefit from the anti-DDoS throttling logic; and 10 // benefit from the anti-DDoS throttling logic; and
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 TestURLRequestContext context_; 291 TestURLRequestContext context_;
292 TestURLRequest mock_request_; 292 TestURLRequest mock_request_;
293 293
294 DISALLOW_COPY_AND_ASSIGN(Server); 294 DISALLOW_COPY_AND_ASSIGN(Server);
295 }; 295 };
296 296
297 // Mock throttler entry used by Requester class. 297 // Mock throttler entry used by Requester class.
298 class MockURLRequestThrottlerEntry : public URLRequestThrottlerEntry { 298 class MockURLRequestThrottlerEntry : public URLRequestThrottlerEntry {
299 public: 299 public:
300 explicit MockURLRequestThrottlerEntry( 300 explicit MockURLRequestThrottlerEntry(URLRequestThrottlerManager* manager)
301 URLRequestThrottlerManager* manager) 301 : URLRequestThrottlerEntry(manager, std::string()),
302 : URLRequestThrottlerEntry(manager, ""), 302 mock_backoff_entry_(&backoff_policy_) {}
303 mock_backoff_entry_(&backoff_policy_) {
304 }
305 303
306 virtual const BackoffEntry* GetBackoffEntry() const OVERRIDE { 304 virtual const BackoffEntry* GetBackoffEntry() const OVERRIDE {
307 return &mock_backoff_entry_; 305 return &mock_backoff_entry_;
308 } 306 }
309 307
310 virtual BackoffEntry* GetBackoffEntry() OVERRIDE { 308 virtual BackoffEntry* GetBackoffEntry() OVERRIDE {
311 return &mock_backoff_entry_; 309 return &mock_backoff_entry_;
312 } 310 }
313 311
314 virtual TimeTicks ImplGetTimeNow() const OVERRIDE { 312 virtual TimeTicks ImplGetTimeNow() const OVERRIDE {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 effective_delay -= current_jitter; 424 effective_delay -= current_jitter;
427 } else { 425 } else {
428 effective_delay += current_jitter; 426 effective_delay += current_jitter;
429 } 427 }
430 428
431 if (throttler_entry_->fake_now() - time_of_last_attempt_ > 429 if (throttler_entry_->fake_now() - time_of_last_attempt_ >
432 effective_delay) { 430 effective_delay) {
433 if (!throttler_entry_->ShouldRejectRequest(server_->mock_request())) { 431 if (!throttler_entry_->ShouldRejectRequest(server_->mock_request())) {
434 int status_code = server_->HandleRequest(); 432 int status_code = server_->HandleRequest();
435 MockURLRequestThrottlerHeaderAdapter response_headers(status_code); 433 MockURLRequestThrottlerHeaderAdapter response_headers(status_code);
436 throttler_entry_->UpdateWithResponse("", &response_headers); 434 throttler_entry_->UpdateWithResponse(std::string(), &response_headers);
437 435
438 if (status_code == 200) { 436 if (status_code == 200) {
439 if (results_) 437 if (results_)
440 results_->AddSuccess(); 438 results_->AddSuccess();
441 439
442 if (last_attempt_was_failure_) { 440 if (last_attempt_was_failure_) {
443 last_downtime_duration_ = 441 last_downtime_duration_ =
444 throttler_entry_->fake_now() - time_of_last_success_; 442 throttler_entry_->fake_now() - time_of_last_success_;
445 } 443 }
446 444
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 trials[i].PrintTrialDescription(); 746 trials[i].PrintTrialDescription();
749 trials[i].stats.ReportTrialResult(increase_ratio); 747 trials[i].stats.ReportTrialResult(increase_ratio);
750 } 748 }
751 749
752 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); 750 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio);
753 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); 751 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio);
754 } 752 }
755 753
756 } // namespace 754 } // namespace
757 } // namespace net 755 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_fetcher_impl_unittest.cc ('k') | net/url_request/url_request_throttler_test_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698