| 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 "components/history/core/browser/visitsegment_database.h" | 5 #include "components/history/core/browser/visitsegment_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 base::Time ts = from_time.LocalMidnight(); | 222 base::Time ts = from_time.LocalMidnight(); |
| 223 statement.BindInt64(0, ts.ToInternalValue()); | 223 statement.BindInt64(0, ts.ToInternalValue()); |
| 224 | 224 |
| 225 std::vector<std::unique_ptr<PageUsageData>> segments; | 225 std::vector<std::unique_ptr<PageUsageData>> segments; |
| 226 base::Time now = base::Time::Now(); | 226 base::Time now = base::Time::Now(); |
| 227 SegmentID previous_segment_id = 0; | 227 SegmentID previous_segment_id = 0; |
| 228 while (statement.Step()) { | 228 while (statement.Step()) { |
| 229 SegmentID segment_id = statement.ColumnInt64(0); | 229 SegmentID segment_id = statement.ColumnInt64(0); |
| 230 if (segment_id != previous_segment_id) { | 230 if (segment_id != previous_segment_id) { |
| 231 segments.push_back(base::WrapUnique(new PageUsageData(segment_id))); | 231 segments.push_back(base::MakeUnique<PageUsageData>(segment_id)); |
| 232 previous_segment_id = segment_id; | 232 previous_segment_id = segment_id; |
| 233 } | 233 } |
| 234 | 234 |
| 235 base::Time timeslot = | 235 base::Time timeslot = |
| 236 base::Time::FromInternalValue(statement.ColumnInt64(1)); | 236 base::Time::FromInternalValue(statement.ColumnInt64(1)); |
| 237 int visit_count = statement.ColumnInt(2); | 237 int visit_count = statement.ColumnInt(2); |
| 238 int days_ago = (now - timeslot).InDays(); | 238 int days_ago = (now - timeslot).InDays(); |
| 239 | 239 |
| 240 // Score for this day in isolation. | 240 // Score for this day in isolation. |
| 241 float day_visits_score = 1.0f + log(static_cast<float>(visit_count)); | 241 float day_visits_score = 1.0f + log(static_cast<float>(visit_count)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 "name VARCHAR," | 318 "name VARCHAR," |
| 319 "url_id INTEGER NON NULL)") && | 319 "url_id INTEGER NON NULL)") && |
| 320 GetDB().Execute("INSERT INTO segments_tmp SELECT " | 320 GetDB().Execute("INSERT INTO segments_tmp SELECT " |
| 321 "id, name, url_id FROM segments") && | 321 "id, name, url_id FROM segments") && |
| 322 GetDB().Execute("DROP TABLE segments") && | 322 GetDB().Execute("DROP TABLE segments") && |
| 323 GetDB().Execute("ALTER TABLE segments_tmp RENAME TO segments") && | 323 GetDB().Execute("ALTER TABLE segments_tmp RENAME TO segments") && |
| 324 transaction.Commit(); | 324 transaction.Commit(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace history | 327 } // namespace history |
| OLD | NEW |