| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/visit_database.h" | 5 #include "chrome/browser/history/visit_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 "(url, visit_time, from_visit, transition, segment_id, " | 147 "(url, visit_time, from_visit, transition, segment_id, " |
| 148 "visit_duration) VALUES (?,?,?,?,?,?)")); | 148 "visit_duration) VALUES (?,?,?,?,?,?)")); |
| 149 statement.BindInt64(0, visit->url_id); | 149 statement.BindInt64(0, visit->url_id); |
| 150 statement.BindInt64(1, visit->visit_time.ToInternalValue()); | 150 statement.BindInt64(1, visit->visit_time.ToInternalValue()); |
| 151 statement.BindInt64(2, visit->referring_visit); | 151 statement.BindInt64(2, visit->referring_visit); |
| 152 statement.BindInt64(3, visit->transition); | 152 statement.BindInt64(3, visit->transition); |
| 153 statement.BindInt64(4, visit->segment_id); | 153 statement.BindInt64(4, visit->segment_id); |
| 154 statement.BindInt64(5, visit->visit_duration.ToInternalValue()); | 154 statement.BindInt64(5, visit->visit_duration.ToInternalValue()); |
| 155 | 155 |
| 156 if (!statement.Run()) { | 156 if (!statement.Run()) { |
| 157 VLOG(0) << "Failed to execute visit insert statement: " | 157 DVLOG(0) << "Failed to execute visit insert statement: " |
| 158 << "url_id = " << visit->url_id; | 158 << "url_id = " << visit->url_id; |
| 159 return 0; | 159 return 0; |
| 160 } | 160 } |
| 161 | 161 |
| 162 visit->visit_id = GetDB().GetLastInsertRowId(); | 162 visit->visit_id = GetDB().GetLastInsertRowId(); |
| 163 | 163 |
| 164 if (source != SOURCE_BROWSED) { | 164 if (source != SOURCE_BROWSED) { |
| 165 // Record the source of this visit when it is not browsed. | 165 // Record the source of this visit when it is not browsed. |
| 166 sql::Statement statement1(GetDB().GetCachedStatement(SQL_FROM_HERE, | 166 sql::Statement statement1(GetDB().GetCachedStatement(SQL_FROM_HERE, |
| 167 "INSERT INTO visit_source (id, source) VALUES (?,?)")); | 167 "INSERT INTO visit_source (id, source) VALUES (?,?)")); |
| 168 statement1.BindInt64(0, visit->visit_id); | 168 statement1.BindInt64(0, visit->visit_id); |
| 169 statement1.BindInt64(1, source); | 169 statement1.BindInt64(1, source); |
| 170 | 170 |
| 171 if (!statement1.Run()) { | 171 if (!statement1.Run()) { |
| 172 VLOG(0) << "Failed to execute visit_source insert statement: " | 172 DVLOG(0) << "Failed to execute visit_source insert statement: " |
| 173 << "id = " << visit->visit_id; | 173 << "id = " << visit->visit_id; |
| 174 return 0; | 174 return 0; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 return visit->visit_id; | 178 return visit->visit_id; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void VisitDatabase::DeleteVisit(const VisitRow& visit) { | 181 void VisitDatabase::DeleteVisit(const VisitRow& visit) { |
| 182 // Patch around this visit. Any visits that this went to will now have their | 182 // Patch around this visit. Any visits that this went to will now have their |
| 183 // "source" be the deleted visit's source. | 183 // "source" be the deleted visit's source. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 while (statement.Step()) { | 616 while (statement.Step()) { |
| 617 BriefVisitInfo info; | 617 BriefVisitInfo info; |
| 618 info.url_id = statement.ColumnInt64(0); | 618 info.url_id = statement.ColumnInt64(0); |
| 619 info.time = base::Time::FromInternalValue(statement.ColumnInt64(1)); | 619 info.time = base::Time::FromInternalValue(statement.ColumnInt64(1)); |
| 620 info.transition = ui::PageTransitionFromInt(statement.ColumnInt(2)); | 620 info.transition = ui::PageTransitionFromInt(statement.ColumnInt(2)); |
| 621 result_vector->push_back(info); | 621 result_vector->push_back(info); |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 | 624 |
| 625 } // namespace history | 625 } // namespace history |
| OLD | NEW |