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

Side by Side Diff: chrome/browser/ui/webui/history_ui.cc

Issue 164703002: Don't leak WebHistoryService::Request on HistoryService shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dubroy comments Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/history_ui.h" 5 #include "chrome/browser/ui/webui/history_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 return result.Pass(); 380 return result.Pass();
381 } 381 }
382 382
383 bool BrowsingHistoryHandler::HistoryEntry::SortByTimeDescending( 383 bool BrowsingHistoryHandler::HistoryEntry::SortByTimeDescending(
384 const BrowsingHistoryHandler::HistoryEntry& entry1, 384 const BrowsingHistoryHandler::HistoryEntry& entry1,
385 const BrowsingHistoryHandler::HistoryEntry& entry2) { 385 const BrowsingHistoryHandler::HistoryEntry& entry2) {
386 return entry1.time > entry2.time; 386 return entry1.time > entry2.time;
387 } 387 }
388 388
389 BrowsingHistoryHandler::BrowsingHistoryHandler() {} 389 BrowsingHistoryHandler::BrowsingHistoryHandler()
390 : has_pending_delete_request_(false),
391 weak_factory_(this) {
392 }
390 393
391 BrowsingHistoryHandler::~BrowsingHistoryHandler() { 394 BrowsingHistoryHandler::~BrowsingHistoryHandler() {
392 history_request_consumer_.CancelAllRequests(); 395 history_request_consumer_.CancelAllRequests();
393 web_history_request_.reset(); 396 web_history_request_.reset();
394 } 397 }
395 398
396 void BrowsingHistoryHandler::RegisterMessages() { 399 void BrowsingHistoryHandler::RegisterMessages() {
397 // Create our favicon data source. 400 // Create our favicon data source.
398 Profile* profile = Profile::FromWebUI(web_ui()); 401 Profile* profile = Profile::FromWebUI(web_ui());
399 content::URLDataSource::Add( 402 content::URLDataSource::Add(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 NOTREACHED() << "Failed to convert argument 4."; 525 NOTREACHED() << "Failed to convert argument 4.";
523 return; 526 return;
524 } 527 }
525 528
526 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; 529 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY;
527 QueryHistory(search_text, options); 530 QueryHistory(search_text, options);
528 } 531 }
529 532
530 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { 533 void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) {
531 Profile* profile = Profile::FromWebUI(web_ui()); 534 Profile* profile = Profile::FromWebUI(web_ui());
535 // TODO(davidben): history.js is not aware of this failure and will still
536 // override |deleteCompleteCallback_|.
532 if (delete_task_tracker_.HasTrackedTasks() || 537 if (delete_task_tracker_.HasTrackedTasks() ||
538 has_pending_delete_request_ ||
533 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { 539 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) {
534 web_ui()->CallJavascriptFunction("deleteFailed"); 540 web_ui()->CallJavascriptFunction("deleteFailed");
535 return; 541 return;
536 } 542 }
537 543
538 HistoryService* history_service = 544 HistoryService* history_service =
539 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); 545 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
540 history::WebHistoryService* web_history = 546 history::WebHistoryService* web_history =
541 WebHistoryServiceFactory::GetForProfile(profile); 547 WebHistoryServiceFactory::GetForProfile(profile);
542 548
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 history_service->ProcessLocalDeleteDirective(delete_directive); 611 history_service->ProcessLocalDeleteDirective(delete_directive);
606 } 612 }
607 613
608 history_service->ExpireHistory( 614 history_service->ExpireHistory(
609 expire_list, 615 expire_list,
610 base::Bind(&BrowsingHistoryHandler::RemoveComplete, 616 base::Bind(&BrowsingHistoryHandler::RemoveComplete,
611 base::Unretained(this)), 617 base::Unretained(this)),
612 &delete_task_tracker_); 618 &delete_task_tracker_);
613 619
614 if (web_history) { 620 if (web_history) {
615 web_history_delete_request_ = web_history->ExpireHistory( 621 has_pending_delete_request_ = true;
622 web_history->ExpireHistory(
616 expire_list, 623 expire_list,
617 base::Bind(&BrowsingHistoryHandler::RemoveWebHistoryComplete, 624 base::Bind(&BrowsingHistoryHandler::RemoveWebHistoryComplete,
618 base::Unretained(this))); 625 weak_factory_.GetWeakPtr()));
619 } 626 }
620 627
621 #if defined(ENABLE_EXTENSIONS) 628 #if defined(ENABLE_EXTENSIONS)
622 // If the profile has activity logging enabled also clean up any URLs from 629 // If the profile has activity logging enabled also clean up any URLs from
623 // the extension activity log. The extension activity log contains URLS 630 // the extension activity log. The extension activity log contains URLS
624 // which websites an extension has activity on so it will indirectly 631 // which websites an extension has activity on so it will indirectly
625 // contain websites that a user has visited. 632 // contain websites that a user has visited.
626 extensions::ActivityLog* activity_log = 633 extensions::ActivityLog* activity_log =
627 extensions::ActivityLog::GetInstance(profile); 634 extensions::ActivityLog::GetInstance(profile);
628 for (std::vector<history::ExpireHistoryArgs>::const_iterator it = 635 for (std::vector<history::ExpireHistoryArgs>::const_iterator it =
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 results_info_value_.SetBoolean("hasSyncedResults", results_value != NULL); 886 results_info_value_.SetBoolean("hasSyncedResults", results_value != NULL);
880 if (!history_request_consumer_.HasPendingRequests()) 887 if (!history_request_consumer_.HasPendingRequests())
881 ReturnResultsToFrontEnd(); 888 ReturnResultsToFrontEnd();
882 } 889 }
883 890
884 void BrowsingHistoryHandler::RemoveComplete() { 891 void BrowsingHistoryHandler::RemoveComplete() {
885 urls_to_be_deleted_.clear(); 892 urls_to_be_deleted_.clear();
886 893
887 // Notify the page that the deletion request is complete, but only if a web 894 // Notify the page that the deletion request is complete, but only if a web
888 // history delete request is not still pending. 895 // history delete request is not still pending.
889 if (!(web_history_delete_request_.get() && 896 if (!has_pending_delete_request_)
890 web_history_delete_request_->is_pending())) {
891 web_ui()->CallJavascriptFunction("deleteComplete"); 897 web_ui()->CallJavascriptFunction("deleteComplete");
892 }
893 } 898 }
894 899
895 void BrowsingHistoryHandler::RemoveWebHistoryComplete( 900 void BrowsingHistoryHandler::RemoveWebHistoryComplete(bool success) {
896 history::WebHistoryService::Request* request, bool success) { 901 has_pending_delete_request_ = false;
897 // TODO(dubroy): Should we handle failure somehow? Delete directives will 902 // TODO(dubroy): Should we handle failure somehow? Delete directives will
898 // ensure that the visits are eventually deleted, so maybe it's not necessary. 903 // ensure that the visits are eventually deleted, so maybe it's not necessary.
899 if (!delete_task_tracker_.HasTrackedTasks()) 904 if (!delete_task_tracker_.HasTrackedTasks())
900 RemoveComplete(); 905 RemoveComplete();
901 } 906 }
902 907
903 void BrowsingHistoryHandler::SetQueryTimeInWeeks( 908 void BrowsingHistoryHandler::SetQueryTimeInWeeks(
904 int offset, history::QueryOptions* options) { 909 int offset, history::QueryOptions* options) {
905 // LocalMidnight returns the beginning of the current day so get the 910 // LocalMidnight returns the beginning of the current day so get the
906 // beginning of the next one. 911 // beginning of the next one.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 1011 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
1007 net::EscapeQueryParamValue(base::UTF16ToUTF8(text), true)); 1012 net::EscapeQueryParamValue(base::UTF16ToUTF8(text), true));
1008 } 1013 }
1009 1014
1010 // static 1015 // static
1011 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 1016 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
1012 ui::ScaleFactor scale_factor) { 1017 ui::ScaleFactor scale_factor) {
1013 return ResourceBundle::GetSharedInstance(). 1018 return ResourceBundle::GetSharedInstance().
1014 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 1019 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
1015 } 1020 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698