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..495d193dd09c5313bfb6be6827d3834d2200439e |
--- /dev/null |
+++ b/chrome/browser/predictors/resource_prefetch_predictor_tables.h |
@@ -0,0 +1,66 @@ |
+// 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 <string> |
+#include <vector> |
+ |
+#include "chrome/browser/predictors/predictor_table_base.h" |
dominich
2012/05/21 16:16:53
This include should be first as it provides the ba
Shishir
2012/05/23 01:46:46
Done.
|
+#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 { |
+ public: |
+ struct UrlTableRow { |
+ UrlTableRow(); |
+ UrlTableRow(const UrlTableRow& other); |
dominich
2012/05/21 16:16:53
check if you can mark this explicit - STL may not
Shishir
2012/05/23 01:46:46
Doesnt work with STL.
|
+ 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_; |
dominich
2012/05/21 16:16:53
Can this be a float?
Shishir
2012/05/23 01:46:46
Since sql/statement doesnt expose float , keeping
|
+ |
+ // Not stored. |
+ double score_; |
dominich
2012/05/21 16:16:53
Can this be a float?
Shishir
2012/05/23 01:46:46
Done.
|
+ }; |
+ |
+ // Sorts the UrlTableRows by score. |
dominich
2012/05/21 16:16:53
ascending or descending?
Shishir
2012/05/23 01:46:46
Done.
|
+ 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_ |