| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/message_loop_proxy.h" | 6 #include "base/message_loop_proxy.h" |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "chrome/common/net/url_request_context_getter.h" | 10 #include "chrome/common/net/url_request_context_getter.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 TEST_F(CloudPrintURLFetcherOverloadTest, Protect) { | 314 TEST_F(CloudPrintURLFetcherOverloadTest, Protect) { |
| 315 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 315 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 316 ASSERT_TRUE(test_server.Start()); | 316 ASSERT_TRUE(test_server.Start()); |
| 317 | 317 |
| 318 GURL url(test_server.GetURL("defaultresponse")); | 318 GURL url(test_server.GetURL("defaultresponse")); |
| 319 | 319 |
| 320 // Registers an entry for test url. It only allows 3 requests to be sent | 320 // Registers an entry for test url. It only allows 3 requests to be sent |
| 321 // in 200 milliseconds. | 321 // in 200 milliseconds. |
| 322 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 322 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
| 323 new net::URLRequestThrottlerEntry(200, 3, 1, 0, 2.0, 0.0, 256)); | 323 new net::URLRequestThrottlerEntry(200, 3, 1, 2.0, 0.0, 256)); |
| 324 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( | 324 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( |
| 325 url, entry); | 325 url, entry); |
| 326 | 326 |
| 327 CreateFetcher(url, 11); | 327 CreateFetcher(url, 11); |
| 328 | 328 |
| 329 MessageLoop::current()->Run(); | 329 MessageLoop::current()->Run(); |
| 330 | 330 |
| 331 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); | 331 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); |
| 332 } | 332 } |
| 333 | 333 |
| 334 // http://code.google.com/p/chromium/issues/detail?id=60426 | 334 // http://code.google.com/p/chromium/issues/detail?id=60426 |
| 335 TEST_F(CloudPrintURLFetcherRetryBackoffTest, FLAKY_GiveUp) { | 335 TEST_F(CloudPrintURLFetcherRetryBackoffTest, FLAKY_GiveUp) { |
| 336 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 336 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 337 ASSERT_TRUE(test_server.Start()); | 337 ASSERT_TRUE(test_server.Start()); |
| 338 | 338 |
| 339 GURL url(test_server.GetURL("defaultresponse")); | 339 GURL url(test_server.GetURL("defaultresponse")); |
| 340 | 340 |
| 341 // Registers an entry for test url. The backoff time is calculated by: | 341 // Registers an entry for test url. The backoff time is calculated by: |
| 342 // new_backoff = 2.0 * old_backoff + 0 | 342 // new_backoff = 2.0 * old_backoff + 0 |
| 343 // and maximum backoff time is 256 milliseconds. | 343 // and maximum backoff time is 256 milliseconds. |
| 344 // Maximum retries allowed is set to 11. | 344 // Maximum retries allowed is set to 11. |
| 345 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 345 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
| 346 new net::URLRequestThrottlerEntry(200, 3, 1, 0, 2.0, 0.0, 256)); | 346 new net::URLRequestThrottlerEntry(200, 3, 1, 2.0, 0.0, 256)); |
| 347 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( | 347 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( |
| 348 url, entry); | 348 url, entry); |
| 349 | 349 |
| 350 CreateFetcher(url, 11); | 350 CreateFetcher(url, 11); |
| 351 | 351 |
| 352 MessageLoop::current()->Run(); | 352 MessageLoop::current()->Run(); |
| 353 | 353 |
| 354 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); | 354 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace. | 357 } // namespace. |
| OLD | NEW |