summaryrefslogtreecommitdiffstats
path: root/chrome/browser/predictors
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-14 02:35:09 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-14 02:35:09 +0000
commit6578fef37a7aa42c4259bb86ca72cf05ec084f9a (patch)
tree3f694557bf32a6b4fe9e87915faf79a48a03dcdf /chrome/browser/predictors
parent166df683c229ed6c028afeb3e7bbe77f2565bda1 (diff)
downloadchromium_src-6578fef37a7aa42c4259bb86ca72cf05ec084f9a.zip
chromium_src-6578fef37a7aa42c4259bb86ca72cf05ec084f9a.tar.gz
chromium_src-6578fef37a7aa42c4259bb86ca72cf05ec084f9a.tar.bz2
Remove content notifications from ResourcePrefetchPredictor, remove NOTIFICATION_LOAD_FROM_MEMORY_CACHE.
BUG=170921 TEST=everything still works Review URL: https://codereview.chromium.org/25923002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/predictors')
-rw-r--r--chrome/browser/predictors/resource_prefetch_common.cc8
-rw-r--r--chrome/browser/predictors/resource_prefetch_common.h2
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor.cc95
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor.h19
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor_factory.cc6
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor_factory.h5
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor_tab_helper.cc63
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h34
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor_unittest.cc50
9 files changed, 163 insertions, 119 deletions
diff --git a/chrome/browser/predictors/resource_prefetch_common.cc b/chrome/browser/predictors/resource_prefetch_common.cc
index 4fe002e..055fa8b 100644
--- a/chrome/browser/predictors/resource_prefetch_common.cc
+++ b/chrome/browser/predictors/resource_prefetch_common.cc
@@ -167,10 +167,10 @@ NavigationID::NavigationID(const NavigationID& other)
creation_time(other.creation_time) {
}
-NavigationID::NavigationID(const content::WebContents& web_contents)
- : render_process_id(web_contents.GetRenderProcessHost()->GetID()),
- render_view_id(web_contents.GetRenderViewHost()->GetRoutingID()),
- main_frame_url(web_contents.GetURL()) {
+NavigationID::NavigationID(content::WebContents* web_contents)
+ : render_process_id(web_contents->GetRenderProcessHost()->GetID()),
+ render_view_id(web_contents->GetRenderViewHost()->GetRoutingID()),
+ main_frame_url(web_contents->GetURL()) {
}
bool NavigationID::is_valid() const {
diff --git a/chrome/browser/predictors/resource_prefetch_common.h b/chrome/browser/predictors/resource_prefetch_common.h
index 47243dc..de485cc 100644
--- a/chrome/browser/predictors/resource_prefetch_common.h
+++ b/chrome/browser/predictors/resource_prefetch_common.h
@@ -36,7 +36,7 @@ struct NavigationID {
// constructor.
NavigationID();
NavigationID(const NavigationID& other);
- explicit NavigationID(const content::WebContents& web_contents);
+ explicit NavigationID(content::WebContents* web_contents);
bool operator<(const NavigationID& rhs) const;
bool operator==(const NavigationID& rhs) const;
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.cc b/chrome/browser/predictors/resource_prefetch_predictor.cc
index ea5bd89..c1f04eb 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc
@@ -27,7 +27,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/load_from_memory_cache_details.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -303,10 +302,6 @@ ResourcePrefetchPredictor::ResourcePrefetchPredictor(
DCHECK(config_.IsURLLearningEnabled());
if (config_.IsHostPrefetchingEnabled())
DCHECK(config_.IsHostLearningEnabled());
-
- notification_registrar_.Add(this,
- content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
- content::NotificationService::AllSources());
}
ResourcePrefetchPredictor::~ResourcePrefetchPredictor() {
@@ -322,7 +317,7 @@ void ResourcePrefetchPredictor::RecordURLRequest(
OnMainFrameRequest(request);
}
-void ResourcePrefetchPredictor::RecordUrlResponse(
+void ResourcePrefetchPredictor::RecordURLResponse(
const URLRequestSummary& response) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (initialization_state_ != INITIALIZED)
@@ -334,7 +329,7 @@ void ResourcePrefetchPredictor::RecordUrlResponse(
OnSubresourceResponse(response);
}
-void ResourcePrefetchPredictor::RecordUrlRedirect(
+void ResourcePrefetchPredictor::RecordURLRedirect(
const URLRequestSummary& response) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (initialization_state_ != INITIALIZED)
@@ -344,6 +339,30 @@ void ResourcePrefetchPredictor::RecordUrlRedirect(
OnMainFrameRedirect(response);
}
+void ResourcePrefetchPredictor::RecordMainFrameLoadComplete(
+ const NavigationID& navigation_id) {
+ switch (initialization_state_) {
+ case NOT_INITIALIZED:
+ StartInitialization();
+ break;
+ case INITIALIZING:
+ break;
+ case INITIALIZED: {
+ RecordNavigationEvent(NAVIGATION_EVENT_ONLOAD);
+ // WebContents can return an empty URL if the navigation entry
+ // corresponding to the navigation has not been created yet.
+ if (navigation_id.main_frame_url.is_empty())
+ RecordNavigationEvent(NAVIGATION_EVENT_ONLOAD_EMPTY_URL);
+ else
+ OnNavigationComplete(navigation_id);
+ break;
+ }
+ default:
+ NOTREACHED() << "Unexpected initialization_state_: "
+ << initialization_state_;
+ }
+}
+
void ResourcePrefetchPredictor::FinishedPrefetchForNavigation(
const NavigationID& navigation_id,
PrefetchKeyType key_type,
@@ -365,48 +384,6 @@ void ResourcePrefetchPredictor::Observe(
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
switch (type) {
- case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
- switch (initialization_state_) {
- case NOT_INITIALIZED:
- StartInitialization();
- break;
- case INITIALIZING:
- break;
- case INITIALIZED: {
- RecordNavigationEvent(NAVIGATION_EVENT_ONLOAD);
- const content::WebContents* web_contents =
- content::Source<content::WebContents>(source).ptr();
- NavigationID navigation_id(*web_contents);
- // WebContents can return an empty URL if the navigation entry
- // corresponding to the navigation has not been created yet.
- if (navigation_id.main_frame_url.is_empty())
- RecordNavigationEvent(NAVIGATION_EVENT_ONLOAD_EMPTY_URL);
- else
- OnNavigationComplete(navigation_id);
- break;
- }
- default:
- NOTREACHED() << "Unexpected initialization_state_: "
- << initialization_state_;
- }
- break;
- }
-
- case content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE: {
- const content::LoadFromMemoryCacheDetails* load_details =
- content::Details<content::LoadFromMemoryCacheDetails>(details).ptr();
- const content::WebContents* web_contents =
- content::Source<content::NavigationController>(
- source).ptr()->GetWebContents();
-
- NavigationID navigation_id(*web_contents);
- OnSubresourceLoadedFromMemory(navigation_id,
- load_details->url,
- load_details->mime_type,
- load_details->resource_type);
- break;
- }
-
case chrome::NOTIFICATION_HISTORY_LOADED: {
DCHECK_EQ(initialization_state_, INITIALIZING);
notification_registrar_.Remove(this,
@@ -520,23 +497,6 @@ void ResourcePrefetchPredictor::OnSubresourceResponse(
inflight_navigations_[response.navigation_id]->push_back(response);
}
-void ResourcePrefetchPredictor::OnSubresourceLoadedFromMemory(
- const NavigationID& navigation_id,
- const GURL& resource_url,
- const std::string& mime_type,
- ResourceType::Type resource_type) {
- if (inflight_navigations_.find(navigation_id) == inflight_navigations_.end())
- return;
-
- URLRequestSummary summary;
- summary.navigation_id = navigation_id;
- summary.resource_url = resource_url;
- summary.mime_type = mime_type;
- summary.resource_type = GetResourceTypeFromMimeType(mime_type, resource_type);
- summary.was_cached = true;
- inflight_navigations_[navigation_id]->push_back(summary);
-}
-
void ResourcePrefetchPredictor::OnNavigationComplete(
const NavigationID& navigation_id) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -733,9 +693,6 @@ void ResourcePrefetchPredictor::OnHistoryAndCacheLoaded() {
DCHECK_EQ(initialization_state_, INITIALIZING);
notification_registrar_.Add(this,
- content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE,
- content::NotificationService::AllSources());
- notification_registrar_.Add(this,
chrome::NOTIFICATION_HISTORY_URLS_DELETED,
content::Source<Profile>(profile_));
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.h b/chrome/browser/predictors/resource_prefetch_predictor.h
index ed177e4..5dbf2bc 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h
@@ -49,14 +49,14 @@ class ResourcePrefetcherManager;
// The overall flow of the resource prefetching algorithm is as follows:
//
// * ResourcePrefetchPredictorObserver - Listens for URL requests, responses and
-// redirects on the IO thread(via RDHostDelegate) and post tasks to the
-// ResourcePrefetchPredictor on the UI thread. This is owned by the
-// ProfileIOData for the profile.
+// redirects on the IO thread (via ResourceDispatcherHostDelegate) and posts
+// tasks to the ResourcePrefetchPredictor on the UI thread. This is owned by
+// the ProfileIOData for the profile.
// * ResourcePrefetchPredictorTables - Persists ResourcePrefetchPredictor data
// to a sql database. Runs entirely on the DB thread. Owned by the
// PredictorDatabase.
// * ResourcePrefetchPredictor - Learns about resource requirements per URL in
-// the UI thread through the ResourcePrefetchPredictorObserver and perisists
+// the UI thread through the ResourcePrefetchPredictorObserver and persists
// it to disk in the DB thread through the ResourcePrefetchPredictorTables. It
// initiates resource prefetching using the ResourcePrefetcherManager. Owned
// by profile.
@@ -110,8 +110,11 @@ class ResourcePrefetchPredictor
// predictor of main frame and resource requests. Should only be called if the
// corresponding Should* functions return true.
void RecordURLRequest(const URLRequestSummary& request);
- void RecordUrlResponse(const URLRequestSummary& response);
- void RecordUrlRedirect(const URLRequestSummary& response);
+ void RecordURLResponse(const URLRequestSummary& response);
+ void RecordURLRedirect(const URLRequestSummary& response);
+
+ // Called when the main frame of a page completes loading.
+ void RecordMainFrameLoadComplete(const NavigationID& navigation_id);
// Called by ResourcePrefetcherManager to notify that prefetching has finished
// for a navigation. Should take ownership of |requests|.
@@ -191,10 +194,6 @@ class ResourcePrefetchPredictor
void OnMainFrameResponse(const URLRequestSummary& response);
void OnMainFrameRedirect(const URLRequestSummary& response);
void OnSubresourceResponse(const URLRequestSummary& response);
- void OnSubresourceLoadedFromMemory(const NavigationID& navigation_id,
- const GURL& resource_url,
- const std::string& mime_type,
- ResourceType::Type resource_type);
// Called when onload completes for a navigation. We treat this point as the
// "completion" of the navigation. The resources requested by the page upto
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_factory.cc b/chrome/browser/predictors/resource_prefetch_predictor_factory.cc
index d8e78c7..4018d84 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_factory.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_factory.cc
@@ -15,9 +15,9 @@ namespace predictors {
// static
ResourcePrefetchPredictor* ResourcePrefetchPredictorFactory::GetForProfile(
- Profile* profile) {
+ content::BrowserContext* context) {
return static_cast<ResourcePrefetchPredictor*>(
- GetInstance()->GetServiceForBrowserContext(profile, true));
+ GetInstance()->GetServiceForBrowserContext(context, true));
}
// static
@@ -39,7 +39,7 @@ ResourcePrefetchPredictorFactory::~ResourcePrefetchPredictorFactory() {}
BrowserContextKeyedService*
ResourcePrefetchPredictorFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
- Profile* profile = static_cast<Profile*>(context);
+ Profile* profile = Profile::FromBrowserContext(context);
ResourcePrefetchPredictorConfig config;
if (!IsSpeculativeResourcePrefetchingEnabled(profile, &config))
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_factory.h b/chrome/browser/predictors/resource_prefetch_predictor_factory.h
index 802b544..8ec8012 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_factory.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor_factory.h
@@ -9,8 +9,6 @@
#include "base/memory/singleton.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
-class Profile;
-
namespace predictors {
class ResourcePrefetchPredictor;
@@ -18,7 +16,8 @@ class ResourcePrefetchPredictor;
class ResourcePrefetchPredictorFactory
: public BrowserContextKeyedServiceFactory {
public:
- static ResourcePrefetchPredictor* GetForProfile(Profile* profile);
+ static ResourcePrefetchPredictor* GetForProfile(
+ content::BrowserContext* context);
static ResourcePrefetchPredictorFactory* GetInstance();
private:
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tab_helper.cc b/chrome/browser/predictors/resource_prefetch_predictor_tab_helper.cc
new file mode 100644
index 0000000..b9cd748
--- /dev/null
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tab_helper.cc
@@ -0,0 +1,63 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h"
+
+#include "chrome/browser/predictors/resource_prefetch_predictor.h"
+#include "chrome/browser/predictors/resource_prefetch_predictor_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/load_from_memory_cache_details.h"
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(
+ predictors::ResourcePrefetchPredictorTabHelper);
+
+using content::BrowserThread;
+
+namespace predictors {
+
+ResourcePrefetchPredictorTabHelper::ResourcePrefetchPredictorTabHelper(
+ content::WebContents* web_contents)
+ : content::WebContentsObserver(web_contents) {
+}
+
+ResourcePrefetchPredictorTabHelper::~ResourcePrefetchPredictorTabHelper() {
+}
+
+void ResourcePrefetchPredictorTabHelper::DocumentOnLoadCompletedInMainFrame(
+ int32 page_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ ResourcePrefetchPredictor* predictor =
+ ResourcePrefetchPredictorFactory::GetForProfile(
+ web_contents()->GetBrowserContext());
+ if (!predictor)
+ return;
+
+ NavigationID navigation_id(web_contents());
+ predictor->RecordMainFrameLoadComplete(navigation_id);
+}
+
+void ResourcePrefetchPredictorTabHelper::DidLoadResourceFromMemoryCache(
+ const content::LoadFromMemoryCacheDetails& details) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ ResourcePrefetchPredictor* predictor =
+ ResourcePrefetchPredictorFactory::GetForProfile(
+ web_contents()->GetBrowserContext());
+ if (!predictor)
+ return;
+
+ ResourcePrefetchPredictor::URLRequestSummary summary;
+ summary.navigation_id = NavigationID(web_contents());
+ summary.resource_url = details.url;
+ summary.mime_type = details.mime_type;
+ summary.resource_type =
+ ResourcePrefetchPredictor::GetResourceTypeFromMimeType(
+ details.mime_type, details.resource_type);
+ summary.was_cached = true;
+ predictor->RecordURLResponse(summary);
+}
+
+} // namespace predictors
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h b/chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h
new file mode 100644
index 0000000..56a439b
--- /dev/null
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h
@@ -0,0 +1,34 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TAB_HELPER_H_
+#define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TAB_HELPER_H_
+
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace predictors {
+
+class ResourcePrefetchPredictorTabHelper
+ : public content::WebContentsObserver,
+ public content::WebContentsUserData<ResourcePrefetchPredictorTabHelper> {
+ public:
+ virtual ~ResourcePrefetchPredictorTabHelper();
+
+ // content::WebContentsObserver implementation
+ virtual void DocumentOnLoadCompletedInMainFrame(int32 page_id) OVERRIDE;
+ virtual void DidLoadResourceFromMemoryCache(
+ const content::LoadFromMemoryCacheDetails& details) OVERRIDE;
+
+ private:
+ explicit ResourcePrefetchPredictorTabHelper(
+ content::WebContents* web_contents);
+ friend class content::WebContentsUserData<ResourcePrefetchPredictorTabHelper>;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTabHelper);
+};
+
+} // namespace predictors
+
+#endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TAB_HELPER_H_
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
index b0d7fe3..dec81ee 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
@@ -390,15 +390,15 @@ TEST_F(ResourcePrefetchPredictorTest, NavigationNotRecorded) {
URLRequestSummary resource1 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/style1.css",
ResourceType::STYLESHEET, "text/css", false);
- predictor_->RecordUrlResponse(resource1);
+ predictor_->RecordURLResponse(resource1);
URLRequestSummary resource2 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script1.js",
ResourceType::SCRIPT, "text/javascript", false);
- predictor_->RecordUrlResponse(resource2);
+ predictor_->RecordURLResponse(resource2);
URLRequestSummary resource3 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script2.js",
ResourceType::SCRIPT, "text/javascript", false);
- predictor_->RecordUrlResponse(resource3);
+ predictor_->RecordURLResponse(resource3);
PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com");
host_data.resources.push_back(ResourceRow(std::string(),
@@ -447,35 +447,31 @@ TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDB) {
URLRequestSummary resource1 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/style1.css",
ResourceType::STYLESHEET, "text/css", false);
- predictor_->RecordUrlResponse(resource1);
+ predictor_->RecordURLResponse(resource1);
URLRequestSummary resource2 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script1.js",
ResourceType::SCRIPT, "text/javascript", false);
- predictor_->RecordUrlResponse(resource2);
+ predictor_->RecordURLResponse(resource2);
URLRequestSummary resource3 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script2.js",
ResourceType::SCRIPT, "text/javascript", false);
- predictor_->RecordUrlResponse(resource3);
+ predictor_->RecordURLResponse(resource3);
URLRequestSummary resource4 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script1.js",
ResourceType::SCRIPT, "text/javascript", true);
- predictor_->RecordUrlResponse(resource4);
+ predictor_->RecordURLResponse(resource4);
URLRequestSummary resource5 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/image1.png",
ResourceType::IMAGE, "image/png", false);
- predictor_->RecordUrlResponse(resource5);
+ predictor_->RecordURLResponse(resource5);
URLRequestSummary resource6 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/image2.png",
ResourceType::IMAGE, "image/png", false);
- predictor_->RecordUrlResponse(resource6);
+ predictor_->RecordURLResponse(resource6);
URLRequestSummary resource7 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/style2.css",
- ResourceType::STYLESHEET, "text/css", false);
- predictor_->OnSubresourceLoadedFromMemory(
- resource7.navigation_id,
- resource7.resource_url,
- resource7.mime_type,
- resource7.resource_type);
+ ResourceType::STYLESHEET, "text/css", true);
+ predictor_->RecordURLResponse(resource7);
PrefetchData url_data(PREFETCH_KEY_TYPE_URL, "http://www.google.com/");
url_data.resources.push_back(ResourceRow(std::string(),
@@ -545,35 +541,31 @@ TEST_F(ResourcePrefetchPredictorTest, NavigationUrlInDB) {
URLRequestSummary resource1 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/style1.css",
ResourceType::STYLESHEET, "text/css", false);
- predictor_->RecordUrlResponse(resource1);
+ predictor_->RecordURLResponse(resource1);
URLRequestSummary resource2 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script1.js",
ResourceType::SCRIPT, "text/javascript", false);
- predictor_->RecordUrlResponse(resource2);
+ predictor_->RecordURLResponse(resource2);
URLRequestSummary resource3 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script2.js",
ResourceType::SCRIPT, "text/javascript", false);
- predictor_->RecordUrlResponse(resource3);
+ predictor_->RecordURLResponse(resource3);
URLRequestSummary resource4 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/script1.js",
ResourceType::SCRIPT, "text/javascript", true);
- predictor_->RecordUrlResponse(resource4);
+ predictor_->RecordURLResponse(resource4);
URLRequestSummary resource5 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/image1.png",
ResourceType::IMAGE, "image/png", false);
- predictor_->RecordUrlResponse(resource5);
+ predictor_->RecordURLResponse(resource5);
URLRequestSummary resource6 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/image2.png",
ResourceType::IMAGE, "image/png", false);
- predictor_->RecordUrlResponse(resource6);
+ predictor_->RecordURLResponse(resource6);
URLRequestSummary resource7 = CreateURLRequestSummary(
1, 1, "http://www.google.com", "http://google.com/style2.css",
- ResourceType::STYLESHEET, "text/css", false);
- predictor_->OnSubresourceLoadedFromMemory(
- resource7.navigation_id,
- resource7.resource_url,
- resource7.mime_type,
- resource7.resource_type);
+ ResourceType::STYLESHEET, "text/css", true);
+ predictor_->RecordURLResponse(resource7);
PrefetchData url_data(PREFETCH_KEY_TYPE_URL, "http://www.google.com/");
url_data.resources.push_back(ResourceRow(std::string(),
@@ -673,11 +665,11 @@ TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDBAndDBFull) {
URLRequestSummary resource1 = CreateURLRequestSummary(
1, 1, "http://www.nike.com", "http://nike.com/style1.css",
ResourceType::STYLESHEET, "text/css", false);
- predictor_->RecordUrlResponse(resource1);
+ predictor_->RecordURLResponse(resource1);
URLRequestSummary resource2 = CreateURLRequestSummary(
1, 1, "http://www.nike.com", "http://nike.com/image2.png",
ResourceType::IMAGE, "image/png", false);
- predictor_->RecordUrlResponse(resource2);
+ predictor_->RecordURLResponse(resource2);
EXPECT_CALL(
*mock_tables_.get(),