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

Side by Side Diff: ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.h

Issue 2350773002: Add a browsing data counter factory on iOS (Closed)
Patch Set: Addressed comments Created 4 years, 3 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 unified diff | Download patch
OLDNEW
(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 #ifndef IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_H_
6 #define IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/callback_forward.h"
12 #include "components/browsing_data/core/counters/browsing_data_counter.h"
13
14 class PrefService;
15
16 namespace ios {
17 class ChromeBrowserState;
18 }
19
20 // Wrapper around a browsing data volume counter that bridges the update counter
21 // UI callback to the UI.
22 class BrowsingDataCounterWrapper {
23 public:
24 using UpdateUICallback =
25 base::Callback<void(const browsing_data::BrowsingDataCounter::Result&)>;
26
27 // This method returns the counter corresponding to the data type specified by
28 // |pref_name| or null if there is no such counter.
29 static std::unique_ptr<BrowsingDataCounterWrapper> CreateCounterWrapper(
30 const char* pref_name,
31 ios::ChromeBrowserState* browser_state,
32 PrefService* pref_service,
33 const UpdateUICallback& update_ui_callback);
34
35 ~BrowsingDataCounterWrapper();
36
37 void RestartCounter();
38
39 private:
40 BrowsingDataCounterWrapper(
41 std::unique_ptr<browsing_data::BrowsingDataCounter> counter,
42 PrefService* pref_service,
43 const UpdateUICallback& update_ui_callback);
44
45 // Method to be passed as callback to the counter. This will be invoked when
46 // the result is ready.
47 void UpdateWithResult(
48 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result);
49
50 // The counter for which the interaction is managed by this wrapper.
51 std::unique_ptr<browsing_data::BrowsingDataCounter> counter_;
52
53 // Callback that updates the UI once the counter result is ready. This is
54 // invoked by UpdateWithResult.
55 UpdateUICallback update_ui_callback_;
56
57 DISALLOW_COPY_AND_ASSIGN(BrowsingDataCounterWrapper);
58 };
59
60 #endif // IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_
OLDNEW
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698