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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 2083363002: Remove calls to deprecated MessageLoop methods in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 // Extension1 response to the redirected URL. Arrives second, and ignored. 289 // Extension1 response to the redirected URL. Arrives second, and ignored.
290 response = new ExtensionWebRequestEventRouter::EventResponse( 290 response = new ExtensionWebRequestEventRouter::EventResponse(
291 extension1_id, base::Time::FromDoubleT(1)); 291 extension1_id, base::Time::FromDoubleT(1));
292 ipc_sender_.PushTask( 292 ipc_sender_.PushTask(
293 base::Bind(&EventHandledOnIOThread, 293 base::Bind(&EventHandledOnIOThread,
294 &profile_, extension1_id, kEventName, kEventName + "/1", 294 &profile_, extension1_id, kEventName, kEventName + "/1",
295 request->identifier(), response)); 295 request->identifier(), response));
296 296
297 request->Start(); 297 request->Start();
298 base::MessageLoop::current()->Run(); 298 base::RunLoop().Run();
299 299
300 EXPECT_TRUE(!request->is_pending()); 300 EXPECT_TRUE(!request->is_pending());
301 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request->status().status()); 301 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request->status().status());
302 EXPECT_EQ(0, request->status().error()); 302 EXPECT_EQ(0, request->status().error());
303 EXPECT_EQ(redirect_url, request->url()); 303 EXPECT_EQ(redirect_url, request->url());
304 EXPECT_EQ(2U, request->url_chain().size()); 304 EXPECT_EQ(2U, request->url_chain().size());
305 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); 305 EXPECT_EQ(0U, ipc_sender_.GetNumTasks());
306 } 306 }
307 307
308 // Now test the same thing but the extensions answer in reverse order. 308 // Now test the same thing but the extensions answer in reverse order.
(...skipping 30 matching lines...) Expand all
339 339
340 // Extension1 response to the redirected URL. Arrives second, and ignored. 340 // Extension1 response to the redirected URL. Arrives second, and ignored.
341 response = new ExtensionWebRequestEventRouter::EventResponse( 341 response = new ExtensionWebRequestEventRouter::EventResponse(
342 extension1_id, base::Time::FromDoubleT(1)); 342 extension1_id, base::Time::FromDoubleT(1));
343 ipc_sender_.PushTask( 343 ipc_sender_.PushTask(
344 base::Bind(&EventHandledOnIOThread, 344 base::Bind(&EventHandledOnIOThread,
345 &profile_, extension1_id, kEventName, kEventName + "/1", 345 &profile_, extension1_id, kEventName, kEventName + "/1",
346 request2->identifier(), response)); 346 request2->identifier(), response));
347 347
348 request2->Start(); 348 request2->Start();
349 base::MessageLoop::current()->Run(); 349 base::RunLoop().Run();
350 350
351 EXPECT_TRUE(!request2->is_pending()); 351 EXPECT_TRUE(!request2->is_pending());
352 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request2->status().status()); 352 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request2->status().status());
353 EXPECT_EQ(0, request2->status().error()); 353 EXPECT_EQ(0, request2->status().error());
354 EXPECT_EQ(redirect_url, request2->url()); 354 EXPECT_EQ(redirect_url, request2->url());
355 EXPECT_EQ(2U, request2->url_chain().size()); 355 EXPECT_EQ(2U, request2->url_chain().size());
356 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); 356 EXPECT_EQ(0U, ipc_sender_.GetNumTasks());
357 } 357 }
358 358
359 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( 359 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 response = new ExtensionWebRequestEventRouter::EventResponse( 404 response = new ExtensionWebRequestEventRouter::EventResponse(
405 extension2_id, base::Time::FromDoubleT(2)); 405 extension2_id, base::Time::FromDoubleT(2));
406 response->new_url = redirect_url; 406 response->new_url = redirect_url;
407 ipc_sender_.PushTask( 407 ipc_sender_.PushTask(
408 base::Bind(&EventHandledOnIOThread, 408 base::Bind(&EventHandledOnIOThread,
409 &profile_, extension2_id, kEventName, kEventName + "/2", 409 &profile_, extension2_id, kEventName, kEventName + "/2",
410 request->identifier(), response)); 410 request->identifier(), response));
411 411
412 request->Start(); 412 request->Start();
413 413
414 base::MessageLoop::current()->Run(); 414 base::RunLoop().Run();
415 415
416 EXPECT_TRUE(!request->is_pending()); 416 EXPECT_TRUE(!request->is_pending());
417 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); 417 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status());
418 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, request->status().error()); 418 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, request->status().error());
419 EXPECT_EQ(request_url, request->url()); 419 EXPECT_EQ(request_url, request->url());
420 EXPECT_EQ(1U, request->url_chain().size()); 420 EXPECT_EQ(1U, request->url_chain().size());
421 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); 421 EXPECT_EQ(0U, ipc_sender_.GetNumTasks());
422 422
423 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( 423 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
424 &profile_, extension1_id, kEventName + "/1", 0, 0); 424 &profile_, extension1_id, kEventName + "/1", 0, 0);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 // Extension response for OnErrorOccurred: Terminate the message loop. 467 // Extension response for OnErrorOccurred: Terminate the message loop.
468 ipc_sender_.PushTask( 468 ipc_sender_.PushTask(
469 base::Bind(&base::MessageLoop::PostTask, 469 base::Bind(&base::MessageLoop::PostTask,
470 base::Unretained(base::MessageLoop::current()), FROM_HERE, 470 base::Unretained(base::MessageLoop::current()), FROM_HERE,
471 base::MessageLoop::QuitWhenIdleClosure())); 471 base::MessageLoop::QuitWhenIdleClosure()));
472 472
473 request->Start(); 473 request->Start();
474 // request->Start() will have submitted OnBeforeRequest by the time we cancel. 474 // request->Start() will have submitted OnBeforeRequest by the time we cancel.
475 request->Cancel(); 475 request->Cancel();
476 base::MessageLoop::current()->Run(); 476 base::RunLoop().Run();
477 477
478 EXPECT_TRUE(!request->is_pending()); 478 EXPECT_TRUE(!request->is_pending());
479 EXPECT_EQ(net::URLRequestStatus::CANCELED, request->status().status()); 479 EXPECT_EQ(net::URLRequestStatus::CANCELED, request->status().status());
480 EXPECT_EQ(net::ERR_ABORTED, request->status().error()); 480 EXPECT_EQ(net::ERR_ABORTED, request->status().error());
481 EXPECT_EQ(request_url, request->url()); 481 EXPECT_EQ(request_url, request->url());
482 EXPECT_EQ(1U, request->url_chain().size()); 482 EXPECT_EQ(1U, request->url_chain().size());
483 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); 483 EXPECT_EQ(0U, ipc_sender_.GetNumTasks());
484 484
485 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( 485 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
486 &profile_, extension_id, kEventName + "/1", 0, 0); 486 &profile_, extension_id, kEventName + "/1", 0, 0);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 // Don't do anything for the onSendHeaders message. 977 // Don't do anything for the onSendHeaders message.
978 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); 978 ipc_sender_.PushTask(base::Bind(&base::DoNothing));
979 979
980 // Note that we mess up the headers slightly: 980 // Note that we mess up the headers slightly:
981 // request->Start() will first add additional headers (e.g. the User-Agent) 981 // request->Start() will first add additional headers (e.g. the User-Agent)
982 // and then send an event to the extension. When we have prepared our 982 // and then send an event to the extension. When we have prepared our
983 // answers to the onBeforeSendHeaders events above, these headers did not 983 // answers to the onBeforeSendHeaders events above, these headers did not
984 // exists and are therefore not listed in the responses. This makes 984 // exists and are therefore not listed in the responses. This makes
985 // them seem deleted. 985 // them seem deleted.
986 request->Start(); 986 request->Start();
987 base::MessageLoop::current()->Run(); 987 base::RunLoop().Run();
988 988
989 EXPECT_TRUE(!request->is_pending()); 989 EXPECT_TRUE(!request->is_pending());
990 // This cannot succeed as we send the request to a server that does not exist. 990 // This cannot succeed as we send the request to a server that does not exist.
991 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); 991 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status());
992 EXPECT_EQ(request_url, request->url()); 992 EXPECT_EQ(request_url, request->url());
993 EXPECT_EQ(1U, request->url_chain().size()); 993 EXPECT_EQ(1U, request->url_chain().size());
994 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); 994 EXPECT_EQ(0U, ipc_sender_.GetNumTasks());
995 995
996 // Calculate the expected headers. 996 // Calculate the expected headers.
997 net::HttpRequestHeaders expected_headers; 997 net::HttpRequestHeaders expected_headers;
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 EXPECT_TRUE(credentials_set); 2314 EXPECT_TRUE(credentials_set);
2315 EXPECT_FALSE(auth3.Empty()); 2315 EXPECT_FALSE(auth3.Empty());
2316 EXPECT_EQ(username, auth1.username()); 2316 EXPECT_EQ(username, auth1.username());
2317 EXPECT_EQ(password, auth1.password()); 2317 EXPECT_EQ(password, auth1.password());
2318 EXPECT_EQ(1u, warning_set.size()); 2318 EXPECT_EQ(1u, warning_set.size());
2319 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2319 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2320 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2320 EXPECT_EQ(3u, capturing_net_log.GetSize());
2321 } 2321 }
2322 2322
2323 } // namespace extensions 2323 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/top_sites/top_sites_apitest.cc ('k') | chrome/browser/extensions/app_data_migrator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698