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

Side by Side Diff: ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h

Issue 2638413006: Add ContentSuggestionsMediator (Closed)
Patch Set: Format Created 3 years, 10 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 2017 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_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDG E_OBSERVER_H_
6 #define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BRIDG E_OBSERVER_H_
7
8 #include "components/ntp_snippets/content_suggestions_service.h"
9
10 // Observes ContentSuggestionsService events from Objective-C. To use as a
11 // ntp_snippets::ContentSuggestionsService::Observer, wrap in a
12 // ContentSuggestionsServiceBridge.
13 @protocol ContentSuggestionsServiceObserver
14
15 // Invoked by ntp_snippets::ContentSuggestionsService::OnNewSuggestions.
16 - (void)contentSuggestionsService:
17 (ntp_snippets::ContentSuggestionsService*)suggestionsService
18 newSuggestionsInCategory:(ntp_snippets::Category)category;
19
20 // Invoked by ntp_snippets::ContentSuggestionsService::OnCategoryStatusChanged.
21 - (void)contentSuggestionsService:
22 (ntp_snippets::ContentSuggestionsService*)suggestionsService
23 category:(ntp_snippets::Category)category
24 statusChangedTo:(ntp_snippets::CategoryStatus)status;
25
26 // Invoked by ntp_snippets::ContentSuggestionsService::OnSuggestionInvalidated.
27 - (void)contentSuggestionsService:
28 (ntp_snippets::ContentSuggestionsService*)suggestionsService
29 SuggestionInvalidated:
30 (const ntp_snippets::ContentSuggestion::ID&)suggestion_id;
31
32 // Invoked by ntp_snippets::ContentSuggestionsService::OnFullRefreshRequired.
33 - (void)contentSuggestionsServiceFullRefreshRequired:
34 (ntp_snippets::ContentSuggestionsService*)suggestionsService;
35
36 // Invoked by
37 // ntp_snippets::ContentSuggestionsService::ContentSuggestionsServiceShutdown.
38 - (void)contentSuggestionsServiceShutdown:
39 (ntp_snippets::ContentSuggestionsService*)suggestionsService;
40
41 @end
42
43 // Observer for the ContentSuggestionsService that translates all the callbacks
44 // to Objective-C calls.
45 class ContentSuggestionsServiceBridge
46 : public ntp_snippets::ContentSuggestionsService::Observer {
47 public:
48 ContentSuggestionsServiceBridge(
49 id<ContentSuggestionsServiceObserver> observer,
50 ntp_snippets::ContentSuggestionsService* service);
51 ~ContentSuggestionsServiceBridge() override;
52
53 private:
54 void OnNewSuggestions(ntp_snippets::Category category) override;
55 void OnCategoryStatusChanged(
56 ntp_snippets::Category category,
57 ntp_snippets::CategoryStatus new_status) override;
58 void OnSuggestionInvalidated(
59 const ntp_snippets::ContentSuggestion::ID& suggestion_id) override;
60 void OnFullRefreshRequired() override;
61 void ContentSuggestionsServiceShutdown() override;
62
63 __unsafe_unretained id<ContentSuggestionsServiceObserver> observer_;
64 ntp_snippets::ContentSuggestionsService* service_; // weak
65
66 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsServiceBridge);
67 };
68
69 #endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_SERVICE_BR IDGE_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698