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

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

Issue 2546153002: Revert of Prerender: Hardcode the Silence experiment date (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 return; 1254 return;
1255 int64_t recent_profile_bytes = 1255 int64_t recent_profile_bytes =
1256 profile_network_bytes_ - last_recorded_profile_network_bytes_; 1256 profile_network_bytes_ - last_recorded_profile_network_bytes_;
1257 last_recorded_profile_network_bytes_ = profile_network_bytes_; 1257 last_recorded_profile_network_bytes_ = profile_network_bytes_;
1258 DCHECK_GE(recent_profile_bytes, 0); 1258 DCHECK_GE(recent_profile_bytes, 0);
1259 histograms_->RecordNetworkBytes( 1259 histograms_->RecordNetworkBytes(
1260 origin, used, prerender_bytes, recent_profile_bytes); 1260 origin, used, prerender_bytes, recent_profile_bytes);
1261 } 1261 }
1262 1262
1263 bool PrerenderManager::IsPrerenderSilenceExperiment(Origin origin) const { 1263 bool PrerenderManager::IsPrerenderSilenceExperiment(Origin origin) const {
1264 if (origin == ORIGIN_OFFLINE || 1264 if (origin == ORIGIN_OFFLINE)
1265 origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR) {
1266 return false; 1265 return false;
1267 }
1268 1266
1269 // The group name should contain expiration time formatted as: 1267 // The group name should contain expiration time formatted as:
1270 // "ExperimentYes_expires_YYYY-MM-DDTHH:MM:SSZ". 1268 // "ExperimentYes_expires_YYYY-MM-DDTHH:MM:SSZ".
1271 std::string group_name = 1269 std::string group_name =
1272 base::FieldTrialList::FindFullName("PrerenderSilence"); 1270 base::FieldTrialList::FindFullName("PrerenderSilence");
1273 const char kExperimentPrefix[] = "ExperimentYes"; 1271 const char kExperimentPrefix[] = "ExperimentYes";
1274 if (!base::StartsWith(group_name, kExperimentPrefix, 1272 if (!base::StartsWith(group_name, kExperimentPrefix,
1275 base::CompareCase::INSENSITIVE_ASCII)) { 1273 base::CompareCase::INSENSITIVE_ASCII)) {
1276 // The experiment group was not set, use 2016-12-14 PST as the day of the
1277 // experiment.
1278 base::Time experiment_start;
1279 if (!base::Time::FromString("2016-12-14-08:00:00Z", &experiment_start))
1280 NOTREACHED();
1281 base::Time current_time = GetCurrentTime();
1282 if ((experiment_start <= current_time) &&
1283 (current_time < experiment_start + base::TimeDelta::FromDays(1))) {
1284 return true;
1285 }
1286 return false; 1274 return false;
1287 } 1275 }
1288 const char kExperimentPrefixWithExpiration[] = "ExperimentYes_expires_"; 1276 const char kExperimentPrefixWithExpiration[] = "ExperimentYes_expires_";
1289 if (!base::StartsWith(group_name, kExperimentPrefixWithExpiration, 1277 if (!base::StartsWith(group_name, kExperimentPrefixWithExpiration,
1290 base::CompareCase::INSENSITIVE_ASCII)) { 1278 base::CompareCase::INSENSITIVE_ASCII)) {
1291 // Without expiration day in the group name, behave as a normal experiment, 1279 // Without expiration day in the group name, behave as a normal experiment,
1292 // i.e. sticky to the Chrome session. 1280 // i.e. sticky to the Chrome session.
1293 return true; 1281 return true;
1294 } 1282 }
1295 base::Time expiration_time; 1283 base::Time expiration_time;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 return weak_factory_.GetWeakPtr(); 1361 return weak_factory_.GetWeakPtr();
1374 } 1362 }
1375 1363
1376 void PrerenderManager::SetPrerenderContentsFactoryForTest( 1364 void PrerenderManager::SetPrerenderContentsFactoryForTest(
1377 PrerenderContents::Factory* prerender_contents_factory) { 1365 PrerenderContents::Factory* prerender_contents_factory) {
1378 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1366 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1379 prerender_contents_factory_.reset(prerender_contents_factory); 1367 prerender_contents_factory_.reset(prerender_contents_factory);
1380 } 1368 }
1381 1369
1382 } // namespace prerender 1370 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698