| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <limits> | 6 #include <limits> |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "chrome/browser/history/visit_database.h" | 10 #include "chrome/browser/history/visit_database.h" |
| 11 | 11 |
| 12 #include "chrome/browser/history/url_database.h" | 12 #include "chrome/browser/history/url_database.h" |
| 13 #include "chrome/common/page_transition_types.h" | 13 #include "chrome/common/page_transition_types.h" |
| 14 #include "chrome/common/url_constants.h" |
| 14 | 15 |
| 15 using base::Time; | 16 using base::Time; |
| 16 | 17 |
| 17 // Rows, in order, of the visit table. | 18 // Rows, in order, of the visit table. |
| 18 #define HISTORY_VISIT_ROW_FIELDS \ | 19 #define HISTORY_VISIT_ROW_FIELDS \ |
| 19 " id,url,visit_time,from_visit,transition,segment_id,is_indexed " | 20 " id,url,visit_time,from_visit,transition,segment_id,is_indexed " |
| 20 | 21 |
| 21 namespace history { | 22 namespace history { |
| 22 | 23 |
| 23 VisitDatabase::VisitDatabase() { | 24 VisitDatabase::VisitDatabase() { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (to_visit) | 320 if (to_visit) |
| 320 *to_visit = statement->column_int64(0); | 321 *to_visit = statement->column_int64(0); |
| 321 if (to_url) | 322 if (to_url) |
| 322 *to_url = GURL(statement->column_string(1)); | 323 *to_url = GURL(statement->column_string(1)); |
| 323 return true; | 324 return true; |
| 324 } | 325 } |
| 325 | 326 |
| 326 bool VisitDatabase::GetVisitCountToHost(const GURL& url, | 327 bool VisitDatabase::GetVisitCountToHost(const GURL& url, |
| 327 int* count, | 328 int* count, |
| 328 Time* first_visit) { | 329 Time* first_visit) { |
| 329 if (!url.SchemeIs("http") && !url.SchemeIs("https")) | 330 if (!url.SchemeIs(chrome::kHttpScheme) && !url.SchemeIs(chrome::kHttpsScheme)) |
| 330 return false; | 331 return false; |
| 331 | 332 |
| 332 // We need to search for URLs with a matching host/port. One way to query for | 333 // We need to search for URLs with a matching host/port. One way to query for |
| 333 // this is to use the LIKE operator, eg 'url LIKE http://google.com/%'. This | 334 // this is to use the LIKE operator, eg 'url LIKE http://google.com/%'. This |
| 334 // is inefficient though in that it doesn't use the index and each entry must | 335 // is inefficient though in that it doesn't use the index and each entry must |
| 335 // be visited. The same query can be executed by using >= and < operator. | 336 // be visited. The same query can be executed by using >= and < operator. |
| 336 // The query becomes: | 337 // The query becomes: |
| 337 // 'url >= http://google.com/' and url < http://google.com0'. | 338 // 'url >= http://google.com/' and url < http://google.com0'. |
| 338 // 0 is used as it is one character greater than '/'. | 339 // 0 is used as it is one character greater than '/'. |
| 339 GURL search_url(url); | 340 GURL search_url(url); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 360 *count = 0; | 361 *count = 0; |
| 361 return true; | 362 return true; |
| 362 } | 363 } |
| 363 | 364 |
| 364 *first_visit = Time::FromInternalValue(statement->column_int64(0)); | 365 *first_visit = Time::FromInternalValue(statement->column_int64(0)); |
| 365 *count = statement->column_int(1); | 366 *count = statement->column_int(1); |
| 366 return true; | 367 return true; |
| 367 } | 368 } |
| 368 | 369 |
| 369 } // namespace history | 370 } // namespace history |
| OLD | NEW |