| 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_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 return (url.SchemeIsHTTPOrHTTPS() || | 1016 return (url.SchemeIsHTTPOrHTTPS() || |
| 1017 url.SchemeIs(extensions::kExtensionScheme) || | 1017 url.SchemeIs(extensions::kExtensionScheme) || |
| 1018 url.SchemeIs("data")); | 1018 url.SchemeIs("data")); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 // static | 1021 // static |
| 1022 bool PrerenderManager::DoesSubresourceURLHaveValidScheme(const GURL& url) { | 1022 bool PrerenderManager::DoesSubresourceURLHaveValidScheme(const GURL& url) { |
| 1023 return DoesURLHaveValidScheme(url) || url == GURL(content::kAboutBlankURL); | 1023 return DoesURLHaveValidScheme(url) || url == GURL(content::kAboutBlankURL); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 DictionaryValue* PrerenderManager::GetAsValue() const { | 1026 base::DictionaryValue* PrerenderManager::GetAsValue() const { |
| 1027 DCHECK(CalledOnValidThread()); | 1027 DCHECK(CalledOnValidThread()); |
| 1028 DictionaryValue* dict_value = new DictionaryValue(); | 1028 base::DictionaryValue* dict_value = new base::DictionaryValue(); |
| 1029 dict_value->Set("history", prerender_history_->GetEntriesAsValue()); | 1029 dict_value->Set("history", prerender_history_->GetEntriesAsValue()); |
| 1030 dict_value->Set("active", GetActivePrerendersAsValue()); | 1030 dict_value->Set("active", GetActivePrerendersAsValue()); |
| 1031 dict_value->SetBoolean("enabled", enabled_); | 1031 dict_value->SetBoolean("enabled", enabled_); |
| 1032 dict_value->SetBoolean("omnibox_enabled", IsOmniboxEnabled(profile_)); | 1032 dict_value->SetBoolean("omnibox_enabled", IsOmniboxEnabled(profile_)); |
| 1033 // If prerender is disabled via a flag this method is not even called. | 1033 // If prerender is disabled via a flag this method is not even called. |
| 1034 std::string enabled_note; | 1034 std::string enabled_note; |
| 1035 if (IsControlGroup(kNoExperiment)) | 1035 if (IsControlGroup(kNoExperiment)) |
| 1036 enabled_note += "(Control group: Not actually prerendering) "; | 1036 enabled_note += "(Control group: Not actually prerendering) "; |
| 1037 if (IsNoUseGroup()) | 1037 if (IsNoUseGroup()) |
| 1038 enabled_note += "(No-use group: Not swapping in prerendered pages) "; | 1038 enabled_note += "(No-use group: Not swapping in prerendered pages) "; |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 void PrerenderManager::AddToHistory(PrerenderContents* contents) { | 1657 void PrerenderManager::AddToHistory(PrerenderContents* contents) { |
| 1658 PrerenderHistory::Entry entry(contents->prerender_url(), | 1658 PrerenderHistory::Entry entry(contents->prerender_url(), |
| 1659 contents->final_status(), | 1659 contents->final_status(), |
| 1660 contents->origin(), | 1660 contents->origin(), |
| 1661 base::Time::Now()); | 1661 base::Time::Now()); |
| 1662 prerender_history_->AddEntry(entry); | 1662 prerender_history_->AddEntry(entry); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 Value* PrerenderManager::GetActivePrerendersAsValue() const { | 1665 base::Value* PrerenderManager::GetActivePrerendersAsValue() const { |
| 1666 ListValue* list_value = new ListValue(); | 1666 base::ListValue* list_value = new base::ListValue(); |
| 1667 for (ScopedVector<PrerenderData>::const_iterator it = | 1667 for (ScopedVector<PrerenderData>::const_iterator it = |
| 1668 active_prerenders_.begin(); | 1668 active_prerenders_.begin(); |
| 1669 it != active_prerenders_.end(); ++it) { | 1669 it != active_prerenders_.end(); ++it) { |
| 1670 if (Value* prerender_value = (*it)->contents()->GetAsValue()) | 1670 if (base::Value* prerender_value = (*it)->contents()->GetAsValue()) |
| 1671 list_value->Append(prerender_value); | 1671 list_value->Append(prerender_value); |
| 1672 } | 1672 } |
| 1673 return list_value; | 1673 return list_value; |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 void PrerenderManager::DestroyAllContents(FinalStatus final_status) { | 1676 void PrerenderManager::DestroyAllContents(FinalStatus final_status) { |
| 1677 DeleteOldWebContents(); | 1677 DeleteOldWebContents(); |
| 1678 while (!active_prerenders_.empty()) { | 1678 while (!active_prerenders_.empty()) { |
| 1679 PrerenderContents* contents = active_prerenders_.front()->contents(); | 1679 PrerenderContents* contents = active_prerenders_.front()->contents(); |
| 1680 contents->Destroy(final_status); | 1680 contents->Destroy(final_status); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 void PrerenderManager::RecordEvent(PrerenderContents* contents, | 1868 void PrerenderManager::RecordEvent(PrerenderContents* contents, |
| 1869 PrerenderEvent event) const { | 1869 PrerenderEvent event) const { |
| 1870 if (!contents) | 1870 if (!contents) |
| 1871 histograms_->RecordEvent(ORIGIN_NONE, kNoExperiment, event); | 1871 histograms_->RecordEvent(ORIGIN_NONE, kNoExperiment, event); |
| 1872 else | 1872 else |
| 1873 histograms_->RecordEvent(contents->origin(), contents->experiment_id(), | 1873 histograms_->RecordEvent(contents->origin(), contents->experiment_id(), |
| 1874 event); | 1874 event); |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 } // namespace prerender | 1877 } // namespace prerender |
| OLD | NEW |