| 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/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "chrome/browser/autocomplete/history_url_provider.h" | 20 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_service.h" | 21 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 22 #include "chrome/browser/history/history_field_trial.h" | |
| 23 #include "chrome/browser/history/history_notifications.h" | 22 #include "chrome/browser/history/history_notifications.h" |
| 24 #include "chrome/browser/history/history_publisher.h" | 23 #include "chrome/browser/history/history_publisher.h" |
| 25 #include "chrome/browser/history/in_memory_history_backend.h" | 24 #include "chrome/browser/history/in_memory_history_backend.h" |
| 26 #include "chrome/browser/history/page_usage_data.h" | 25 #include "chrome/browser/history/page_usage_data.h" |
| 27 #include "chrome/browser/history/top_sites.h" | 26 #include "chrome/browser/history/top_sites.h" |
| 28 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 31 #include "content/browser/cancelable_request.h" | 30 #include "content/browser/cancelable_request.h" |
| 32 #include "content/browser/download/download_persistent_store_info.h" | 31 #include "content/browser/download/download_persistent_store_info.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 NOTREACHED(); | 366 NOTREACHED(); |
| 368 return 0; | 367 return 0; |
| 369 } | 368 } |
| 370 return segment_id; | 369 return segment_id; |
| 371 } | 370 } |
| 372 | 371 |
| 373 void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) { | 372 void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) { |
| 374 if (!db_.get()) | 373 if (!db_.get()) |
| 375 return; | 374 return; |
| 376 | 375 |
| 377 TimeTicks beginning_time = TimeTicks::Now(); | |
| 378 | |
| 379 // Will be filled with the URL ID and the visit ID of the last addition. | 376 // Will be filled with the URL ID and the visit ID of the last addition. |
| 380 std::pair<URLID, VisitID> last_ids(0, tracker_.GetLastVisit( | 377 std::pair<URLID, VisitID> last_ids(0, tracker_.GetLastVisit( |
| 381 request->id_scope, request->page_id, request->referrer)); | 378 request->id_scope, request->page_id, request->referrer)); |
| 382 | 379 |
| 383 VisitID from_visit_id = last_ids.second; | 380 VisitID from_visit_id = last_ids.second; |
| 384 | 381 |
| 385 // If a redirect chain is given, we expect the last item in that chain to be | 382 // If a redirect chain is given, we expect the last item in that chain to be |
| 386 // the final URL. | 383 // the final URL. |
| 387 DCHECK(request->redirects.empty() || | 384 DCHECK(request->redirects.empty() || |
| 388 request->redirects.back() == request->url); | 385 request->redirects.back() == request->url); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 tracker_.AddVisit(request->id_scope, request->page_id, request->url, | 537 tracker_.AddVisit(request->id_scope, request->page_id, request->url, |
| 541 last_ids.second); | 538 last_ids.second); |
| 542 } | 539 } |
| 543 | 540 |
| 544 if (text_database_.get()) { | 541 if (text_database_.get()) { |
| 545 text_database_->AddPageURL(request->url, last_ids.first, last_ids.second, | 542 text_database_->AddPageURL(request->url, last_ids.first, last_ids.second, |
| 546 last_recorded_time_); | 543 last_recorded_time_); |
| 547 } | 544 } |
| 548 | 545 |
| 549 ScheduleCommit(); | 546 ScheduleCommit(); |
| 550 | |
| 551 UMA_HISTOGRAM_TIMES( | |
| 552 "History.AddPage" + HistoryFieldTrial::GetGroupSuffix(), | |
| 553 TimeTicks::Now() - beginning_time); | |
| 554 } | 547 } |
| 555 | 548 |
| 556 void HistoryBackend::InitImpl(const std::string& languages) { | 549 void HistoryBackend::InitImpl(const std::string& languages) { |
| 557 DCHECK(!db_.get()) << "Initializing HistoryBackend twice"; | 550 DCHECK(!db_.get()) << "Initializing HistoryBackend twice"; |
| 558 // In the rare case where the db fails to initialize a dialog may get shown | 551 // In the rare case where the db fails to initialize a dialog may get shown |
| 559 // the blocks the caller, yet allows other messages through. For this reason | 552 // the blocks the caller, yet allows other messages through. For this reason |
| 560 // we only set db_ to the created database if creation is successful. That | 553 // we only set db_ to the created database if creation is successful. That |
| 561 // way other methods won't do anything as db_ is still NULL. | 554 // way other methods won't do anything as db_ is still NULL. |
| 562 | 555 |
| 563 HistoryFieldTrial::Activate(); | |
| 564 | |
| 565 TimeTicks beginning_time = TimeTicks::Now(); | 556 TimeTicks beginning_time = TimeTicks::Now(); |
| 566 | 557 |
| 567 // Compute the file names. Note that the index file can be removed when the | 558 // Compute the file names. Note that the index file can be removed when the |
| 568 // text db manager is finished being hooked up. | 559 // text db manager is finished being hooked up. |
| 569 FilePath history_name = history_dir_.Append(chrome::kHistoryFilename); | 560 FilePath history_name = history_dir_.Append(chrome::kHistoryFilename); |
| 570 FilePath thumbnail_name = GetThumbnailFileName(); | 561 FilePath thumbnail_name = GetThumbnailFileName(); |
| 571 FilePath archived_name = GetArchivedFileName(); | 562 FilePath archived_name = GetArchivedFileName(); |
| 572 FilePath tmp_bookmarks_file = history_dir_.Append( | 563 FilePath tmp_bookmarks_file = history_dir_.Append( |
| 573 chrome::kHistoryBookmarksFileName); | 564 chrome::kHistoryBookmarksFileName); |
| 574 | 565 |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 // if (archived_db_.get() && | 1216 // if (archived_db_.get() && |
| 1226 // expirer_.GetCurrentArchiveTime() - TimeDelta::FromDays(7)) { | 1217 // expirer_.GetCurrentArchiveTime() - TimeDelta::FromDays(7)) { |
| 1227 } else { | 1218 } else { |
| 1228 // Full text history query. | 1219 // Full text history query. |
| 1229 QueryHistoryFTS(text_query, options, &request->value); | 1220 QueryHistoryFTS(text_query, options, &request->value); |
| 1230 } | 1221 } |
| 1231 } | 1222 } |
| 1232 | 1223 |
| 1233 request->ForwardResult(request->handle(), &request->value); | 1224 request->ForwardResult(request->handle(), &request->value); |
| 1234 | 1225 |
| 1235 UMA_HISTOGRAM_TIMES( | 1226 UMA_HISTOGRAM_TIMES("History.QueryHistory", |
| 1236 "History.QueryHistory" + HistoryFieldTrial::GetGroupSuffix(), | 1227 TimeTicks::Now() - beginning_time); |
| 1237 TimeTicks::Now() - beginning_time); | |
| 1238 } | 1228 } |
| 1239 | 1229 |
| 1240 // Basic time-based querying of history. | 1230 // Basic time-based querying of history. |
| 1241 void HistoryBackend::QueryHistoryBasic(URLDatabase* url_db, | 1231 void HistoryBackend::QueryHistoryBasic(URLDatabase* url_db, |
| 1242 VisitDatabase* visit_db, | 1232 VisitDatabase* visit_db, |
| 1243 const QueryOptions& options, | 1233 const QueryOptions& options, |
| 1244 QueryResults* result) { | 1234 QueryResults* result) { |
| 1245 // First get all visits. | 1235 // First get all visits. |
| 1246 VisitVector visits; | 1236 VisitVector visits; |
| 1247 visit_db->GetVisibleVisitsInRange(options.begin_time, options.end_time, | 1237 visit_db->GetVisibleVisitsInRange(options.begin_time, options.end_time, |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 break; | 2316 break; |
| 2327 } | 2317 } |
| 2328 } | 2318 } |
| 2329 } | 2319 } |
| 2330 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name | 2320 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name |
| 2331 TimeTicks::Now() - beginning_time); | 2321 TimeTicks::Now() - beginning_time); |
| 2332 return success; | 2322 return success; |
| 2333 } | 2323 } |
| 2334 | 2324 |
| 2335 } // namespace history | 2325 } // namespace history |
| OLD | NEW |