Skip to content

Commit

Permalink
net: Remove code for session cookie deletion experiment.
Browse files Browse the repository at this point in the history
The original experiment attempted to measure the effect of deleting session
cookies at shutdown on startup time. This experiment was flawed, because there
are several cases where Chrome doesn't want to delete session cookies during
shutdown.

BUG=488314

Review URL: https://codereview.chromium.org/1333033002

Cr-Commit-Position: refs/heads/master@{#348252}
  • Loading branch information
erikchen authored and Commit bot committed Sep 10, 2015
1 parent fd78c76 commit abb548f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
37 changes: 1 addition & 36 deletions net/extras/sqlite/sqlite_persistent_cookie_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_macros.h"
#include "base/profiler/scoped_tracker.h"
#include "base/sequenced_task_runner.h"
Expand Down Expand Up @@ -45,15 +44,6 @@ namespace {
// CPU or I/O with these low priority requests immediately after start up.
const int kLoadDelayMilliseconds = 0;

const char kDeleteAtShutdown[] = "DeleteAtShutdown";
const char kSessionCookieDeletionStrategy[] = "SessionCookieDeletionStrategy";

bool ShouldDeleteSessionCookiesAtShutdown() {
const std::string group_name =
base::FieldTrialList::FindFullName(kSessionCookieDeletionStrategy);
return group_name == kDeleteAtShutdown;
}

} // namespace

namespace net {
Expand Down Expand Up @@ -89,9 +79,7 @@ class SQLitePersistentCookieStore::Backend
const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
bool restore_old_session_cookies,
CookieCryptoDelegate* crypto_delegate)
: delete_session_cookies_at_shutdown_(
ShouldDeleteSessionCookiesAtShutdown()),
path_(path),
: path_(path),
num_pending_(0),
initialized_(false),
corruption_detected_(false),
Expand Down Expand Up @@ -226,8 +214,6 @@ class SQLitePersistentCookieStore::Backend

void DeleteSessionCookiesOnStartup();

void DeleteSessionCookiesOnShutdown();

void BackgroundDeleteAllInList(const std::list<CookieOrigin>& cookies);

void DatabaseErrorCallback(int error, sql::Statement* stmt);
Expand All @@ -243,7 +229,6 @@ class SQLitePersistentCookieStore::Backend
void FinishedLoadingCookies(const LoadedCallback& loaded_callback,
bool success);

bool delete_session_cookies_at_shutdown_;
const base::FilePath path_;
scoped_ptr<sql::Connection> db_;
sql::MetaTable meta_table_;
Expand Down Expand Up @@ -1193,10 +1178,6 @@ void SQLitePersistentCookieStore::Backend::Close(
void SQLitePersistentCookieStore::Backend::InternalBackgroundClose(
const base::Closure& callback) {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());

if (delete_session_cookies_at_shutdown_)
DeleteSessionCookiesOnShutdown();

// Commit any pending operations
Commit();

Expand Down Expand Up @@ -1271,22 +1252,6 @@ void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() {
db_->GetLastChangeCount());
}

void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnShutdown() {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());

if (!db_)
return;

base::Time start_time = base::Time::Now();
if (!db_->Execute("DELETE FROM cookies WHERE persistent != 1"))
LOG(WARNING) << "Unable to delete session cookies.";

UMA_HISTOGRAM_TIMES("Cookie.Shutdown.TimeSpentDeletingCookies",
base::Time::Now() - start_time);
UMA_HISTOGRAM_COUNTS("Cookie.Shutdown.NumberOfCookiesDeleted",
db_->GetLastChangeCount());
}

void SQLitePersistentCookieStore::Backend::BackgroundDeleteAllInList(
const std::list<CookieOrigin>& cookies) {
DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
Expand Down
6 changes: 6 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4968,6 +4968,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>

<histogram name="Cookie.Shutdown.NumberOfCookiesDeleted">
<obsolete>
Deprecated as of 9/2015. The associated experiment was flawed.
</obsolete>
<owner>erikchen@chromium.org</owner>
<summary>
The number of session cookies deleted on shutdown. This metric is emitted
Expand All @@ -4976,6 +4979,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>

<histogram name="Cookie.Shutdown.TimeSpentDeletingCookies" units="ms">
<obsolete>
Deprecated as of 9/2015. The associated experiment was flawed.
</obsolete>
<owner>erikchen@chromium.org</owner>
<summary>
The amount of time required to delete session cookies on shutdown. This
Expand Down

0 comments on commit abb548f

Please sign in to comment.