Chromium Code Reviews| 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); |
| +} |