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