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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 314293005: Change HistoryService::QueryURL to use CancelableTaskTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and add comment for scoped_ptr usage Created 6 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 "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/guid.h" 14 #include "base/guid.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/prefs/testing_pref_service.h" 16 #include "base/prefs/testing_pref_service.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/task/cancelable_task_tracker.h"
18 #include "chrome/browser/autofill/personal_data_manager_factory.h" 19 #include "chrome/browser/autofill/personal_data_manager_factory.h"
19 #include "chrome/browser/browsing_data/browsing_data_helper.h" 20 #include "chrome/browser/browsing_data/browsing_data_helper.h"
20 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 21 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
23 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 24 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
24 #include "chrome/browser/chromeos/login/users/user_manager.h" 25 #include "chrome/browser/chromeos/login/users/user_manager.h"
25 #include "chrome/browser/chromeos/settings/cros_settings.h" 26 #include "chrome/browser/chromeos/settings/cros_settings.h"
26 #include "chrome/browser/chromeos/settings/device_settings_service.h" 27 #include "chrome/browser/chromeos/settings/device_settings_service.h"
27 #endif 28 #endif
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 378 }
378 379
379 // Returns true, if the given URL exists in the history service. 380 // Returns true, if the given URL exists in the history service.
380 bool HistoryContainsURL(const GURL& url) { 381 bool HistoryContainsURL(const GURL& url) {
381 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 382 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
382 new content::MessageLoopRunner; 383 new content::MessageLoopRunner;
383 quit_closure_ = message_loop_runner->QuitClosure(); 384 quit_closure_ = message_loop_runner->QuitClosure();
384 history_service_->QueryURL( 385 history_service_->QueryURL(
385 url, 386 url,
386 true, 387 true,
387 &consumer_,
388 base::Bind(&RemoveHistoryTester::SaveResultAndQuit, 388 base::Bind(&RemoveHistoryTester::SaveResultAndQuit,
389 base::Unretained(this))); 389 base::Unretained(this)),
390 &tracker_);
390 message_loop_runner->Run(); 391 message_loop_runner->Run();
391 return query_url_success_; 392 return query_url_success_;
392 } 393 }
393 394
394 void AddHistory(const GURL& url, base::Time time) { 395 void AddHistory(const GURL& url, base::Time time) {
395 history_service_->AddPage(url, time, NULL, 0, GURL(), 396 history_service_->AddPage(url, time, NULL, 0, GURL(),
396 history::RedirectList(), content::PAGE_TRANSITION_LINK, 397 history::RedirectList(), content::PAGE_TRANSITION_LINK,
397 history::SOURCE_BROWSED, false); 398 history::SOURCE_BROWSED, false);
398 } 399 }
399 400
400 private: 401 private:
401 // Callback for HistoryService::QueryURL. 402 // Callback for HistoryService::QueryURL.
402 void SaveResultAndQuit(HistoryService::Handle, 403 void SaveResultAndQuit(bool success,
403 bool success, 404 const history::URLRow&,
404 const history::URLRow*, 405 const history::VisitVector&) {
405 history::VisitVector*) {
406 query_url_success_ = success; 406 query_url_success_ = success;
407 quit_closure_.Run(); 407 quit_closure_.Run();
408 } 408 }
409 409
410 // For History requests. 410 // For History requests.
411 CancelableRequestConsumer consumer_; 411 base::CancelableTaskTracker tracker_;
412 bool query_url_success_; 412 bool query_url_success_;
413 base::Closure quit_closure_; 413 base::Closure quit_closure_;
414 414
415 // TestingProfile owns the history service; we shouldn't delete it. 415 // TestingProfile owns the history service; we shouldn't delete it.
416 HistoryService* history_service_; 416 HistoryService* history_service_;
417 417
418 DISALLOW_COPY_AND_ASSIGN(RemoveHistoryTester); 418 DISALLOW_COPY_AND_ASSIGN(RemoveHistoryTester);
419 }; 419 };
420 420
421 class RemoveAutofillTester : public autofill::PersonalDataManagerObserver { 421 class RemoveAutofillTester : public autofill::PersonalDataManagerObserver {
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 } 1687 }
1688 1688
1689 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts_ProtectedOrigins) { 1689 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts_ProtectedOrigins) {
1690 DomainReliabilityMonitor* monitor = UseProfileWithDomainReliabilityMonitor(); 1690 DomainReliabilityMonitor* monitor = UseProfileWithDomainReliabilityMonitor();
1691 BlockUntilBrowsingDataRemoved( 1691 BlockUntilBrowsingDataRemoved(
1692 BrowsingDataRemover::EVERYTHING, 1692 BrowsingDataRemover::EVERYTHING,
1693 BrowsingDataRemover::REMOVE_COOKIES, true); 1693 BrowsingDataRemover::REMOVE_COOKIES, true);
1694 EXPECT_TRUE(monitor->was_cleared_for_testing()); 1694 EXPECT_TRUE(monitor->was_cleared_for_testing());
1695 EXPECT_EQ(CLEAR_CONTEXTS, monitor->cleared_mode_for_testing()); 1695 EXPECT_EQ(CLEAR_CONTEXTS, monitor->cleared_mode_for_testing());
1696 } 1696 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/custom_home_pages_table_model.h » ('j') | chrome/browser/custom_home_pages_table_model.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698