Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 315 }
316 visit_set.insert(visit_id); 316 visit_set.insert(visit_id);
317 } 317 }
318 return 0; 318 return 0;
319 } 319 }
320 320
321 SegmentID HistoryBackend::UpdateSegments( 321 SegmentID HistoryBackend::UpdateSegments(
322 const GURL& url, 322 const GURL& url,
323 VisitID from_visit, 323 VisitID from_visit,
324 VisitID visit_id, 324 VisitID visit_id,
325 content::PageTransition transition_type, 325 ui::PageTransition transition_type,
326 const Time ts) { 326 const Time ts) {
327 if (!db_) 327 if (!db_)
328 return 0; 328 return 0;
329 329
330 // We only consider main frames. 330 // We only consider main frames.
331 if (!content::PageTransitionIsMainFrame(transition_type)) 331 if (!ui::PageTransitionIsMainFrame(transition_type))
332 return 0; 332 return 0;
333 333
334 SegmentID segment_id = 0; 334 SegmentID segment_id = 0;
335 content::PageTransition t = 335 ui::PageTransition t =
336 content::PageTransitionStripQualifier(transition_type); 336 ui::PageTransitionStripQualifier(transition_type);
337 337
338 // Are we at the beginning of a new segment? 338 // Are we at the beginning of a new segment?
339 // Note that navigating to an existing entry (with back/forward) reuses the 339 // Note that navigating to an existing entry (with back/forward) reuses the
340 // same transition type. We are not adding it as a new segment in that case 340 // same transition type. We are not adding it as a new segment in that case
341 // because if this was the target of a redirect, we might end up with 341 // because if this was the target of a redirect, we might end up with
342 // 2 entries for the same final URL. Ex: User types google.net, gets 342 // 2 entries for the same final URL. Ex: User types google.net, gets
343 // redirected to google.com. A segment is created for google.net. On 343 // redirected to google.com. A segment is created for google.net. On
344 // google.com users navigates through a link, then press back. That last 344 // google.com users navigates through a link, then press back. That last
345 // navigation is for the entry google.com transition typed. We end up adding 345 // navigation is for the entry google.com transition typed. We end up adding
346 // a segment for that one as well. So we end up with google.net and google.com 346 // a segment for that one as well. So we end up with google.net and google.com
347 // in the segment table, showing as 2 entries in the NTP. 347 // in the segment table, showing as 2 entries in the NTP.
348 // Note also that we should still be updating the visit count for that segment 348 // Note also that we should still be updating the visit count for that segment
349 // which we are not doing now. It should be addressed when 349 // which we are not doing now. It should be addressed when
350 // http://crbug.com/96860 is fixed. 350 // http://crbug.com/96860 is fixed.
351 if ((t == content::PAGE_TRANSITION_TYPED || 351 if ((t == ui::PAGE_TRANSITION_TYPED ||
352 t == content::PAGE_TRANSITION_AUTO_BOOKMARK) && 352 t == ui::PAGE_TRANSITION_AUTO_BOOKMARK) &&
353 (transition_type & content::PAGE_TRANSITION_FORWARD_BACK) == 0) { 353 (transition_type & ui::PAGE_TRANSITION_FORWARD_BACK) == 0) {
354 // If so, create or get the segment. 354 // If so, create or get the segment.
355 std::string segment_name = db_->ComputeSegmentName(url); 355 std::string segment_name = db_->ComputeSegmentName(url);
356 URLID url_id = db_->GetRowForURL(url, NULL); 356 URLID url_id = db_->GetRowForURL(url, NULL);
357 if (!url_id) 357 if (!url_id)
358 return 0; 358 return 0;
359 359
360 segment_id = db_->GetSegmentNamed(segment_name); 360 segment_id = db_->GetSegmentNamed(segment_name);
361 if (!segment_id) { 361 if (!segment_id) {
362 segment_id = db_->CreateSegment(url_id, segment_name); 362 segment_id = db_->CreateSegment(url_id, segment_name);
363 if (!segment_id) { 363 if (!segment_id) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // If a redirect chain is given, we expect the last item in that chain to be 430 // If a redirect chain is given, we expect the last item in that chain to be
431 // the final URL. 431 // the final URL.
432 DCHECK(request.redirects.empty() || 432 DCHECK(request.redirects.empty() ||
433 request.redirects.back() == request.url); 433 request.redirects.back() == request.url);
434 434
435 // If the user is adding older history, we need to make sure our times 435 // If the user is adding older history, we need to make sure our times
436 // are correct. 436 // are correct.
437 if (request.time < first_recorded_time_) 437 if (request.time < first_recorded_time_)
438 first_recorded_time_ = request.time; 438 first_recorded_time_ = request.time;
439 439
440 content::PageTransition request_transition = request.transition; 440 ui::PageTransition request_transition = request.transition;
441 content::PageTransition stripped_transition = 441 ui::PageTransition stripped_transition =
442 content::PageTransitionStripQualifier(request_transition); 442 ui::PageTransitionStripQualifier(request_transition);
443 bool is_keyword_generated = 443 bool is_keyword_generated =
444 (stripped_transition == content::PAGE_TRANSITION_KEYWORD_GENERATED); 444 (stripped_transition == ui::PAGE_TRANSITION_KEYWORD_GENERATED);
445 445
446 // If the user is navigating to a not-previously-typed intranet hostname, 446 // If the user is navigating to a not-previously-typed intranet hostname,
447 // change the transition to TYPED so that the omnibox will learn that this is 447 // change the transition to TYPED so that the omnibox will learn that this is
448 // a known host. 448 // a known host.
449 bool has_redirects = request.redirects.size() > 1; 449 bool has_redirects = request.redirects.size() > 1;
450 if (content::PageTransitionIsMainFrame(request_transition) && 450 if (ui::PageTransitionIsMainFrame(request_transition) &&
451 (stripped_transition != content::PAGE_TRANSITION_TYPED) && 451 (stripped_transition != ui::PAGE_TRANSITION_TYPED) &&
452 !is_keyword_generated) { 452 !is_keyword_generated) {
453 const GURL& origin_url(has_redirects ? 453 const GURL& origin_url(has_redirects ?
454 request.redirects[0] : request.url); 454 request.redirects[0] : request.url);
455 if (origin_url.SchemeIs(url::kHttpScheme) || 455 if (origin_url.SchemeIs(url::kHttpScheme) ||
456 origin_url.SchemeIs(url::kHttpsScheme) || 456 origin_url.SchemeIs(url::kHttpsScheme) ||
457 origin_url.SchemeIs(url::kFtpScheme)) { 457 origin_url.SchemeIs(url::kFtpScheme)) {
458 std::string host(origin_url.host()); 458 std::string host(origin_url.host());
459 size_t registry_length = 459 size_t registry_length =
460 net::registry_controlled_domains::GetRegistryLength( 460 net::registry_controlled_domains::GetRegistryLength(
461 host, 461 host,
462 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, 462 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
463 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); 463 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
464 if (registry_length == 0 && !db_->IsTypedHost(host)) { 464 if (registry_length == 0 && !db_->IsTypedHost(host)) {
465 stripped_transition = content::PAGE_TRANSITION_TYPED; 465 stripped_transition = ui::PAGE_TRANSITION_TYPED;
466 request_transition = 466 request_transition =
467 content::PageTransitionFromInt( 467 ui::PageTransitionFromInt(
468 stripped_transition | 468 stripped_transition |
469 content::PageTransitionGetQualifier(request_transition)); 469 ui::PageTransitionGetQualifier(request_transition));
470 } 470 }
471 } 471 }
472 } 472 }
473 473
474 if (!has_redirects) { 474 if (!has_redirects) {
475 // The single entry is both a chain start and end. 475 // The single entry is both a chain start and end.
476 content::PageTransition t = content::PageTransitionFromInt( 476 ui::PageTransition t = ui::PageTransitionFromInt(
477 request_transition | 477 request_transition |
478 content::PAGE_TRANSITION_CHAIN_START | 478 ui::PAGE_TRANSITION_CHAIN_START |
479 content::PAGE_TRANSITION_CHAIN_END); 479 ui::PAGE_TRANSITION_CHAIN_END);
480 480
481 // No redirect case (one element means just the page itself). 481 // No redirect case (one element means just the page itself).
482 last_ids = AddPageVisit(request.url, request.time, 482 last_ids = AddPageVisit(request.url, request.time,
483 last_ids.second, t, request.visit_source); 483 last_ids.second, t, request.visit_source);
484 484
485 // Update the segment for this visit. KEYWORD_GENERATED visits should not 485 // Update the segment for this visit. KEYWORD_GENERATED visits should not
486 // result in changing most visited, so we don't update segments (most 486 // result in changing most visited, so we don't update segments (most
487 // visited db). 487 // visited db).
488 if (!is_keyword_generated) { 488 if (!is_keyword_generated) {
489 UpdateSegments(request.url, from_visit_id, last_ids.second, t, 489 UpdateSegments(request.url, from_visit_id, last_ids.second, t,
490 request.time); 490 request.time);
491 491
492 // Update the referrer's duration. 492 // Update the referrer's duration.
493 UpdateVisitDuration(from_visit_id, request.time); 493 UpdateVisitDuration(from_visit_id, request.time);
494 } 494 }
495 } else { 495 } else {
496 // Redirect case. Add the redirect chain. 496 // Redirect case. Add the redirect chain.
497 497
498 content::PageTransition redirect_info = 498 ui::PageTransition redirect_info =
499 content::PAGE_TRANSITION_CHAIN_START; 499 ui::PAGE_TRANSITION_CHAIN_START;
500 500
501 RedirectList redirects = request.redirects; 501 RedirectList redirects = request.redirects;
502 if (redirects[0].SchemeIs(url::kAboutScheme)) { 502 if (redirects[0].SchemeIs(url::kAboutScheme)) {
503 // When the redirect source + referrer is "about" we skip it. This 503 // When the redirect source + referrer is "about" we skip it. This
504 // happens when a page opens a new frame/window to about:blank and then 504 // happens when a page opens a new frame/window to about:blank and then
505 // script sets the URL to somewhere else (used to hide the referrer). It 505 // script sets the URL to somewhere else (used to hide the referrer). It
506 // would be nice to keep all these redirects properly but we don't ever 506 // would be nice to keep all these redirects properly but we don't ever
507 // see the initial about:blank load, so we don't know where the 507 // see the initial about:blank load, so we don't know where the
508 // subsequent client redirect came from. 508 // subsequent client redirect came from.
509 // 509 //
510 // In this case, we just don't bother hooking up the source of the 510 // In this case, we just don't bother hooking up the source of the
511 // redirects, so we remove it. 511 // redirects, so we remove it.
512 redirects.erase(redirects.begin()); 512 redirects.erase(redirects.begin());
513 } else if (request_transition & content::PAGE_TRANSITION_CLIENT_REDIRECT) { 513 } else if (request_transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) {
514 redirect_info = content::PAGE_TRANSITION_CLIENT_REDIRECT; 514 redirect_info = ui::PAGE_TRANSITION_CLIENT_REDIRECT;
515 // The first entry in the redirect chain initiated a client redirect. 515 // The first entry in the redirect chain initiated a client redirect.
516 // We don't add this to the database since the referrer is already 516 // We don't add this to the database since the referrer is already
517 // there, so we skip over it but change the transition type of the first 517 // there, so we skip over it but change the transition type of the first
518 // transition to client redirect. 518 // transition to client redirect.
519 // 519 //
520 // The referrer is invalid when restoring a session that features an 520 // The referrer is invalid when restoring a session that features an
521 // https tab that redirects to a different host or to http. In this 521 // https tab that redirects to a different host or to http. In this
522 // case we don't need to reconnect the new redirect with the existing 522 // case we don't need to reconnect the new redirect with the existing
523 // chain. 523 // chain.
524 if (request.referrer.is_valid()) { 524 if (request.referrer.is_valid()) {
525 DCHECK(request.referrer == redirects[0]); 525 DCHECK(request.referrer == redirects[0]);
526 redirects.erase(redirects.begin()); 526 redirects.erase(redirects.begin());
527 527
528 // If the navigation entry for this visit has replaced that for the 528 // If the navigation entry for this visit has replaced that for the
529 // first visit, remove the CHAIN_END marker from the first visit. This 529 // first visit, remove the CHAIN_END marker from the first visit. This
530 // can be called a lot, for example, the page cycler, and most of the 530 // can be called a lot, for example, the page cycler, and most of the
531 // time we won't have changed anything. 531 // time we won't have changed anything.
532 VisitRow visit_row; 532 VisitRow visit_row;
533 if (request.did_replace_entry && 533 if (request.did_replace_entry &&
534 db_->GetRowForVisit(last_ids.second, &visit_row) && 534 db_->GetRowForVisit(last_ids.second, &visit_row) &&
535 visit_row.transition & content::PAGE_TRANSITION_CHAIN_END) { 535 visit_row.transition & ui::PAGE_TRANSITION_CHAIN_END) {
536 visit_row.transition = content::PageTransitionFromInt( 536 visit_row.transition = ui::PageTransitionFromInt(
537 visit_row.transition & ~content::PAGE_TRANSITION_CHAIN_END); 537 visit_row.transition & ~ui::PAGE_TRANSITION_CHAIN_END);
538 db_->UpdateVisitRow(visit_row); 538 db_->UpdateVisitRow(visit_row);
539 } 539 }
540 } 540 }
541 } 541 }
542 542
543 for (size_t redirect_index = 0; redirect_index < redirects.size(); 543 for (size_t redirect_index = 0; redirect_index < redirects.size();
544 redirect_index++) { 544 redirect_index++) {
545 content::PageTransition t = 545 ui::PageTransition t =
546 content::PageTransitionFromInt(stripped_transition | redirect_info); 546 ui::PageTransitionFromInt(stripped_transition | redirect_info);
547 547
548 // If this is the last transition, add a CHAIN_END marker 548 // If this is the last transition, add a CHAIN_END marker
549 if (redirect_index == (redirects.size() - 1)) { 549 if (redirect_index == (redirects.size() - 1)) {
550 t = content::PageTransitionFromInt( 550 t = ui::PageTransitionFromInt(
551 t | content::PAGE_TRANSITION_CHAIN_END); 551 t | ui::PAGE_TRANSITION_CHAIN_END);
552 } 552 }
553 553
554 // Record all redirect visits with the same timestamp. We don't display 554 // Record all redirect visits with the same timestamp. We don't display
555 // them anyway, and if we ever decide to, we can reconstruct their order 555 // them anyway, and if we ever decide to, we can reconstruct their order
556 // from the redirect chain. 556 // from the redirect chain.
557 last_ids = AddPageVisit(redirects[redirect_index], 557 last_ids = AddPageVisit(redirects[redirect_index],
558 request.time, last_ids.second, 558 request.time, last_ids.second,
559 t, request.visit_source); 559 t, request.visit_source);
560 if (t & content::PAGE_TRANSITION_CHAIN_START) { 560 if (t & ui::PAGE_TRANSITION_CHAIN_START) {
561 // Update the segment for this visit. 561 // Update the segment for this visit.
562 UpdateSegments(redirects[redirect_index], 562 UpdateSegments(redirects[redirect_index],
563 from_visit_id, last_ids.second, t, request.time); 563 from_visit_id, last_ids.second, t, request.time);
564 564
565 // Update the visit_details for this visit. 565 // Update the visit_details for this visit.
566 UpdateVisitDuration(from_visit_id, request.time); 566 UpdateVisitDuration(from_visit_id, request.time);
567 } 567 }
568 568
569 // Subsequent transitions in the redirect list must all be server 569 // Subsequent transitions in the redirect list must all be server
570 // redirects. 570 // redirects.
571 redirect_info = content::PAGE_TRANSITION_SERVER_REDIRECT; 571 redirect_info = ui::PAGE_TRANSITION_SERVER_REDIRECT;
572 } 572 }
573 573
574 // Last, save this redirect chain for later so we can set titles & favicons 574 // Last, save this redirect chain for later so we can set titles & favicons
575 // on the redirected pages properly. 575 // on the redirected pages properly.
576 recent_redirects_.Put(request.url, redirects); 576 recent_redirects_.Put(request.url, redirects);
577 } 577 }
578 578
579 // TODO(brettw) bug 1140015: Add an "add page" notification so the history 579 // TODO(brettw) bug 1140015: Add an "add page" notification so the history
580 // views can keep in sync. 580 // views can keep in sync.
581 581
582 // Add the last visit to the tracker so we can get outgoing transitions. 582 // Add the last visit to the tracker so we can get outgoing transitions.
583 // TODO(evanm): Due to http://b/1194536 we lose the referrers of a subframe 583 // TODO(evanm): Due to http://b/1194536 we lose the referrers of a subframe
584 // navigation anyway, so last_visit_id is always zero for them. But adding 584 // navigation anyway, so last_visit_id is always zero for them. But adding
585 // them here confuses main frame history, so we skip them for now. 585 // them here confuses main frame history, so we skip them for now.
586 if (stripped_transition != content::PAGE_TRANSITION_AUTO_SUBFRAME && 586 if (stripped_transition != ui::PAGE_TRANSITION_AUTO_SUBFRAME &&
587 stripped_transition != content::PAGE_TRANSITION_MANUAL_SUBFRAME && 587 stripped_transition != ui::PAGE_TRANSITION_MANUAL_SUBFRAME &&
588 !is_keyword_generated) { 588 !is_keyword_generated) {
589 tracker_.AddVisit(request.context_id, request.page_id, request.url, 589 tracker_.AddVisit(request.context_id, request.page_id, request.url,
590 last_ids.second); 590 last_ids.second);
591 } 591 }
592 592
593 ScheduleCommit(); 593 ScheduleCommit();
594 } 594 }
595 595
596 void HistoryBackend::InitImpl(const std::string& languages) { 596 void HistoryBackend::InitImpl(const std::string& languages) {
597 DCHECK(!db_) << "Initializing HistoryBackend twice"; 597 DCHECK(!db_) << "Initializing HistoryBackend twice";
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 if (thumbnail_db_) { 727 if (thumbnail_db_) {
728 thumbnail_db_->CommitTransaction(); 728 thumbnail_db_->CommitTransaction();
729 thumbnail_db_.reset(); 729 thumbnail_db_.reset();
730 } 730 }
731 } 731 }
732 732
733 std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( 733 std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
734 const GURL& url, 734 const GURL& url,
735 Time time, 735 Time time,
736 VisitID referring_visit, 736 VisitID referring_visit,
737 content::PageTransition transition, 737 ui::PageTransition transition,
738 VisitSource visit_source) { 738 VisitSource visit_source) {
739 // Top-level frame navigations are visible, everything else is hidden 739 // Top-level frame navigations are visible, everything else is hidden
740 bool new_hidden = !content::PageTransitionIsMainFrame(transition); 740 bool new_hidden = !ui::PageTransitionIsMainFrame(transition);
741 741
742 // NOTE: This code must stay in sync with 742 // NOTE: This code must stay in sync with
743 // ExpireHistoryBackend::ExpireURLsForVisits(). 743 // ExpireHistoryBackend::ExpireURLsForVisits().
744 // TODO(pkasting): http://b/1148304 We shouldn't be marking so many URLs as 744 // TODO(pkasting): http://b/1148304 We shouldn't be marking so many URLs as
745 // typed, which would eliminate the need for this code. 745 // typed, which would eliminate the need for this code.
746 int typed_increment = 0; 746 int typed_increment = 0;
747 content::PageTransition transition_type = 747 ui::PageTransition transition_type =
748 content::PageTransitionStripQualifier(transition); 748 ui::PageTransitionStripQualifier(transition);
749 if ((transition_type == content::PAGE_TRANSITION_TYPED && 749 if ((transition_type == ui::PAGE_TRANSITION_TYPED &&
750 !content::PageTransitionIsRedirect(transition)) || 750 !ui::PageTransitionIsRedirect(transition)) ||
751 transition_type == content::PAGE_TRANSITION_KEYWORD_GENERATED) 751 transition_type == ui::PAGE_TRANSITION_KEYWORD_GENERATED)
752 typed_increment = 1; 752 typed_increment = 1;
753 753
754 #if defined(OS_ANDROID) 754 #if defined(OS_ANDROID)
755 // Only count the page visit if it came from user browsing and only count it 755 // Only count the page visit if it came from user browsing and only count it
756 // once when cycling through a redirect chain. 756 // once when cycling through a redirect chain.
757 if (visit_source == SOURCE_BROWSED && 757 if (visit_source == SOURCE_BROWSED &&
758 (transition & content::PAGE_TRANSITION_CHAIN_END) != 0) { 758 (transition & ui::PAGE_TRANSITION_CHAIN_END) != 0) {
759 RecordTopPageVisitStats(url); 759 RecordTopPageVisitStats(url);
760 } 760 }
761 #endif 761 #endif
762 762
763 // See if this URL is already in the DB. 763 // See if this URL is already in the DB.
764 URLRow url_info(url); 764 URLRow url_info(url);
765 URLID url_id = db_->GetRowForURL(url, &url_info); 765 URLID url_id = db_->GetRowForURL(url, &url_info);
766 if (url_id) { 766 if (url_id) {
767 // Update of an existing row. 767 // Update of an existing row.
768 if (content::PageTransitionStripQualifier(transition) != 768 if (ui::PageTransitionStripQualifier(transition) !=
769 content::PAGE_TRANSITION_RELOAD) 769 ui::PAGE_TRANSITION_RELOAD)
770 url_info.set_visit_count(url_info.visit_count() + 1); 770 url_info.set_visit_count(url_info.visit_count() + 1);
771 if (typed_increment) 771 if (typed_increment)
772 url_info.set_typed_count(url_info.typed_count() + typed_increment); 772 url_info.set_typed_count(url_info.typed_count() + typed_increment);
773 if (url_info.last_visit() < time) 773 if (url_info.last_visit() < time)
774 url_info.set_last_visit(time); 774 url_info.set_last_visit(time);
775 775
776 // Only allow un-hiding of pages, never hiding. 776 // Only allow un-hiding of pages, never hiding.
777 if (!new_hidden) 777 if (!new_hidden)
778 url_info.set_hidden(false); 778 url_info.set_hidden(false);
779 779
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 847 }
848 848
849 modified->changed_urls.push_back(*i); 849 modified->changed_urls.push_back(*i);
850 modified->changed_urls.back().set_id(url_id); // i->id_ is likely 0. 850 modified->changed_urls.back().set_id(url_id); // i->id_ is likely 0.
851 } 851 }
852 852
853 // Sync code manages the visits itself. 853 // Sync code manages the visits itself.
854 if (visit_source != SOURCE_SYNCED) { 854 if (visit_source != SOURCE_SYNCED) {
855 // Make up a visit to correspond to the last visit to the page. 855 // Make up a visit to correspond to the last visit to the page.
856 VisitRow visit_info(url_id, i->last_visit(), 0, 856 VisitRow visit_info(url_id, i->last_visit(), 0,
857 content::PageTransitionFromInt( 857 ui::PageTransitionFromInt(
858 content::PAGE_TRANSITION_LINK | 858 ui::PAGE_TRANSITION_LINK |
859 content::PAGE_TRANSITION_CHAIN_START | 859 ui::PAGE_TRANSITION_CHAIN_START |
860 content::PAGE_TRANSITION_CHAIN_END), 0); 860 ui::PAGE_TRANSITION_CHAIN_END), 0);
861 if (!db_->AddVisit(&visit_info, visit_source)) { 861 if (!db_->AddVisit(&visit_info, visit_source)) {
862 NOTREACHED() << "Adding visit failed."; 862 NOTREACHED() << "Adding visit failed.";
863 return; 863 return;
864 } 864 }
865 NotifyVisitObservers(visit_info); 865 NotifyVisitObservers(visit_info);
866 866
867 if (visit_info.visit_time < first_recorded_time_) 867 if (visit_info.visit_time < first_recorded_time_)
868 first_recorded_time_ = visit_info.visit_time; 868 first_recorded_time_ = visit_info.visit_time;
869 } 869 }
870 } 870 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 << visit.url_id << ": " 1246 << visit.url_id << ": "
1247 << url_result.url().possibly_invalid_spec(); 1247 << url_result.url().possibly_invalid_spec();
1248 continue; // Don't report invalid URLs in case of corruption. 1248 continue; // Don't report invalid URLs in case of corruption.
1249 } 1249 }
1250 1250
1251 url_result.set_visit_time(visit.visit_time); 1251 url_result.set_visit_time(visit.visit_time);
1252 1252
1253 // Set whether the visit was blocked for a managed user by looking at the 1253 // Set whether the visit was blocked for a managed user by looking at the
1254 // transition type. 1254 // transition type.
1255 url_result.set_blocked_visit( 1255 url_result.set_blocked_visit(
1256 (visit.transition & content::PAGE_TRANSITION_BLOCKED) != 0); 1256 (visit.transition & ui::PAGE_TRANSITION_BLOCKED) != 0);
1257 1257
1258 // We don't set any of the query-specific parts of the URLResult, since 1258 // We don't set any of the query-specific parts of the URLResult, since
1259 // snippets and stuff don't apply to basic querying. 1259 // snippets and stuff don't apply to basic querying.
1260 result->AppendURLBySwapping(&url_result); 1260 result->AppendURLBySwapping(&url_result);
1261 } 1261 }
1262 1262
1263 if (!has_more_results && options.begin_time <= first_recorded_time_) 1263 if (!has_more_results && options.begin_time <= first_recorded_time_)
1264 result->set_reached_beginning(true); 1264 result->set_reached_beginning(true);
1265 } 1265 }
1266 1266
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 int rank = kPageVisitStatsMaxTopSites; 2703 int rank = kPageVisitStatsMaxTopSites;
2704 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2704 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2705 if (it != most_visited_urls_map_.end()) 2705 if (it != most_visited_urls_map_.end())
2706 rank = (*it).second; 2706 rank = (*it).second;
2707 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2707 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2708 rank, kPageVisitStatsMaxTopSites + 1); 2708 rank, kPageVisitStatsMaxTopSites + 1);
2709 } 2709 }
2710 #endif 2710 #endif
2711 2711
2712 } // namespace history 2712 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698