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

Unified 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: Moving to WeakPtrs and RVHD. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_predictor_tables.h
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_tables.h b/chrome/browser/predictors/resource_prefetch_predictor_tables.h
new file mode 100644
index 0000000000000000000000000000000000000000..5bd8bd50b206f1415a3965eda5574c401d519b71
--- /dev/null
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 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_TABLES_H_
+#define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
+#pragma once
+
+#include "chrome/browser/predictors/predictor_table_base.h"
+
+#include <string>
+#include <vector>
+
+#include "googleurl/src/gurl.h"
+#include "webkit/glue/resource_type.h"
+
+namespace predictors {
+
+// Interface for database tables used by the ResourcePrefetchPredictor.
+// All methods except the constructor and destructor need to be called on the DB
+// thread.
+// NOTE: This class is named in plural as it will hold other tables shortly.
+//
+// TODO(shishir): Move to composition model instead of implemented inheritance.
+class ResourcePrefetchPredictorTables : public PredictorTableBase {
+ public:
+ struct UrlTableRow {
+ UrlTableRow();
+ UrlTableRow(const UrlTableRow& other);
+ void UpdateScore();
+
+ GURL main_frame_url_;
+ GURL resource_url_;
+ ResourceType::Type resource_type_;
+ int number_of_hits_;
+ int number_of_misses_;
+ int consecutive_misses_;
+ double average_position_;
+
+ // Not stored.
+ float score_;
+ };
+
+ // Sorts the UrlTableRows by score, descending.
+ struct UrlTableRowSorter {
+ bool operator()(const UrlTableRow& x, const UrlTableRow& y) const;
+ };
+
+ void GetAllRows(std::vector<UrlTableRow>* url_row_buffer);
+ void UpdateRowsForUrl(const GURL& main_page_url,
+ const std::vector<UrlTableRow>& row_buffer);
+ void DeleteUrlRows(const std::vector<GURL>& urls);
+
+ private:
+ friend class PredictorDatabaseInternal;
+
+ ResourcePrefetchPredictorTables();
+ virtual ~ResourcePrefetchPredictorTables();
+
+ // PredictorTableBase methods.
+ virtual void CreateTableIfNonExistent() OVERRIDE;
+ virtual void LogDatabaseStats() OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables);
+};
+
+} // namespace predictors
+
+#endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_

Powered by Google App Engine
This is Rietveld 408576698