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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_tab_helper.cc

Issue 117933003: Remove the speculative resource prefetching code. This was experimental code added 1.5 years ago an… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 6 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h"
6
7 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
8 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/load_from_memory_cache_details.h"
12
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
14 predictors::ResourcePrefetchPredictorTabHelper);
15
16 using content::BrowserThread;
17
18 namespace predictors {
19
20 ResourcePrefetchPredictorTabHelper::ResourcePrefetchPredictorTabHelper(
21 content::WebContents* web_contents)
22 : content::WebContentsObserver(web_contents) {
23 }
24
25 ResourcePrefetchPredictorTabHelper::~ResourcePrefetchPredictorTabHelper() {
26 }
27
28 void ResourcePrefetchPredictorTabHelper::DocumentOnLoadCompletedInMainFrame(
29 int32 page_id) {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
31
32 ResourcePrefetchPredictor* predictor =
33 ResourcePrefetchPredictorFactory::GetForProfile(
34 web_contents()->GetBrowserContext());
35 if (!predictor)
36 return;
37
38 NavigationID navigation_id(web_contents());
39 predictor->RecordMainFrameLoadComplete(navigation_id);
40 }
41
42 void ResourcePrefetchPredictorTabHelper::DidLoadResourceFromMemoryCache(
43 const content::LoadFromMemoryCacheDetails& details) {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45
46 ResourcePrefetchPredictor* predictor =
47 ResourcePrefetchPredictorFactory::GetForProfile(
48 web_contents()->GetBrowserContext());
49 if (!predictor)
50 return;
51
52 ResourcePrefetchPredictor::URLRequestSummary summary;
53 summary.navigation_id = NavigationID(web_contents());
54 summary.resource_url = details.url;
55 summary.mime_type = details.mime_type;
56 summary.resource_type =
57 ResourcePrefetchPredictor::GetResourceTypeFromMimeType(
58 details.mime_type, details.resource_type);
59 summary.was_cached = true;
60 predictor->RecordURLResponse(summary);
61 }
62
63 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698