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

Side by Side Diff: chrome/browser/net/sdch_browsertest.cc

Issue 1117613003: [chrome/browser/net] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH
6 // results 6 // results
7 7
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 EXPECT_EQ(request_vector[2].relative_url, kDataURLPath); 527 EXPECT_EQ(request_vector[2].relative_url, kDataURLPath);
528 EXPECT_EQ(request_vector[3].relative_url, kDataURLPath); 528 EXPECT_EQ(request_vector[3].relative_url, kDataURLPath);
529 return (4u == request_vector.size() && 529 return (4u == request_vector.size() &&
530 request_vector[2].relative_url == kDataURLPath && 530 request_vector[2].relative_url == kDataURLPath &&
531 request_vector[3].relative_url == kDataURLPath); 531 request_vector[3].relative_url == kDataURLPath);
532 } 532 }
533 533
534 private: 534 private:
535 static void NukeSdchDictionariesOnIOThread( 535 static void NukeSdchDictionariesOnIOThread(
536 net::URLRequestContextGetter* context_getter) { 536 net::URLRequestContextGetter* context_getter) {
537 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 537 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
538 net::SdchManager* sdch_manager = 538 net::SdchManager* sdch_manager =
539 context_getter->GetURLRequestContext()->sdch_manager(); 539 context_getter->GetURLRequestContext()->sdch_manager();
540 DCHECK(sdch_manager); 540 DCHECK(sdch_manager);
541 sdch_manager->ClearData(); 541 sdch_manager->ClearData();
542 } 542 }
543 543
544 void GetNumberOfDictionaryFetchesOnIOThread( 544 void GetNumberOfDictionaryFetchesOnIOThread(
545 net::URLRequestContextGetter* context_getter, 545 net::URLRequestContextGetter* context_getter,
546 int* result) { 546 int* result) {
547 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 547 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
548 548
549 net::SdchManager* manager( 549 net::SdchManager* manager(
550 context_getter->GetURLRequestContext()->sdch_manager()); 550 context_getter->GetURLRequestContext()->sdch_manager());
551 DCHECK(fetch_counts_.end() != fetch_counts_.find(manager)); 551 DCHECK(fetch_counts_.end() != fetch_counts_.find(manager));
552 552
553 *result = fetch_counts_[manager]; 553 *result = fetch_counts_[manager];
554 } 554 }
555 555
556 // InProcessBrowserTest 556 // InProcessBrowserTest
557 void SetUpCommandLine(base::CommandLine* command_line) override { 557 void SetUpCommandLine(base::CommandLine* command_line) override {
(...skipping 26 matching lines...) Expand all
584 584
585 content::BrowserThread::PostTask( 585 content::BrowserThread::PostTask(
586 content::BrowserThread::IO, 586 content::BrowserThread::IO,
587 FROM_HERE, 587 FROM_HERE,
588 base::Bind(&SdchBrowserTest::UnsubscribeFromAllSdchNotifications, 588 base::Bind(&SdchBrowserTest::UnsubscribeFromAllSdchNotifications,
589 base::Unretained(this))); 589 base::Unretained(this)));
590 } 590 }
591 591
592 void SubscribeToSdchNotifications( 592 void SubscribeToSdchNotifications(
593 net::URLRequestContextGetter* context_getter) { 593 net::URLRequestContextGetter* context_getter) {
594 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 594 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
595 595
596 net::SdchManager* manager = 596 net::SdchManager* manager =
597 context_getter->GetURLRequestContext()->sdch_manager(); 597 context_getter->GetURLRequestContext()->sdch_manager();
598 DCHECK(fetch_counts_.end() == fetch_counts_.find(manager)); 598 DCHECK(fetch_counts_.end() == fetch_counts_.find(manager));
599 599
600 fetch_counts_[manager] = 0; 600 fetch_counts_[manager] = 0;
601 manager->AddObserver(this); 601 manager->AddObserver(this);
602 } 602 }
603 603
604 void UnsubscribeFromAllSdchNotifications() { 604 void UnsubscribeFromAllSdchNotifications() {
605 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 605 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
606 606
607 for (auto it = fetch_counts_.begin(); it != fetch_counts_.end(); ++it) 607 for (auto it = fetch_counts_.begin(); it != fetch_counts_.end(); ++it)
608 it->first->RemoveObserver(this); 608 it->first->RemoveObserver(this);
609 609
610 fetch_counts_.clear(); 610 fetch_counts_.clear();
611 } 611 }
612 612
613 // SdchObserver 613 // SdchObserver
614 void OnDictionaryUsed(net::SdchManager* manager, 614 void OnDictionaryUsed(net::SdchManager* manager,
615 const std::string& server_hash) override {} 615 const std::string& server_hash) override {}
616 616
617 void OnGetDictionary(net::SdchManager* manager, 617 void OnGetDictionary(net::SdchManager* manager,
618 const GURL& request_url, 618 const GURL& request_url,
619 const GURL& dictionary_url) override { 619 const GURL& dictionary_url) override {
620 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 620 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
621 DLOG(ERROR) << "Retrieving count of notifications from manager " << manager; 621 DLOG(ERROR) << "Retrieving count of notifications from manager " << manager;
622 DCHECK(fetch_counts_.end() != fetch_counts_.find(manager)); 622 DCHECK(fetch_counts_.end() != fetch_counts_.find(manager));
623 ++fetch_counts_[manager]; 623 ++fetch_counts_[manager];
624 } 624 }
625 625
626 void OnClearDictionaries(net::SdchManager* manager) override {} 626 void OnClearDictionaries(net::SdchManager* manager) override {}
627 627
628 // URLFetcherDelegate 628 // URLFetcherDelegate
629 void OnURLFetchComplete(const net::URLFetcher* source) override { 629 void OnURLFetchComplete(const net::URLFetcher* source) override {
630 url_fetch_complete_ = true; 630 url_fetch_complete_ = true;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 ASSERT_TRUE(SetupIncognitoBrowser()); 695 ASSERT_TRUE(SetupIncognitoBrowser());
696 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); 696 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser()));
697 697
698 // Data fetches on main browser should not be SDCH encoded. 698 // Data fetches on main browser should not be SDCH encoded.
699 bool sdch_encoding_used = true; 699 bool sdch_encoding_used = true;
700 ASSERT_TRUE(GetData(&sdch_encoding_used)); 700 ASSERT_TRUE(GetData(&sdch_encoding_used));
701 EXPECT_FALSE(sdch_encoding_used); 701 EXPECT_FALSE(sdch_encoding_used);
702 } 702 }
703 703
704 } // namespace 704 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/proxy_service_factory.cc ('k') | chrome/browser/net/ssl_config_service_manager_pref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698