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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_tables.h

Issue 10416002: Seculative resource prefetching for URLs CL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressing Will's comments and adding a unittest. Created 8 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
7 #pragma once
8
9 #include "chrome/browser/predictors/predictor_table_base.h"
10
11 #include <string>
12 #include <vector>
13
14 #include "googleurl/src/gurl.h"
15 #include "webkit/glue/resource_type.h"
16
17 namespace predictors {
18
19 // Interface for database tables used by the ResourcePrefetchPredictor.
20 // All methods except the constructor and destructor need to be called on the DB
21 // thread.
22 // NOTE: This class is named in plural as it will hold other tables shortly.
23 //
24 // TODO(shishir): Move to composition model instead of implemented inheritance.
25 class ResourcePrefetchPredictorTables : public PredictorTableBase {
26 public:
27 struct UrlTableRow {
28 UrlTableRow();
29 UrlTableRow(const UrlTableRow& other);
30 void UpdateScore();
31
32 GURL main_frame_url;
33 GURL resource_url;
34 ResourceType::Type resource_type;
35 int number_of_hits;
36 int number_of_misses;
37 int consecutive_misses;
38 double average_position;
39
40 // Not stored.
41 float score;
42 };
43 typedef std::vector<UrlTableRow> UrlTableRows;
44
45 // Sorts the UrlTableRows by score, descending.
46 struct UrlTableRowSorter {
47 bool operator()(const UrlTableRow& x, const UrlTableRow& y) const;
48 };
49
50 // |url_row_buffer| should be empty for GetAllRows.
51 void GetAllRows(UrlTableRows* url_row_buffer);
52 void UpdateRowsForUrl(const GURL& main_page_url,
53 const UrlTableRows& row_buffer);
54 void DeleteRowsForUrls(const std::vector<GURL>& urls);
55 void DeleteAllRows();
56
57 private:
58 friend class PredictorDatabaseInternal;
59
60 ResourcePrefetchPredictorTables();
61 virtual ~ResourcePrefetchPredictorTables();
62
63 // PredictorTableBase methods.
64 virtual void CreateTableIfNonExistent() OVERRIDE;
65 virtual void LogDatabaseStats() OVERRIDE;
66
67 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables);
68 };
69
70 } // namespace predictors
71
72 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698