OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | 5 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 #include <utility> | 10 #include <utility> |
9 | 11 |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
14 #include "sql/statement.h" | 16 #include "sql/statement.h" |
15 | 17 |
16 using content::BrowserThread; | 18 using content::BrowserThread; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 const char* metadata_table_name = is_host ? kHostMetadataTableName : | 291 const char* metadata_table_name = is_host ? kHostMetadataTableName : |
290 kUrlMetadataTableName; | 292 kUrlMetadataTableName; |
291 Statement metadata_reader(DB()->GetUniqueStatement( | 293 Statement metadata_reader(DB()->GetUniqueStatement( |
292 base::StringPrintf("SELECT * FROM %s", metadata_table_name).c_str())); | 294 base::StringPrintf("SELECT * FROM %s", metadata_table_name).c_str())); |
293 | 295 |
294 while (metadata_reader.Step()) { | 296 while (metadata_reader.Step()) { |
295 std::string primary_key = metadata_reader.ColumnString(0); | 297 std::string primary_key = metadata_reader.ColumnString(0); |
296 | 298 |
297 PrefetchDataMap::iterator it = data_map->find(primary_key); | 299 PrefetchDataMap::iterator it = data_map->find(primary_key); |
298 if (it != data_map->end()) { | 300 if (it != data_map->end()) { |
299 int64 last_visit = metadata_reader.ColumnInt64(1); | 301 int64_t last_visit = metadata_reader.ColumnInt64(1); |
300 it->second.last_visit = base::Time::FromInternalValue(last_visit); | 302 it->second.last_visit = base::Time::FromInternalValue(last_visit); |
301 } else { | 303 } else { |
302 to_delete->push_back(primary_key); | 304 to_delete->push_back(primary_key); |
303 } | 305 } |
304 } | 306 } |
305 } | 307 } |
306 | 308 |
307 bool ResourcePrefetchPredictorTables::UpdateDataHelper( | 309 bool ResourcePrefetchPredictorTables::UpdateDataHelper( |
308 const PrefetchData& data) { | 310 const PrefetchData& data) { |
309 DCHECK(!data.primary_key.empty()); | 311 DCHECK(!data.primary_key.empty()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 506 |
505 Statement* ResourcePrefetchPredictorTables::GetHostMetadataUpdateStatement() { | 507 Statement* ResourcePrefetchPredictorTables::GetHostMetadataUpdateStatement() { |
506 return new Statement(DB()->GetCachedStatement( | 508 return new Statement(DB()->GetCachedStatement( |
507 SQL_FROM_HERE, | 509 SQL_FROM_HERE, |
508 base::StringPrintf( | 510 base::StringPrintf( |
509 "INSERT INTO %s (main_page_url, last_visit_time) VALUES (?,?)", | 511 "INSERT INTO %s (main_page_url, last_visit_time) VALUES (?,?)", |
510 kHostMetadataTableName).c_str())); | 512 kHostMetadataTableName).c_str())); |
511 } | 513 } |
512 | 514 |
513 } // namespace predictors | 515 } // namespace predictors |
OLD | NEW |