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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 773103004: Remove NOTIFICATION_HISTORY_URLS_DELETED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed local variables in tests Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_predictor.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.cc b/chrome/browser/predictors/resource_prefetch_predictor.cc
index 6f1eeab35dc739d8175bec98fe0eda1c586d846e..46da3b50d8d2e58a7a78db0392dba5cff614ec67 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc
@@ -15,10 +15,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_database.h"
#include "chrome/browser/history/history_db_task.h"
-#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/predictors/predictor_database.h"
@@ -29,9 +27,6 @@
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h"
#include "net/base/mime_util.h"
@@ -437,43 +432,12 @@ void ResourcePrefetchPredictor::FinishedPrefetchForNavigation(
}
}
-void ResourcePrefetchPredictor::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- switch (type) {
- case chrome::NOTIFICATION_HISTORY_URLS_DELETED: {
- DCHECK_EQ(initialization_state_, INITIALIZED);
- const content::Details<const history::URLsDeletedDetails>
- urls_deleted_details =
- content::Details<const history::URLsDeletedDetails>(details);
- if (urls_deleted_details->all_history) {
- DeleteAllUrls();
- UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent",
- REPORTING_EVENT_ALL_HISTORY_CLEARED,
- REPORTING_EVENT_COUNT);
- } else {
- DeleteUrls(urls_deleted_details->rows);
- UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent",
- REPORTING_EVENT_PARTIAL_HISTORY_CLEARED,
- REPORTING_EVENT_COUNT);
- }
- break;
- }
-
- default:
- NOTREACHED() << "Unexpected notification observed.";
- break;
- }
-}
-
void ResourcePrefetchPredictor::Shutdown() {
if (prefetch_manager_.get()) {
prefetch_manager_->ShutdownOnUIThread();
prefetch_manager_ = NULL;
}
+ history_service_observer_.RemoveAll();
}
void ResourcePrefetchPredictor::OnMainFrameRequest(
@@ -751,17 +715,11 @@ void ResourcePrefetchPredictor::OnHistoryAndCacheLoaded() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(initialization_state_, INITIALIZING);
- notification_registrar_.Add(this,
- chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- content::Source<Profile>(profile_));
-
// Initialize the prefetch manager only if prefetching is enabled.
if (config_.IsPrefetchingEnabled(profile_)) {
prefetch_manager_ = new ResourcePrefetcherManager(
this, config_, profile_->GetRequestContext());
}
-
- history_service_observer_.RemoveAll();
initialization_state_ = INITIALIZED;
}
@@ -807,15 +765,14 @@ void ResourcePrefetchPredictor::DeleteUrls(const history::URLRows& urls) {
// in the cache.
std::vector<std::string> urls_to_delete, hosts_to_delete;
- for (history::URLRows::const_iterator it = urls.begin(); it != urls.end();
- ++it) {
- const std::string url_spec = it->url().spec();
+ for (const auto& it : urls) {
+ const std::string url_spec = it.url().spec();
sdefresne 2014/12/08 17:41:06 nit: const std::string& url_spec = it.url().spec()
nshaik 2014/12/08 21:29:53 Done.
if (url_table_cache_->find(url_spec) != url_table_cache_->end()) {
urls_to_delete.push_back(url_spec);
url_table_cache_->erase(url_spec);
}
- const std::string host = it->url().host();
+ const std::string host = it.url().host();
sdefresne 2014/12/08 17:41:06 nit: const std::string& host = it.url().host();
nshaik 2014/12/08 21:29:53 Done.
if (host_table_cache_->find(host) != host_table_cache_->end()) {
hosts_to_delete.push_back(host);
host_table_cache_->erase(host);
@@ -1339,6 +1296,27 @@ void ResourcePrefetchPredictor::ReportPredictedAccuracyStatsHelper(
#undef RPP_PREDICTED_HISTOGRAM_COUNTS
}
+void ResourcePrefetchPredictor::OnURLsDeleted(
+ HistoryService* history_service,
+ bool all_history,
+ bool expired,
+ const history::URLRows& deleted_rows,
+ const std::set<GURL>& favicon_urls) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(initialization_state_, INITIALIZED);
+ if (all_history) {
+ DeleteAllUrls();
+ UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent",
+ REPORTING_EVENT_ALL_HISTORY_CLEARED,
+ REPORTING_EVENT_COUNT);
+ } else {
+ DeleteUrls(deleted_rows);
+ UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent",
+ REPORTING_EVENT_PARTIAL_HISTORY_CLEARED,
+ REPORTING_EVENT_COUNT);
+ }
+}
+
void ResourcePrefetchPredictor::OnHistoryServiceLoaded(
HistoryService* history_service) {
OnHistoryAndCacheLoaded();

Powered by Google App Engine
This is Rietveld 408576698