| 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/prerender/prerender_local_predictor.h" | 5 #include "chrome/browser/prerender/prerender_local_predictor.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 "Prerender.LocalPredictorTimeUntilUsed", | 609 "Prerender.LocalPredictorTimeUntilUsed", |
| 610 GetCurrentTime() - current_prerender_->actual_start_time, | 610 GetCurrentTime() - current_prerender_->actual_start_time, |
| 611 base::TimeDelta::FromMilliseconds(10), | 611 base::TimeDelta::FromMilliseconds(10), |
| 612 base::TimeDelta::FromMilliseconds(GetMaxLocalPredictionTimeMs()), | 612 base::TimeDelta::FromMilliseconds(GetMaxLocalPredictionTimeMs()), |
| 613 50); | 613 50); |
| 614 last_swapped_in_prerender_.reset(current_prerender_.release()); | 614 last_swapped_in_prerender_.reset(current_prerender_.release()); |
| 615 RecordEvent(EVENT_ADD_VISIT_PRERENDER_IDENTIFIED); | 615 RecordEvent(EVENT_ADD_VISIT_PRERENDER_IDENTIFIED); |
| 616 } | 616 } |
| 617 if (ShouldExcludeTransitionForPrediction(info.transition)) | 617 if (ShouldExcludeTransitionForPrediction(info.transition)) |
| 618 return; | 618 return; |
| 619 Profile* profile = prerender_manager_->profile(); |
| 620 if (!profile || |
| 621 ShouldDisableLocalPredictorDueToPreferencesAndNetwork(profile)) { |
| 622 return; |
| 623 } |
| 619 RecordEvent(EVENT_ADD_VISIT_RELEVANT_TRANSITION); | 624 RecordEvent(EVENT_ADD_VISIT_RELEVANT_TRANSITION); |
| 620 base::TimeDelta max_age = | 625 base::TimeDelta max_age = |
| 621 base::TimeDelta::FromMilliseconds(GetMaxLocalPredictionTimeMs()); | 626 base::TimeDelta::FromMilliseconds(GetMaxLocalPredictionTimeMs()); |
| 622 base::TimeDelta min_age = | 627 base::TimeDelta min_age = |
| 623 base::TimeDelta::FromMilliseconds(kMinLocalPredictionTimeMs); | 628 base::TimeDelta::FromMilliseconds(kMinLocalPredictionTimeMs); |
| 624 std::set<URLID> next_urls_currently_found; | 629 std::set<URLID> next_urls_currently_found; |
| 625 std::map<URLID, int> next_urls_num_found; | 630 std::map<URLID, int> next_urls_num_found; |
| 626 int num_occurrences_of_current_visit = 0; | 631 int num_occurrences_of_current_visit = 0; |
| 627 base::Time last_visited; | 632 base::Time last_visited; |
| 628 scoped_ptr<CandidatePrerenderInfo> lookup_info( | 633 scoped_ptr<CandidatePrerenderInfo> lookup_info( |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 Profile* profile = prerender_manager_->profile(); | 1124 Profile* profile = prerender_manager_->profile(); |
| 1120 if (!profile) | 1125 if (!profile) |
| 1121 return NULL; | 1126 return NULL; |
| 1122 return HistoryServiceFactory::GetForProfileWithoutCreating(profile); | 1127 return HistoryServiceFactory::GetForProfileWithoutCreating(profile); |
| 1123 } | 1128 } |
| 1124 | 1129 |
| 1125 void PrerenderLocalPredictor::Init() { | 1130 void PrerenderLocalPredictor::Init() { |
| 1126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1127 RecordEvent(EVENT_INIT_STARTED); | 1132 RecordEvent(EVENT_INIT_STARTED); |
| 1128 Profile* profile = prerender_manager_->profile(); | 1133 Profile* profile = prerender_manager_->profile(); |
| 1129 if (!profile || DisableLocalPredictorBasedOnSyncAndConfiguration(profile)) { | 1134 if (!profile || |
| 1135 ShouldDisableLocalPredictorBasedOnSyncAndConfiguration(profile)) { |
| 1130 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED); | 1136 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED); |
| 1131 return; | 1137 return; |
| 1132 } | 1138 } |
| 1133 HistoryService* history = GetHistoryIfExists(); | 1139 HistoryService* history = GetHistoryIfExists(); |
| 1134 if (history) { | 1140 if (history) { |
| 1135 CHECK(!is_visit_database_observer_); | 1141 CHECK(!is_visit_database_observer_); |
| 1136 history->ScheduleDBTask( | 1142 history->ScheduleDBTask( |
| 1137 scoped_ptr<history::HistoryDBTask>( | 1143 scoped_ptr<history::HistoryDBTask>( |
| 1138 new GetVisitHistoryTask(this, kMaxVisitHistory)), | 1144 new GetVisitHistoryTask(this, kMaxVisitHistory)), |
| 1139 &history_db_tracker_); | 1145 &history_db_tracker_); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 break; | 1572 break; |
| 1567 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: | 1573 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: |
| 1568 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); | 1574 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); |
| 1569 break; | 1575 break; |
| 1570 default: | 1576 default: |
| 1571 NOTREACHED(); | 1577 NOTREACHED(); |
| 1572 } | 1578 } |
| 1573 } | 1579 } |
| 1574 | 1580 |
| 1575 } // namespace prerender | 1581 } // namespace prerender |
| OLD | NEW |