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

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: 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.h"
sdefresne 2016/09/19 17:07:52 I think you can include base/callback_forward.h he
ioanap 2016/09/20 09:36:48 Done.
12 #include "components/browsing_data/core/counters/browsing_data_counter.h"
sdefresne 2016/09/19 17:07:52 You don't call any method of BrowsingDataCounter i
ioanap 2016/09/20 09:36:48 I don't call any method, but I need a nested class
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 typedef base::Callback<void(
sdefresne 2016/09/19 17:07:52 nit: I think using is recommended instead of typed
ioanap 2016/09/20 09:36:48 Didn't know that. Thank you!
25 const browsing_data::BrowsingDataCounter::Result&)>
26 UpdateUICallback;
27
28 // This method returns a nullptr if there is no corresponding counter for the
29 // data type specified by the |pref_name|.
30 static BrowsingDataCounterWrapper* CreateCounterWrapper(
sdefresne 2016/09/19 17:07:52 Why is this method not returning a std::unique_ptr
ioanap 2016/09/20 09:36:48 Done.
31 const char* pref_name,
32 ios::ChromeBrowserState* browser_state,
33 PrefService* pref_service,
34 const UpdateUICallback update_ui_callback);
sdefresne 2016/09/19 17:07:52 const UpdateUICallback& update_ui_callback
ioanap 2016/09/20 09:36:48 Done.
35
36 ~BrowsingDataCounterWrapper();
37
38 void RestartCounter();
39
40 private:
41 BrowsingDataCounterWrapper(
42 std::unique_ptr<browsing_data::BrowsingDataCounter> counter,
43 PrefService* pref_service,
44 const UpdateUICallback& update_ui_callback);
45
46 // Method to be passed as callback to the counter. This will be invoked when
47 // the result is ready.
48 void UpdateWithResult(
49 std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result);
50
51 // The counter for which the interaction is managed by this wrapper.
52 std::unique_ptr<browsing_data::BrowsingDataCounter> counter_;
53
54 // Callback that updates the UI once the counter result is ready. This is
55 // invoked by UpdateWithResult.
56 UpdateUICallback update_ui_callback_;
57 };
sdefresne 2016/09/19 17:07:52 DISALLOW_COPY_AND_ASSIGN()?
ioanap 2016/09/20 09:36:48 Done.
58
59 #endif // IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698