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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.h
diff --git a/ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.h b/ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..124a2900737639ce4b4c360717b92cf462d3635f
--- /dev/null
+++ b/ios/chrome/browser/browsing_data/browsing_data_counter_wrapper.h
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_H_
+#define IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_H_
+
+#include <memory>
+#include <string>
+
+#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.
+#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
+
+class PrefService;
+
+namespace ios {
+class ChromeBrowserState;
+}
+
+// Wrapper around a browsing data volume counter that bridges the update counter
+// UI callback to the UI.
+class BrowsingDataCounterWrapper {
+ public:
+ 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!
+ const browsing_data::BrowsingDataCounter::Result&)>
+ UpdateUICallback;
+
+ // This method returns a nullptr if there is no corresponding counter for the
+ // data type specified by the |pref_name|.
+ 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.
+ const char* pref_name,
+ ios::ChromeBrowserState* browser_state,
+ PrefService* pref_service,
+ 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.
+
+ ~BrowsingDataCounterWrapper();
+
+ void RestartCounter();
+
+ private:
+ BrowsingDataCounterWrapper(
+ std::unique_ptr<browsing_data::BrowsingDataCounter> counter,
+ PrefService* pref_service,
+ const UpdateUICallback& update_ui_callback);
+
+ // Method to be passed as callback to the counter. This will be invoked when
+ // the result is ready.
+ void UpdateWithResult(
+ std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result);
+
+ // The counter for which the interaction is managed by this wrapper.
+ std::unique_ptr<browsing_data::BrowsingDataCounter> counter_;
+
+ // Callback that updates the UI once the counter result is ready. This is
+ // invoked by UpdateWithResult.
+ UpdateUICallback update_ui_callback_;
+};
sdefresne 2016/09/19 17:07:52 DISALLOW_COPY_AND_ASSIGN()?
ioanap 2016/09/20 09:36:48 Done.
+
+#endif // IOS_CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_WRAPPER_

Powered by Google App Engine
This is Rietveld 408576698