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

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate_browsertest.cc

Issue 2828663002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/{i,l,m,n,p,r}* (Closed)
Patch Set: Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void SetShouldAddDataReductionProxyData(bool add_data) { 251 void SetShouldAddDataReductionProxyData(bool add_data) {
252 dispatcher_host_delegate_->set_should_add_data_reduction_proxy_data( 252 dispatcher_host_delegate_->set_should_add_data_reduction_proxy_data(
253 add_data); 253 add_data);
254 } 254 }
255 255
256 int GetTimesStandardThrottlesAddedForURL(const GURL& url) { 256 int GetTimesStandardThrottlesAddedForURL(const GURL& url) {
257 int count; 257 int count;
258 base::RunLoop run_loop; 258 base::RunLoop run_loop;
259 content::BrowserThread::PostTaskAndReply( 259 content::BrowserThread::PostTaskAndReply(
260 content::BrowserThread::IO, FROM_HERE, 260 content::BrowserThread::IO, FROM_HERE,
261 base::Bind( 261 base::BindOnce(
262 &TestDispatcherHostDelegate::GetTimesStandardThrottlesAddedForURL, 262 &TestDispatcherHostDelegate::GetTimesStandardThrottlesAddedForURL,
263 base::Unretained(dispatcher_host_delegate_.get()), url, &count), 263 base::Unretained(dispatcher_host_delegate_.get()), url, &count),
264 run_loop.QuitClosure()); 264 run_loop.QuitClosure());
265 run_loop.Run(); 265 run_loop.Run();
266 return count; 266 return count;
267 } 267 }
268 268
269 protected: 269 protected:
270 // The fake URL for DMServer we are using. 270 // The fake URL for DMServer we are using.
271 GURL dm_url_; 271 GURL dm_url_;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 : net::URLRequestMockHTTPJob(request, 353 : net::URLRequestMockHTTPJob(request,
354 network_delegate, 354 network_delegate,
355 file_path, 355 file_path,
356 task_runner), 356 task_runner),
357 report_on_ui_(report_on_ui) {} 357 report_on_ui_(report_on_ui) {}
358 358
359 void Start() override { 359 void Start() override {
360 // Report the observed request headers on the UI thread. 360 // Report the observed request headers on the UI thread.
361 content::BrowserThread::PostTask( 361 content::BrowserThread::PostTask(
362 content::BrowserThread::UI, FROM_HERE, 362 content::BrowserThread::UI, FROM_HERE,
363 base::Bind(report_on_ui_, request_->url().spec(), 363 base::BindOnce(report_on_ui_, request_->url().spec(),
364 request_->extra_request_headers().ToString())); 364 request_->extra_request_headers().ToString()));
365 365
366 URLRequestMockHTTPJob::Start(); 366 URLRequestMockHTTPJob::Start();
367 } 367 }
368 368
369 protected: 369 protected:
370 const ReportResponseHeadersOnUI report_on_ui_; 370 const ReportResponseHeadersOnUI report_on_ui_;
371 371
372 private: 372 private:
373 DISALLOW_COPY_AND_ASSIGN(MirrorMockURLRequestJob); 373 DISALLOW_COPY_AND_ASSIGN(MirrorMockURLRequestJob);
374 }; 374 };
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 // If test case requires adding header for the first url, 523 // If test case requires adding header for the first url,
524 // change the delegate. 524 // change the delegate.
525 std::unique_ptr<HeaderTestDispatcherHostDelegate> dispatcher_host_delegate; 525 std::unique_ptr<HeaderTestDispatcherHostDelegate> dispatcher_host_delegate;
526 if (test_case.inject_header) { 526 if (test_case.inject_header) {
527 dispatcher_host_delegate = 527 dispatcher_host_delegate =
528 base::MakeUnique<HeaderTestDispatcherHostDelegate>( 528 base::MakeUnique<HeaderTestDispatcherHostDelegate>(
529 test_case.original_url); 529 test_case.original_url);
530 content::BrowserThread::PostTask( 530 content::BrowserThread::PostTask(
531 content::BrowserThread::IO, FROM_HERE, 531 content::BrowserThread::IO, FROM_HERE,
532 base::Bind(&SetDelegateOnIO, dispatcher_host_delegate.get())); 532 base::BindOnce(&SetDelegateOnIO, dispatcher_host_delegate.get()));
533 } 533 }
534 534
535 // Set up mockup interceptors. 535 // Set up mockup interceptors.
536 content::BrowserThread::PostTask( 536 content::BrowserThread::PostTask(
537 content::BrowserThread::IO, FROM_HERE, 537 content::BrowserThread::IO, FROM_HERE,
538 base::Bind(&MirrorMockJobInterceptor::Register, test_case.original_url, 538 base::BindOnce(&MirrorMockJobInterceptor::Register,
539 root_http, report_request_headers)); 539 test_case.original_url, root_http,
540 report_request_headers));
540 content::BrowserThread::PostTask( 541 content::BrowserThread::PostTask(
541 content::BrowserThread::IO, FROM_HERE, 542 content::BrowserThread::IO, FROM_HERE,
542 base::Bind(&MirrorMockJobInterceptor::Register, 543 base::BindOnce(&MirrorMockJobInterceptor::Register,
543 test_case.redirected_to_url, root_http, 544 test_case.redirected_to_url, root_http,
544 report_request_headers)); 545 report_request_headers));
545 546
546 // Navigate to first url. 547 // Navigate to first url.
547 ui_test_utils::NavigateToURL(browser(), test_case.original_url); 548 ui_test_utils::NavigateToURL(browser(), test_case.original_url);
548 549
549 // Cleanup before verifying the observed headers. 550 // Cleanup before verifying the observed headers.
550 content::BrowserThread::PostTask( 551 content::BrowserThread::PostTask(
551 content::BrowserThread::IO, FROM_HERE, 552 content::BrowserThread::IO, FROM_HERE,
552 base::Bind(&MirrorMockJobInterceptor::Unregister, 553 base::BindOnce(&MirrorMockJobInterceptor::Unregister,
553 test_case.original_url)); 554 test_case.original_url));
554 content::BrowserThread::PostTask( 555 content::BrowserThread::PostTask(
555 content::BrowserThread::IO, FROM_HERE, 556 content::BrowserThread::IO, FROM_HERE,
556 base::Bind(&MirrorMockJobInterceptor::Unregister, 557 base::BindOnce(&MirrorMockJobInterceptor::Unregister,
557 test_case.redirected_to_url)); 558 test_case.redirected_to_url));
558 559
559 // If delegate is changed, remove it. 560 // If delegate is changed, remove it.
560 if (test_case.inject_header) { 561 if (test_case.inject_header) {
561 base::RunLoop run_loop; 562 base::RunLoop run_loop;
562 content::BrowserThread::PostTaskAndReply( 563 content::BrowserThread::PostTaskAndReply(
563 content::BrowserThread::IO, FROM_HERE, 564 content::BrowserThread::IO, FROM_HERE,
564 base::Bind(&SetDelegateOnIO, nullptr), run_loop.QuitClosure()); 565 base::BindOnce(&SetDelegateOnIO, nullptr), run_loop.QuitClosure());
565 run_loop.Run(); 566 run_loop.Run();
566 } 567 }
567 568
568 // Ensure that the response headers have been reported to the UI thread 569 // Ensure that the response headers have been reported to the UI thread
569 // and unregistration has been processed on the IO thread. 570 // and unregistration has been processed on the IO thread.
570 base::RunLoop run_loop; 571 base::RunLoop run_loop;
571 content::BrowserThread::PostTaskAndReply(content::BrowserThread::IO, 572 content::BrowserThread::PostTaskAndReply(content::BrowserThread::IO,
572 FROM_HERE, 573 FROM_HERE,
573 // Flush IO thread... 574 // Flush IO thread...
574 base::Bind(&base::DoNothing), 575 base::BindOnce(&base::DoNothing),
575 // ... and UI thread. 576 // ... and UI thread.
576 run_loop.QuitClosure()); 577 run_loop.QuitClosure());
577 run_loop.Run(); 578 run_loop.Run();
578 579
579 // Check if header exists and X-Chrome-Connected is correctly provided. 580 // Check if header exists and X-Chrome-Connected is correctly provided.
580 ASSERT_EQ(1u, request_headers.count(test_case.original_url.spec())); 581 ASSERT_EQ(1u, request_headers.count(test_case.original_url.spec()));
581 if (test_case.original_url_expects_header) { 582 if (test_case.original_url_expects_header) {
582 EXPECT_THAT(request_headers[test_case.original_url.spec()], 583 EXPECT_THAT(request_headers[test_case.original_url.spec()],
583 HasSubstr(signin::kChromeConnectedHeader)); 584 HasSubstr(signin::kChromeConnectedHeader));
584 } else { 585 } else {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 DownloadTestObserverNotInProgress download_observer( 633 DownloadTestObserverNotInProgress download_observer(
633 content::BrowserContext::GetDownloadManager(browser()->profile()), 1); 634 content::BrowserContext::GetDownloadManager(browser()->profile()), 1);
634 download_observer.StartObserving(); 635 download_observer.StartObserving();
635 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( 636 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(
636 "/download-anchor-attrib.html")); 637 "/download-anchor-attrib.html"));
637 download_observer.WaitForFinished(); 638 download_observer.WaitForFinished();
638 EXPECT_EQ(1, 639 EXPECT_EQ(1,
639 GetTimesStandardThrottlesAddedForURL( 640 GetTimesStandardThrottlesAddedForURL(
640 embedded_test_server()->GetURL("/anchor_download_test.png"))); 641 embedded_test_server()->GetURL("/anchor_download_test.png")));
641 } 642 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698