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

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h

Issue 2638413006: Add ContentSuggestionsMediator (Closed)
Patch Set: Fix Created 3 years, 11 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/content_suggestions/content_suggestions_service_bridge_observer.h
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h b/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6b29437b25d865310b796136bae928735f42356
--- /dev/null
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h
@@ -0,0 +1,50 @@
+// Copyright 2017 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_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDGE_OBSERVER_H_
+#define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDGE_OBSERVER_H_
+
+#include "components/ntp_snippets/content_suggestions_service.h"
+
+// Protocol duplicating all ContentSuggestionsService Observer methods in
+// Objective-C.
+@protocol ContentSuggestionsServiceBridgeObserver
marq (ping after 24h) 2017/01/27 12:44:55 Remove 'Bridge" from the protocol name.
gambard 2017/01/30 15:19:17 Done.
+
marq (ping after 24h) 2017/01/27 12:44:55 You still need comments for each method declaratio
gambard 2017/01/30 15:19:17 Done.
+- (void)onNewSuggestions:(ntp_snippets::Category)category;
marq (ping after 24h) 2017/01/27 12:44:55 The usual pattern for delegate and observer protoc
gambard 2017/01/30 15:19:17 Done.
+- (void)onCategory:(ntp_snippets::Category)category
+ statusChanged:(ntp_snippets::CategoryStatus)status;
+- (void)onSuggestionInvalidated:
+ (const ntp_snippets::ContentSuggestion::ID&)suggestion_id;
+- (void)onFullRefreshRequired;
+- (void)contentSuggestionsServiceShutdown;
+
+@end
+
+// Observer for the ContentSuggestionsService that translates all the callbacks
+// to Objective-C calls.
+class ContentSuggestionsServiceBridge
+ : public ntp_snippets::ContentSuggestionsService::Observer {
+ public:
+ ContentSuggestionsServiceBridge(
+ id<ContentSuggestionsServiceBridgeObserver> observer,
+ ntp_snippets::ContentSuggestionsService* service);
+ ~ContentSuggestionsServiceBridge() override;
+
+ private:
+ void OnNewSuggestions(ntp_snippets::Category category) override;
+ void OnCategoryStatusChanged(
+ ntp_snippets::Category category,
+ ntp_snippets::CategoryStatus new_status) override;
+ void OnSuggestionInvalidated(
+ const ntp_snippets::ContentSuggestion::ID& suggestion_id) override;
+ void OnFullRefreshRequired() override;
+ void ContentSuggestionsServiceShutdown() override;
+
+ __unsafe_unretained id<ContentSuggestionsServiceBridgeObserver> observer_;
+ ntp_snippets::ContentSuggestionsService* service_; // weak
+
+ DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsServiceBridge);
+};
+
+#endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDGE_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698