| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/in_memory_database.h" | 5 #include "chrome/browser/history/in_memory_database.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/history/history_field_trial.h" | |
| 14 | 13 |
| 15 namespace history { | 14 namespace history { |
| 16 | 15 |
| 17 InMemoryDatabase::InMemoryDatabase() : URLDatabase() { | 16 InMemoryDatabase::InMemoryDatabase() : URLDatabase() { |
| 18 } | 17 } |
| 19 | 18 |
| 20 InMemoryDatabase::~InMemoryDatabase() { | 19 InMemoryDatabase::~InMemoryDatabase() { |
| 21 } | 20 } |
| 22 | 21 |
| 23 bool InMemoryDatabase::InitDB() { | 22 bool InMemoryDatabase::InitDB() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 84 } |
| 86 | 85 |
| 87 // Copy URL data to memory. | 86 // Copy URL data to memory. |
| 88 base::TimeTicks begin_load = base::TimeTicks::Now(); | 87 base::TimeTicks begin_load = base::TimeTicks::Now(); |
| 89 if (!db_.Execute( | 88 if (!db_.Execute( |
| 90 "INSERT INTO urls SELECT * FROM history.urls WHERE typed_count > 0")) { | 89 "INSERT INTO urls SELECT * FROM history.urls WHERE typed_count > 0")) { |
| 91 // Unable to get data from the history database. This is OK, the file may | 90 // Unable to get data from the history database. This is OK, the file may |
| 92 // just not exist yet. | 91 // just not exist yet. |
| 93 } | 92 } |
| 94 base::TimeTicks end_load = base::TimeTicks::Now(); | 93 base::TimeTicks end_load = base::TimeTicks::Now(); |
| 95 UMA_HISTOGRAM_MEDIUM_TIMES( | 94 UMA_HISTOGRAM_MEDIUM_TIMES("History.InMemoryDBPopulate", |
| 96 "History.InMemoryDBPopulate" + HistoryFieldTrial::GetGroupSuffix(), | 95 end_load - begin_load); |
| 97 end_load - begin_load); | |
| 98 UMA_HISTOGRAM_COUNTS("History.InMemoryDBItemCount", db_.GetLastChangeCount()); | 96 UMA_HISTOGRAM_COUNTS("History.InMemoryDBItemCount", db_.GetLastChangeCount()); |
| 99 | 97 |
| 100 { | 98 { |
| 101 // This calculation should be fast (since it's on an in-memory DB with | 99 // This calculation should be fast (since it's on an in-memory DB with |
| 102 // an average of only 35 rows). | 100 // an average of only 35 rows). |
| 103 sql::Statement visit_count(db_.GetUniqueStatement( | 101 sql::Statement visit_count(db_.GetUniqueStatement( |
| 104 "SELECT sum(visit_count) FROM urls")); | 102 "SELECT sum(visit_count) FROM urls")); |
| 105 if (visit_count && visit_count.Step()) { | 103 if (visit_count && visit_count.Step()) { |
| 106 UMA_HISTOGRAM_COUNTS("History.InMemoryTypedUrlVisitCount", | 104 UMA_HISTOGRAM_COUNTS("History.InMemoryTypedUrlVisitCount", |
| 107 visit_count.ColumnInt(0)); | 105 visit_count.ColumnInt(0)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 CreateKeywordSearchTermsIndices(); | 148 CreateKeywordSearchTermsIndices(); |
| 151 | 149 |
| 152 return true; | 150 return true; |
| 153 } | 151 } |
| 154 | 152 |
| 155 sql::Connection& InMemoryDatabase::GetDB() { | 153 sql::Connection& InMemoryDatabase::GetDB() { |
| 156 return db_; | 154 return db_; |
| 157 } | 155 } |
| 158 | 156 |
| 159 } // namespace history | 157 } // namespace history |
| OLD | NEW |