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..36372515e91cd72be7d9ae7a7a3a127e3272da37 100644 |
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc |
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc |
@@ -29,9 +29,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 +434,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 +717,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; |
} |
@@ -1339,6 +1299,23 @@ void ResourcePrefetchPredictor::ReportPredictedAccuracyStatsHelper( |
#undef RPP_PREDICTED_HISTOGRAM_COUNTS |
} |
+void ResourcePrefetchPredictor::OnURLsDeleted( |
+ HistoryService* history_service, |
+ const history::URLsDeletedDetails& deleted_details) { |
+ DCHECK_EQ(initialization_state_, INITIALIZED); |
+ if (deleted_details.all_history) { |
+ DeleteAllUrls(); |
+ UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent", |
+ REPORTING_EVENT_ALL_HISTORY_CLEARED, |
+ REPORTING_EVENT_COUNT); |
+ } else { |
+ DeleteUrls(deleted_details.rows); |
+ UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent", |
+ REPORTING_EVENT_PARTIAL_HISTORY_CLEARED, |
+ REPORTING_EVENT_COUNT); |
+ } |
+} |
+ |
void ResourcePrefetchPredictor::OnHistoryServiceLoaded( |
HistoryService* history_service) { |
OnHistoryAndCacheLoaded(); |