| 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/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 explicit MostVisitedSites(Profile* profile) : | 174 explicit MostVisitedSites(Profile* profile) : |
| 175 profile_(profile) { | 175 profile_(profile) { |
| 176 // If TopSites is already loaded, we will want to use it right away. | 176 // If TopSites is already loaded, we will want to use it right away. |
| 177 // Otherwise, wait for three seconds to avoid race conditions. | 177 // Otherwise, wait for three seconds to avoid race conditions. |
| 178 // This is a hack to ensure unit tests don't fail. | 178 // This is a hack to ensure unit tests don't fail. |
| 179 // See http://crbug.com/94654 | 179 // See http://crbug.com/94654 |
| 180 if (profile && profile->GetTopSitesWithoutCreating()) { | 180 if (profile && profile->GetTopSitesWithoutCreating()) { |
| 181 Init(); | 181 Init(); |
| 182 } else { | 182 } else { |
| 183 timer_.Start(base::TimeDelta::FromSeconds(3), this, | 183 timer_.Start(base::TimeDelta::FromSeconds(3), this, |
| 184 &prerender::PrerenderManager::MostVisitedSites::Init); | 184 &prerender::PrerenderManager::MostVisitedSites::Init, |
| 185 FROM_HERE); |
| 185 } | 186 } |
| 186 } | 187 } |
| 187 | 188 |
| 188 void Init() { | 189 void Init() { |
| 189 history::TopSites* top_sites = GetTopSites(); | 190 history::TopSites* top_sites = GetTopSites(); |
| 190 if (top_sites) { | 191 if (top_sites) { |
| 191 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, | 192 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, |
| 192 Source<history::TopSites>(top_sites)); | 193 Source<history::TopSites>(top_sites)); |
| 193 } | 194 } |
| 194 | 195 |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); | 794 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); |
| 794 } | 795 } |
| 795 | 796 |
| 796 void PrerenderManager::StartSchedulingPeriodicCleanups() { | 797 void PrerenderManager::StartSchedulingPeriodicCleanups() { |
| 797 DCHECK(CalledOnValidThread()); | 798 DCHECK(CalledOnValidThread()); |
| 798 if (repeating_timer_.IsRunning()) | 799 if (repeating_timer_.IsRunning()) |
| 799 return; | 800 return; |
| 800 repeating_timer_.Start( | 801 repeating_timer_.Start( |
| 801 base::TimeDelta::FromMilliseconds(kPeriodicCleanupIntervalMs), | 802 base::TimeDelta::FromMilliseconds(kPeriodicCleanupIntervalMs), |
| 802 this, | 803 this, |
| 803 &PrerenderManager::PeriodicCleanup); | 804 &PrerenderManager::PeriodicCleanup, |
| 805 FROM_HERE); |
| 804 } | 806 } |
| 805 | 807 |
| 806 void PrerenderManager::MaybeStopSchedulingPeriodicCleanups() { | 808 void PrerenderManager::MaybeStopSchedulingPeriodicCleanups() { |
| 807 if (!prerender_list_.empty()) | 809 if (!prerender_list_.empty()) |
| 808 return; | 810 return; |
| 809 | 811 |
| 810 DCHECK(CalledOnValidThread()); | 812 DCHECK(CalledOnValidThread()); |
| 811 repeating_timer_.Stop(); | 813 repeating_timer_.Stop(); |
| 812 } | 814 } |
| 813 | 815 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 DeletePendingDeleteEntries(); | 1030 DeletePendingDeleteEntries(); |
| 1029 } | 1031 } |
| 1030 | 1032 |
| 1031 void PrerenderManager::RecordFinalStatus(Origin origin, | 1033 void PrerenderManager::RecordFinalStatus(Origin origin, |
| 1032 uint8 experiment_id, | 1034 uint8 experiment_id, |
| 1033 FinalStatus final_status) const { | 1035 FinalStatus final_status) const { |
| 1034 histograms_->RecordFinalStatus(origin, experiment_id, final_status); | 1036 histograms_->RecordFinalStatus(origin, experiment_id, final_status); |
| 1035 } | 1037 } |
| 1036 | 1038 |
| 1037 } // namespace prerender | 1039 } // namespace prerender |
| OLD | NEW |