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