Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/browsing_data/cookie_counter.h" | |
| 6 | |
| 7 #include "chrome/browser/browsing_data/cookie_counting_helper.h" | |
| 8 #include "components/browsing_data/core/pref_names.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 | |
| 11 using content::BrowserThread; | |
| 12 | |
| 13 CookieCounter::CookieCounter(Profile* profile) | |
| 14 : profile_(profile), weak_ptr_factory_(this) {} | |
| 15 | |
| 16 CookieCounter::~CookieCounter() {} | |
| 17 | |
| 18 const char* CookieCounter::GetPrefName() const { | |
| 19 return browsing_data::prefs::kDeleteCookies; | |
| 20 } | |
| 21 | |
| 22 void CookieCounter::Count() { | |
| 23 base::Time begin = GetPeriodStart(); | |
| 24 auto done_callback = | |
| 25 base::Bind(&CookieCounter::Done, weak_ptr_factory_.GetWeakPtr()); | |
| 26 // Use a helper class that owns itself to avoid issues when CookieCounter is | |
| 27 // deleted before counting finished. | |
| 28 auto helper = new CookieCountingHelper(profile_, begin, done_callback); | |
| 29 helper->CountAndDestroySelfWhenFinished(); | |
| 30 } | |
| 31 | |
| 32 void CookieCounter::Done(int origin_count) { | |
| 33 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 34 ReportResult(origin_count); | |
| 35 } | |
| OLD | NEW |