OLD | NEW |
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 "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 "base/values.h" | 10 #include "base/values.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 const std::string& data); | 205 const std::string& data); |
206 | 206 |
207 virtual void OnRequestGiveUp(); | 207 virtual void OnRequestGiveUp(); |
208 | 208 |
209 private: | 209 private: |
210 int response_count_; | 210 int response_count_; |
211 }; | 211 }; |
212 | 212 |
213 | 213 |
214 void CloudPrintURLFetcherTest::CreateFetcher(const GURL& url, int max_retries) { | 214 void CloudPrintURLFetcherTest::CreateFetcher(const GURL& url, int max_retries) { |
215 fetcher_ = new TestCloudPrintURLFetcher(io_message_loop_proxy()); | 215 fetcher_ = new TestCloudPrintURLFetcher(io_message_loop_proxy().get()); |
216 | 216 |
217 // Registers an entry for test url. It only allows 3 requests to be sent | 217 // Registers an entry for test url. It only allows 3 requests to be sent |
218 // in 200 milliseconds. | 218 // in 200 milliseconds. |
219 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 219 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
220 new net::URLRequestThrottlerEntry( | 220 new net::URLRequestThrottlerEntry( |
221 fetcher_->throttler_manager(), "", 200, 3, 1, 2.0, 0.0, 256)); | 221 fetcher_->throttler_manager(), "", 200, 3, 1, 2.0, 0.0, 256)); |
222 fetcher_->throttler_manager()->OverrideEntryForTests(url, entry); | 222 fetcher_->throttler_manager()->OverrideEntryForTests(url, entry.get()); |
223 | 223 |
224 max_retries_ = max_retries; | 224 max_retries_ = max_retries; |
225 start_time_ = Time::Now(); | 225 start_time_ = Time::Now(); |
226 fetcher_->StartGetRequest(url, this, max_retries_, std::string()); | 226 fetcher_->StartGetRequest(url, this, max_retries_, std::string()); |
227 } | 227 } |
228 | 228 |
229 CloudPrintURLFetcher::ResponseAction | 229 CloudPrintURLFetcher::ResponseAction |
230 CloudPrintURLFetcherTest::HandleRawResponse( | 230 CloudPrintURLFetcherTest::HandleRawResponse( |
231 const net::URLFetcher* source, | 231 const net::URLFetcher* source, |
232 const GURL& url, | 232 const GURL& url, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 FilePath(kDocRoot)); | 369 FilePath(kDocRoot)); |
370 ASSERT_TRUE(test_server.Start()); | 370 ASSERT_TRUE(test_server.Start()); |
371 | 371 |
372 GURL url(test_server.GetURL("defaultresponse")); | 372 GURL url(test_server.GetURL("defaultresponse")); |
373 CreateFetcher(url, 11); | 373 CreateFetcher(url, 11); |
374 | 374 |
375 MessageLoop::current()->Run(); | 375 MessageLoop::current()->Run(); |
376 } | 376 } |
377 | 377 |
378 } // namespace. | 378 } // namespace. |
OLD | NEW |