Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 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 "ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.h" | |
| 6 | |
| 7 #include "components/prefs/pref_service.h" | |
| 8 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | |
| 9 #include "ios/chrome/browser/browsing_data/ios_browsing_data_counter_factory.h" | |
| 10 | |
| 11 // static | |
| 12 BrowsingDataCounterWrapper* BrowsingDataCounterWrapper::CreateCounterWrapper( | |
| 13 const char* pref_name, | |
| 14 ios::ChromeBrowserState* browser_state, | |
| 15 PrefService* pref_service, | |
| 16 const UpdateUICallback update_ui_callback) { | |
| 17 std::unique_ptr<browsing_data::BrowsingDataCounter> counter = | |
| 18 IOSBrowsingDataCounterFactory::GetForBrowserStateAndPref(browser_state, | |
| 19 pref_name); | |
| 20 if (!counter) | |
| 21 return nullptr; | |
| 22 return new BrowsingDataCounterWrapper(std::move(counter), pref_service, | |
| 23 update_ui_callback); | |
| 24 } | |
| 25 | |
| 26 BrowsingDataCounterWrapper::BrowsingDataCounterWrapper( | |
| 27 std::unique_ptr<browsing_data::BrowsingDataCounter> counter, | |
| 28 PrefService* pref_service, | |
| 29 const UpdateUICallback& update_ui_callback) | |
| 30 : counter_(std::move(counter)), update_ui_callback_(update_ui_callback) { | |
| 31 counter_->Init(pref_service, | |
| 32 base::Bind(&BrowsingDataCounterWrapper::UpdateWithResult, | |
| 33 base::Unretained(this))); | |
| 34 } | |
| 35 | |
| 36 void BrowsingDataCounterWrapper::RestartCounter() { | |
| 37 counter_->Restart(); | |
| 38 } | |
| 39 | |
| 40 void BrowsingDataCounterWrapper::UpdateWithResult( | |
| 41 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { | |
| 42 update_ui_callback_.Run(*result.get()); | |
| 43 } | |
| 44 | |
| 45 BrowsingDataCounterWrapper::~BrowsingDataCounterWrapper() {} | |
|
sdefresne
2016/09/19 17:07:52
nit: Can you put method implementation in the same
ioanap
2016/09/20 09:36:48
Done.
| |
| OLD | NEW |