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

Unified Diff: chrome/browser/browsing_data/cookie_counter.cc

Issue 2594723002: Count number of origins with data affected by clearing "cookies and site data". (Closed)
Patch Set: Add comments for issues with incomplete data deletion Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/cookie_counter.cc
diff --git a/chrome/browser/browsing_data/cookie_counter.cc b/chrome/browser/browsing_data/cookie_counter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d9879ce4774831ef4d8db464b999bdf3370fb051
--- /dev/null
+++ b/chrome/browser/browsing_data/cookie_counter.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
msramek 2017/01/09 12:54:43 Ditto.
dullweber 2017/01/09 16:05:46 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/browsing_data/cookie_counter.h"
+
+#include "chrome/browser/browsing_data/cookie_counting_helper.h"
+#include "components/browsing_data/core/pref_names.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+CookieCounter::CookieCounter(Profile* profile)
+ : profile_(profile), weak_ptr_factory_(this) {}
+
+CookieCounter::~CookieCounter() {}
+
+const char* CookieCounter::GetPrefName() const {
+ return browsing_data::prefs::kDeleteCookies;
+}
+
+void CookieCounter::Count() {
+ base::Time begin = GetPeriodStart();
+ auto done_callback =
+ base::Bind(&CookieCounter::Done, weak_ptr_factory_.GetWeakPtr());
+ // Use a helper class that owns itself to avoid issues when CookieCounter is
+ // deleted before counting finished.
+ auto helper = new CookieCountingHelper(profile_, begin, done_callback);
+ helper->CountAndDestroySelfWhenFinished();
+}
+
+void CookieCounter::Done(int origin_count) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ ReportResult(origin_count);
+}

Powered by Google App Engine
This is Rietveld 408576698