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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 342053002: Add UMA metrics for Android Chrome Google Search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated histogram name Created 6 years, 6 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 | Annotate | Revision Log
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/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 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 const GURL& url, Origin origin, uint8 experiment_id, 1623 const GURL& url, Origin origin, uint8 experiment_id,
1624 FinalStatus final_status) const { 1624 FinalStatus final_status) const {
1625 PrerenderHistory::Entry entry(url, final_status, origin, base::Time::Now()); 1625 PrerenderHistory::Entry entry(url, final_status, origin, base::Time::Now());
1626 prerender_history_->AddEntry(entry); 1626 prerender_history_->AddEntry(entry);
1627 RecordFinalStatusWithMatchCompleteStatus( 1627 RecordFinalStatusWithMatchCompleteStatus(
1628 origin, experiment_id, 1628 origin, experiment_id,
1629 PrerenderContents::MATCH_COMPLETE_DEFAULT, 1629 PrerenderContents::MATCH_COMPLETE_DEFAULT,
1630 final_status); 1630 final_status);
1631 } 1631 }
1632 1632
1633 bool PrerenderManager::IsEnabled() const {
1634 DCHECK(CalledOnValidThread());
1635 if (!enabled_)
1636 return false;
1637 for (std::list<const PrerenderCondition*>::const_iterator it =
1638 prerender_conditions_.begin();
1639 it != prerender_conditions_.end();
1640 ++it) {
1641 const PrerenderCondition* condition = *it;
1642 if (!condition->CanPrerender())
1643 return false;
1644 }
1645 return true;
1646 }
1647
1648 void PrerenderManager::Observe(int type, 1633 void PrerenderManager::Observe(int type,
1649 const content::NotificationSource& source, 1634 const content::NotificationSource& source,
1650 const content::NotificationDetails& details) { 1635 const content::NotificationDetails& details) {
1651 switch (type) { 1636 switch (type) {
1652 case chrome::NOTIFICATION_COOKIE_CHANGED: { 1637 case chrome::NOTIFICATION_COOKIE_CHANGED: {
1653 Profile* profile = content::Source<Profile>(source).ptr(); 1638 Profile* profile = content::Source<Profile>(source).ptr();
1654 if (!profile || !profile_->IsSameProfile(profile) || 1639 if (!profile || !profile_->IsSameProfile(profile) ||
1655 profile->IsOffTheRecord()) { 1640 profile->IsOffTheRecord()) {
1656 return; 1641 return;
1657 } 1642 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 if (!ActuallyPrerendering()) 1858 if (!ActuallyPrerendering())
1874 return; 1859 return;
1875 int64 recent_profile_bytes = 1860 int64 recent_profile_bytes =
1876 profile_network_bytes_ - last_recorded_profile_network_bytes_; 1861 profile_network_bytes_ - last_recorded_profile_network_bytes_;
1877 last_recorded_profile_network_bytes_ = profile_network_bytes_; 1862 last_recorded_profile_network_bytes_ = profile_network_bytes_;
1878 DCHECK_GE(recent_profile_bytes, 0); 1863 DCHECK_GE(recent_profile_bytes, 0);
1879 histograms_->RecordNetworkBytes( 1864 histograms_->RecordNetworkBytes(
1880 origin, used, prerender_bytes, recent_profile_bytes); 1865 origin, used, prerender_bytes, recent_profile_bytes);
1881 } 1866 }
1882 1867
1868 bool PrerenderManager::IsEnabled() const {
1869 DCHECK(CalledOnValidThread());
1870 if (!enabled_)
1871 return false;
1872 for (std::list<const PrerenderCondition*>::const_iterator it =
1873 prerender_conditions_.begin();
1874 it != prerender_conditions_.end();
1875 ++it) {
1876 const PrerenderCondition* condition = *it;
1877 if (!condition->CanPrerender())
1878 return false;
1879 }
1880 return true;
1881 }
1882
1883 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) { 1883 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) {
1884 DCHECK_GE(bytes, 0); 1884 DCHECK_GE(bytes, 0);
1885 if (IsEnabled() && ActuallyPrerendering()) 1885 if (IsEnabled() && ActuallyPrerendering())
1886 profile_network_bytes_ += bytes; 1886 profile_network_bytes_ += bytes;
1887 } 1887 }
1888 1888
1889 void PrerenderManager::OnCookieStoreLoaded() { 1889 void PrerenderManager::OnCookieStoreLoaded() {
1890 cookie_store_loaded_ = true; 1890 cookie_store_loaded_ = true;
1891 if (!on_cookie_store_loaded_cb_for_testing_.is_null()) 1891 if (!on_cookie_store_loaded_cb_for_testing_.is_null())
1892 on_cookie_store_loaded_cb_for_testing_.Run(); 1892 on_cookie_store_loaded_cb_for_testing_.Run();
(...skipping 23 matching lines...) Expand all
1916 content::RenderProcessHost* host) { 1916 content::RenderProcessHost* host) {
1917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1918 prerender_process_hosts_.erase(host); 1918 prerender_process_hosts_.erase(host);
1919 BrowserThread::PostTask( 1919 BrowserThread::PostTask(
1920 BrowserThread::IO, FROM_HERE, 1920 BrowserThread::IO, FROM_HERE,
1921 base::Bind(&PrerenderTracker::RemovePrerenderCookieStoreOnIOThread, 1921 base::Bind(&PrerenderTracker::RemovePrerenderCookieStoreOnIOThread,
1922 base::Unretained(prerender_tracker()), host->GetID(), false)); 1922 base::Unretained(prerender_tracker()), host->GetID(), false));
1923 } 1923 }
1924 1924
1925 } // namespace prerender 1925 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698