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

Side by Side Diff: chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc

Issue 8873032: Removing MessageLoop::QuitTask() from chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert 3 more problematic files Created 9 years 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
« no previous file with comments | « chrome/common/worker_thread_ticker_unittest.cc ('k') | chrome/service/service_process.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) 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 "base/values.h" 10 #include "base/values.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 int response_code, 223 int response_code,
224 const net::ResponseCookies& cookies, 224 const net::ResponseCookies& cookies,
225 const std::string& data) { 225 const std::string& data) {
226 EXPECT_TRUE(status.is_success()); 226 EXPECT_TRUE(status.is_success());
227 EXPECT_EQ(200, response_code); // HTTP OK 227 EXPECT_EQ(200, response_code); // HTTP OK
228 EXPECT_FALSE(data.empty()); 228 EXPECT_FALSE(data.empty());
229 229
230 if (handle_raw_response_) { 230 if (handle_raw_response_) {
231 // If the current message loop is not the IO loop, it will be shut down when 231 // If the current message loop is not the IO loop, it will be shut down when
232 // the main loop returns and this thread subsequently goes out of scope. 232 // the main loop returns and this thread subsequently goes out of scope.
233 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 233 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
234 return CloudPrintURLFetcher::STOP_PROCESSING; 234 return CloudPrintURLFetcher::STOP_PROCESSING;
235 } 235 }
236 return CloudPrintURLFetcher::CONTINUE_PROCESSING; 236 return CloudPrintURLFetcher::CONTINUE_PROCESSING;
237 } 237 }
238 238
239 CloudPrintURLFetcher::ResponseAction 239 CloudPrintURLFetcher::ResponseAction
240 CloudPrintURLFetcherBasicTest::HandleRawData( 240 CloudPrintURLFetcherBasicTest::HandleRawData(
241 const content::URLFetcher* source, 241 const content::URLFetcher* source,
242 const GURL& url, 242 const GURL& url,
243 const std::string& data) { 243 const std::string& data) {
244 // We should never get here if we returned true in HandleRawResponse 244 // We should never get here if we returned true in HandleRawResponse
245 EXPECT_FALSE(handle_raw_response_); 245 EXPECT_FALSE(handle_raw_response_);
246 if (handle_raw_data_) { 246 if (handle_raw_data_) {
247 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 247 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
248 return CloudPrintURLFetcher::STOP_PROCESSING; 248 return CloudPrintURLFetcher::STOP_PROCESSING;
249 } 249 }
250 return CloudPrintURLFetcher::CONTINUE_PROCESSING; 250 return CloudPrintURLFetcher::CONTINUE_PROCESSING;
251 } 251 }
252 252
253 CloudPrintURLFetcher::ResponseAction 253 CloudPrintURLFetcher::ResponseAction
254 CloudPrintURLFetcherBasicTest::HandleJSONData( 254 CloudPrintURLFetcherBasicTest::HandleJSONData(
255 const content::URLFetcher* source, 255 const content::URLFetcher* source,
256 const GURL& url, 256 const GURL& url,
257 DictionaryValue* json_data, 257 DictionaryValue* json_data,
258 bool succeeded) { 258 bool succeeded) {
259 // We should never get here if we returned true in one of the above methods. 259 // We should never get here if we returned true in one of the above methods.
260 EXPECT_FALSE(handle_raw_response_); 260 EXPECT_FALSE(handle_raw_response_);
261 EXPECT_FALSE(handle_raw_data_); 261 EXPECT_FALSE(handle_raw_data_);
262 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 262 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
263 return CloudPrintURLFetcher::STOP_PROCESSING; 263 return CloudPrintURLFetcher::STOP_PROCESSING;
264 } 264 }
265 265
266 CloudPrintURLFetcher::ResponseAction 266 CloudPrintURLFetcher::ResponseAction
267 CloudPrintURLFetcherOverloadTest::HandleRawData( 267 CloudPrintURLFetcherOverloadTest::HandleRawData(
268 const content::URLFetcher* source, 268 const content::URLFetcher* source,
269 const GURL& url, 269 const GURL& url,
270 const std::string& data) { 270 const std::string& data) {
271 const TimeDelta one_second = TimeDelta::FromMilliseconds(1000); 271 const TimeDelta one_second = TimeDelta::FromMilliseconds(1000);
272 response_count_++; 272 response_count_++;
273 if (response_count_ < 20) { 273 if (response_count_ < 20) {
274 fetcher_->StartGetRequest(url, 274 fetcher_->StartGetRequest(url,
275 this, 275 this,
276 max_retries_, 276 max_retries_,
277 std::string()); 277 std::string());
278 } else { 278 } else {
279 // We have already sent 20 requests continuously. And we expect that 279 // We have already sent 20 requests continuously. And we expect that
280 // it takes more than 1 second due to the overload protection settings. 280 // it takes more than 1 second due to the overload protection settings.
281 EXPECT_TRUE(Time::Now() - start_time_ >= one_second); 281 EXPECT_TRUE(Time::Now() - start_time_ >= one_second);
282 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 282 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
283 } 283 }
284 return CloudPrintURLFetcher::STOP_PROCESSING; 284 return CloudPrintURLFetcher::STOP_PROCESSING;
285 } 285 }
286 286
287 CloudPrintURLFetcher::ResponseAction 287 CloudPrintURLFetcher::ResponseAction
288 CloudPrintURLFetcherRetryBackoffTest::HandleRawData( 288 CloudPrintURLFetcherRetryBackoffTest::HandleRawData(
289 const content::URLFetcher* source, 289 const content::URLFetcher* source,
290 const GURL& url, 290 const GURL& url,
291 const std::string& data) { 291 const std::string& data) {
292 response_count_++; 292 response_count_++;
293 // First attempt + 11 retries = 12 total responses. 293 // First attempt + 11 retries = 12 total responses.
294 EXPECT_LE(response_count_, 12); 294 EXPECT_LE(response_count_, 12);
295 return CloudPrintURLFetcher::RETRY_REQUEST; 295 return CloudPrintURLFetcher::RETRY_REQUEST;
296 } 296 }
297 297
298 void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() { 298 void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() {
299 // It takes more than 200 ms to finish all 11 requests. 299 // It takes more than 200 ms to finish all 11 requests.
300 EXPECT_TRUE(Time::Now() - start_time_ >= TimeDelta::FromMilliseconds(200)); 300 EXPECT_TRUE(Time::Now() - start_time_ >= TimeDelta::FromMilliseconds(200));
301 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 301 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
302 } 302 }
303 303
304 // http://code.google.com/p/chromium/issues/detail?id=60426 304 // http://code.google.com/p/chromium/issues/detail?id=60426
305 TEST_F(CloudPrintURLFetcherBasicTest, FLAKY_HandleRawResponse) { 305 TEST_F(CloudPrintURLFetcherBasicTest, FLAKY_HandleRawResponse) {
306 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); 306 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot));
307 ASSERT_TRUE(test_server.Start()); 307 ASSERT_TRUE(test_server.Start());
308 SetHandleRawResponse(true); 308 SetHandleRawResponse(true);
309 309
310 CreateFetcher(test_server.GetURL("echo"), 0); 310 CreateFetcher(test_server.GetURL("echo"), 0);
311 MessageLoop::current()->Run(); 311 MessageLoop::current()->Run();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 manager->OverrideEntryForTests(url, entry); 360 manager->OverrideEntryForTests(url, entry);
361 361
362 CreateFetcher(url, 11); 362 CreateFetcher(url, 11);
363 363
364 MessageLoop::current()->Run(); 364 MessageLoop::current()->Run();
365 365
366 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); 366 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url);
367 } 367 }
368 368
369 } // namespace. 369 } // namespace.
OLDNEW
« no previous file with comments | « chrome/common/worker_thread_ticker_unittest.cc ('k') | chrome/service/service_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698