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

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

Issue 2827523003: Move BrowsingDataRemover to content/ (Closed)
Patch Set: Rebase over codereview.chromium.org/2815913005 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 // 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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/string_tokenizer.h" 20 #include "base/strings/string_tokenizer.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browsing_data/browsing_data_helper.h" 25 #include "chrome/browser/browsing_data/browsing_data_helper.h"
26 #include "chrome/browser/browsing_data/browsing_data_remover.h"
27 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
28 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
29 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 26 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
30 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
33 #include "chrome/browser/ui/browser_tabstrip.h" 30 #include "chrome/browser/ui/browser_tabstrip.h"
34 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/browser/ui/tabs/tab_strip_model.h" 32 #include "chrome/browser/ui/tabs/tab_strip_model.h"
36 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
37 #include "chrome/test/base/in_process_browser_test.h" 34 #include "chrome/test/base/in_process_browser_test.h"
38 #include "components/browsing_data/core/browsing_data_utils.h" 35 #include "components/browsing_data/core/browsing_data_utils.h"
39 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/browsing_data_remover.h"
40 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
41 #include "content/public/test/browser_test_utils.h" 39 #include "content/public/test/browser_test_utils.h"
40 #include "content/public/test/browsing_data_remover_test_util.h"
42 #include "content/public/test/test_utils.h" 41 #include "content/public/test/test_utils.h"
43 #include "crypto/sha2.h" 42 #include "crypto/sha2.h"
44 #include "net/base/sdch_manager.h" 43 #include "net/base/sdch_manager.h"
45 #include "net/base/sdch_observer.h" 44 #include "net/base/sdch_observer.h"
46 #include "net/http/http_response_headers.h" 45 #include "net/http/http_response_headers.h"
47 #include "net/test/embedded_test_server/embedded_test_server.h" 46 #include "net/test/embedded_test_server/embedded_test_server.h"
48 #include "net/test/embedded_test_server/http_request.h" 47 #include "net/test/embedded_test_server/http_request.h"
49 #include "net/test/embedded_test_server/http_response.h" 48 #include "net/test/embedded_test_server/http_response.h"
50 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 49 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
51 #include "net/url_request/url_fetcher.h" 50 #include "net/url_request/url_fetcher.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 base::Unretained(this), 396 base::Unretained(this),
398 base::Unretained(profile->GetRequestContext()), 397 base::Unretained(profile->GetRequestContext()),
399 &fetches), 398 &fetches),
400 run_loop.QuitClosure()); 399 run_loop.QuitClosure());
401 run_loop.Run(); 400 run_loop.Run();
402 DCHECK_NE(-1, fetches); 401 DCHECK_NE(-1, fetches);
403 return fetches; 402 return fetches;
404 } 403 }
405 404
406 void BrowsingDataRemoveAndWait(int remove_mask) { 405 void BrowsingDataRemoveAndWait(int remove_mask) {
407 BrowsingDataRemover* remover = 406 content::BrowsingDataRemover* remover =
408 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); 407 content::BrowserContext::GetBrowsingDataRemover(browser()->profile());
409 BrowsingDataRemoverCompletionObserver completion_observer(remover); 408 content::BrowsingDataRemoverCompletionObserver completion_observer(remover);
410 remover->RemoveAndReply(browsing_data::CalculateBeginDeleteTime( 409 remover->RemoveAndReply(
411 browsing_data::TimePeriod::LAST_HOUR), 410 browsing_data::CalculateBeginDeleteTime(
412 browsing_data::CalculateEndDeleteTime( 411 browsing_data::TimePeriod::LAST_HOUR),
413 browsing_data::TimePeriod::LAST_HOUR), 412 browsing_data::CalculateEndDeleteTime(
414 remove_mask, 413 browsing_data::TimePeriod::LAST_HOUR),
415 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, 414 remove_mask, content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
416 &completion_observer); 415 &completion_observer);
417 completion_observer.BlockUntilCompletion(); 416 completion_observer.BlockUntilCompletion();
418 } 417 }
419 418
420 // Something of a cheat; nuke the dictionaries off the SdchManager without 419 // Something of a cheat; nuke the dictionaries off the SdchManager without
421 // touching the cache (which browsing data remover would do). 420 // touching the cache (which browsing data remover would do).
422 void NukeSdchDictionaries() { 421 void NukeSdchDictionaries() {
423 base::RunLoop run_loop; 422 base::RunLoop run_loop;
424 content::BrowserThread::PostTaskAndReply( 423 content::BrowserThread::PostTaskAndReply(
425 content::BrowserThread::IO, FROM_HERE, 424 content::BrowserThread::IO, FROM_HERE,
426 base::BindOnce(&SdchBrowserTest::NukeSdchDictionariesOnIOThread, 425 base::BindOnce(&SdchBrowserTest::NukeSdchDictionariesOnIOThread,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 if (!sdch_enabled()) { 697 if (!sdch_enabled()) {
699 LOG(ERROR) << "SDCH disabled; not running test."; 698 LOG(ERROR) << "SDCH disabled; not running test.";
700 return; 699 return;
701 } 700 }
702 701
703 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); 702 ASSERT_TRUE(ForceSdchDictionaryLoad(browser()));
704 703
705 // Confirm browsing data remover without removing the cache leaves 704 // Confirm browsing data remover without removing the cache leaves
706 // SDCH alone. 705 // SDCH alone.
707 BrowsingDataRemoveAndWait(ChromeBrowsingDataRemoverDelegate::ALL_DATA_TYPES & 706 BrowsingDataRemoveAndWait(ChromeBrowsingDataRemoverDelegate::ALL_DATA_TYPES &
708 ~BrowsingDataRemover::DATA_TYPE_CACHE); 707 ~content::BrowsingDataRemover::DATA_TYPE_CACHE);
709 bool sdch_encoding_used = false; 708 bool sdch_encoding_used = false;
710 ASSERT_TRUE(GetData(&sdch_encoding_used)); 709 ASSERT_TRUE(GetData(&sdch_encoding_used));
711 EXPECT_TRUE(sdch_encoding_used); 710 EXPECT_TRUE(sdch_encoding_used);
712 711
713 // Confirm browsing data remover removing the cache clears SDCH state. 712 // Confirm browsing data remover removing the cache clears SDCH state.
714 BrowsingDataRemoveAndWait(BrowsingDataRemover::DATA_TYPE_CACHE); 713 BrowsingDataRemoveAndWait(content::BrowsingDataRemover::DATA_TYPE_CACHE);
715 sdch_encoding_used = false; 714 sdch_encoding_used = false;
716 ASSERT_TRUE(GetData(&sdch_encoding_used)); 715 ASSERT_TRUE(GetData(&sdch_encoding_used));
717 EXPECT_FALSE(sdch_encoding_used); 716 EXPECT_FALSE(sdch_encoding_used);
718 } 717 }
719 718
720 // Confirm dictionaries not visible in other profiles. 719 // Confirm dictionaries not visible in other profiles.
721 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) { 720 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) {
722 if (!sdch_enabled()) { 721 if (!sdch_enabled()) {
723 LOG(ERROR) << "SDCH disabled; not running test."; 722 LOG(ERROR) << "SDCH disabled; not running test.";
724 return; 723 return;
(...skipping 27 matching lines...) Expand all
752 ASSERT_TRUE(SetupIncognitoBrowser()); 751 ASSERT_TRUE(SetupIncognitoBrowser());
753 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); 752 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser()));
754 753
755 // Data fetches on main browser should not be SDCH encoded. 754 // Data fetches on main browser should not be SDCH encoded.
756 bool sdch_encoding_used = true; 755 bool sdch_encoding_used = true;
757 ASSERT_TRUE(GetData(&sdch_encoding_used)); 756 ASSERT_TRUE(GetData(&sdch_encoding_used));
758 EXPECT_FALSE(sdch_encoding_used); 757 EXPECT_FALSE(sdch_encoding_used);
759 } 758 }
760 759
761 } // namespace 760 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor_browsertest.cc ('k') | chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698