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

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

Issue 2827523003: Move BrowsingDataRemover to content/ (Closed)
Patch Set: Addressed some comments. 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 base::Unretained(this), 397 base::Unretained(this),
399 base::Unretained(profile->GetRequestContext()), 398 base::Unretained(profile->GetRequestContext()),
400 &fetches), 399 &fetches),
401 run_loop.QuitClosure()); 400 run_loop.QuitClosure());
402 run_loop.Run(); 401 run_loop.Run();
403 DCHECK_NE(-1, fetches); 402 DCHECK_NE(-1, fetches);
404 return fetches; 403 return fetches;
405 } 404 }
406 405
407 void BrowsingDataRemoveAndWait(int remove_mask) { 406 void BrowsingDataRemoveAndWait(int remove_mask) {
408 BrowsingDataRemover* remover = 407 content::BrowsingDataRemover* remover =
409 BrowsingDataRemoverFactory::GetForBrowserContext(browser()->profile()); 408 content::BrowserContext::GetBrowsingDataRemover(browser()->profile());
410 BrowsingDataRemoverCompletionObserver completion_observer(remover); 409 content::BrowsingDataRemoverCompletionObserver completion_observer(remover);
411 remover->RemoveAndReply(browsing_data::CalculateBeginDeleteTime( 410 remover->RemoveAndReply(
412 browsing_data::TimePeriod::LAST_HOUR), 411 browsing_data::CalculateBeginDeleteTime(
413 browsing_data::CalculateEndDeleteTime( 412 browsing_data::TimePeriod::LAST_HOUR),
414 browsing_data::TimePeriod::LAST_HOUR), 413 browsing_data::CalculateEndDeleteTime(
415 remove_mask, 414 browsing_data::TimePeriod::LAST_HOUR),
416 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, 415 remove_mask, content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
417 &completion_observer); 416 &completion_observer);
418 completion_observer.BlockUntilCompletion(); 417 completion_observer.BlockUntilCompletion();
419 } 418 }
420 419
421 // Something of a cheat; nuke the dictionaries off the SdchManager without 420 // Something of a cheat; nuke the dictionaries off the SdchManager without
422 // touching the cache (which browsing data remover would do). 421 // touching the cache (which browsing data remover would do).
423 void NukeSdchDictionaries() { 422 void NukeSdchDictionaries() {
424 base::RunLoop run_loop; 423 base::RunLoop run_loop;
425 content::BrowserThread::PostTaskAndReply( 424 content::BrowserThread::PostTaskAndReply(
426 content::BrowserThread::IO, FROM_HERE, 425 content::BrowserThread::IO, FROM_HERE,
427 base::Bind(&SdchBrowserTest::NukeSdchDictionariesOnIOThread, 426 base::Bind(&SdchBrowserTest::NukeSdchDictionariesOnIOThread,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (!sdch_enabled()) { 701 if (!sdch_enabled()) {
703 LOG(ERROR) << "SDCH disabled; not running test."; 702 LOG(ERROR) << "SDCH disabled; not running test.";
704 return; 703 return;
705 } 704 }
706 705
707 ASSERT_TRUE(ForceSdchDictionaryLoad(browser())); 706 ASSERT_TRUE(ForceSdchDictionaryLoad(browser()));
708 707
709 // Confirm browsing data remover without removing the cache leaves 708 // Confirm browsing data remover without removing the cache leaves
710 // SDCH alone. 709 // SDCH alone.
711 BrowsingDataRemoveAndWait(ChromeBrowsingDataRemoverDelegate::ALL_DATA_TYPES & 710 BrowsingDataRemoveAndWait(ChromeBrowsingDataRemoverDelegate::ALL_DATA_TYPES &
712 ~BrowsingDataRemover::DATA_TYPE_CACHE); 711 ~content::BrowsingDataRemover::DATA_TYPE_CACHE);
713 bool sdch_encoding_used = false; 712 bool sdch_encoding_used = false;
714 ASSERT_TRUE(GetData(&sdch_encoding_used)); 713 ASSERT_TRUE(GetData(&sdch_encoding_used));
715 EXPECT_TRUE(sdch_encoding_used); 714 EXPECT_TRUE(sdch_encoding_used);
716 715
717 // Confirm browsing data remover removing the cache clears SDCH state. 716 // Confirm browsing data remover removing the cache clears SDCH state.
718 BrowsingDataRemoveAndWait(BrowsingDataRemover::DATA_TYPE_CACHE); 717 BrowsingDataRemoveAndWait(content::BrowsingDataRemover::DATA_TYPE_CACHE);
719 sdch_encoding_used = false; 718 sdch_encoding_used = false;
720 ASSERT_TRUE(GetData(&sdch_encoding_used)); 719 ASSERT_TRUE(GetData(&sdch_encoding_used));
721 EXPECT_FALSE(sdch_encoding_used); 720 EXPECT_FALSE(sdch_encoding_used);
722 } 721 }
723 722
724 // Confirm dictionaries not visible in other profiles. 723 // Confirm dictionaries not visible in other profiles.
725 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) { 724 IN_PROC_BROWSER_TEST_F(SdchBrowserTest, Isolation) {
726 if (!sdch_enabled()) { 725 if (!sdch_enabled()) {
727 LOG(ERROR) << "SDCH disabled; not running test."; 726 LOG(ERROR) << "SDCH disabled; not running test.";
728 return; 727 return;
(...skipping 27 matching lines...) Expand all
756 ASSERT_TRUE(SetupIncognitoBrowser()); 755 ASSERT_TRUE(SetupIncognitoBrowser());
757 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); 756 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser()));
758 757
759 // Data fetches on main browser should not be SDCH encoded. 758 // Data fetches on main browser should not be SDCH encoded.
760 bool sdch_encoding_used = true; 759 bool sdch_encoding_used = true;
761 ASSERT_TRUE(GetData(&sdch_encoding_used)); 760 ASSERT_TRUE(GetData(&sdch_encoding_used));
762 EXPECT_FALSE(sdch_encoding_used); 761 EXPECT_FALSE(sdch_encoding_used);
763 } 762 }
764 763
765 } // namespace 764 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698