| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 public: | 173 public: |
| 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(FROM_HERE, base::TimeDelta::FromSeconds(3), this, | 183 timer_.Start(base::TimeDelta::FromSeconds(3), this, |
| 184 &prerender::PrerenderManager::MostVisitedSites::Init); | 184 &prerender::PrerenderManager::MostVisitedSites::Init); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 void Init() { | 188 void Init() { |
| 189 history::TopSites* top_sites = GetTopSites(); | 189 history::TopSites* top_sites = GetTopSites(); |
| 190 if (top_sites) { | 190 if (top_sites) { |
| 191 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, | 191 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, |
| 192 Source<history::TopSites>(top_sites)); | 192 Source<history::TopSites>(top_sites)); |
| 193 } | 193 } |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 if (!config_.rate_limit_enabled) | 788 if (!config_.rate_limit_enabled) |
| 789 return true; | 789 return true; |
| 790 return elapsed_time > | 790 return elapsed_time > |
| 791 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); | 791 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); |
| 792 } | 792 } |
| 793 | 793 |
| 794 void PrerenderManager::StartSchedulingPeriodicCleanups() { | 794 void PrerenderManager::StartSchedulingPeriodicCleanups() { |
| 795 DCHECK(CalledOnValidThread()); | 795 DCHECK(CalledOnValidThread()); |
| 796 if (repeating_timer_.IsRunning()) | 796 if (repeating_timer_.IsRunning()) |
| 797 return; | 797 return; |
| 798 repeating_timer_.Start(FROM_HERE, | 798 repeating_timer_.Start( |
| 799 base::TimeDelta::FromMilliseconds(kPeriodicCleanupIntervalMs), | 799 base::TimeDelta::FromMilliseconds(kPeriodicCleanupIntervalMs), |
| 800 this, | 800 this, |
| 801 &PrerenderManager::PeriodicCleanup); | 801 &PrerenderManager::PeriodicCleanup); |
| 802 } | 802 } |
| 803 | 803 |
| 804 void PrerenderManager::MaybeStopSchedulingPeriodicCleanups() { | 804 void PrerenderManager::MaybeStopSchedulingPeriodicCleanups() { |
| 805 if (!prerender_list_.empty()) | 805 if (!prerender_list_.empty()) |
| 806 return; | 806 return; |
| 807 | 807 |
| 808 DCHECK(CalledOnValidThread()); | 808 DCHECK(CalledOnValidThread()); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 DeletePendingDeleteEntries(); | 1026 DeletePendingDeleteEntries(); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 void PrerenderManager::RecordFinalStatus(Origin origin, | 1029 void PrerenderManager::RecordFinalStatus(Origin origin, |
| 1030 uint8 experiment_id, | 1030 uint8 experiment_id, |
| 1031 FinalStatus final_status) const { | 1031 FinalStatus final_status) const { |
| 1032 histograms_->RecordFinalStatus(origin, experiment_id, final_status); | 1032 histograms_->RecordFinalStatus(origin, experiment_id, final_status); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 } // namespace prerender | 1035 } // namespace prerender |
| OLD | NEW |