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..1798c11480343856381b16527107ecadb10cd864 |
--- /dev/null |
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
@@ -0,0 +1,67 @@ |
+// 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. |
+class ResourcePrefetchPredictorTables : public PredictorTableBase { |
willchan no longer on Chromium
2012/05/24 22:28:52
Why is PredictorTableBase inherited? The Google st
Shishir
2012/05/30 01:07:51
I added a todo for this. I would like to do that i
|
+ 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_ |