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

Unified Diff: components/ntp_snippets/breaking_news/subscription_manager.h

Issue 2922543002: [NTP::Push] Add Content Suggestions GCM App Handler (Closed)
Patch Set: Add missing dependency. Created 3 years, 6 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: components/ntp_snippets/breaking_news/subscription_manager.h
diff --git a/components/ntp_snippets/breaking_news/subscription_manager.h b/components/ntp_snippets/breaking_news/subscription_manager.h
index e30447d36432ebff63177ffedfe4fb33f977c0d2..9833611854293b252a7a9b494102d449c5886b91 100644
--- a/components/ntp_snippets/breaking_news/subscription_manager.h
+++ b/components/ntp_snippets/breaking_news/subscription_manager.h
@@ -14,34 +14,47 @@ class PrefRegistrySimple;
namespace ntp_snippets {
+// Class that wraps around the functionality of SubscriptionJsonRequest. It uses
+// the SubscriptionJsonRequest to send subscription and unsubscription requests
+// to the content suggestions server and does the bookkeeping for the data used
+// for subscription. Bookkeeping is required to detect any change (e.g. the
+// token render invalid), and resubscribe accordingly.
class SubscriptionManager {
public:
SubscriptionManager(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
PrefService* pref_service,
- const GURL& subscribe_url);
+ const GURL& subscribe_url,
+ const GURL& unsubscribe_url);
~SubscriptionManager();
void Subscribe(const std::string& token);
+ bool CanSubscribeNow();
void Unsubscribe(const std::string& token);
+ bool CanUnsubscribeNow();
+ bool IsSubscribed();
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
private:
std::string subscription_token_;
+ std::string unsubscription_token_;
// Holds the URL request context.
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
std::unique_ptr<internal::SubscriptionJsonRequest> subscription_request_;
+ std::unique_ptr<internal::SubscriptionJsonRequest> unsubscription_request_;
PrefService* pref_service_;
- // API endpoint for subscribing.
+ // API endpoint for subscribing and unsubscribing.
const GURL subscribe_url_;
+ const GURL unsubscribe_url_;
void DidSubscribe(const ntp_snippets::Status& status);
+ void DidUnsubscribe(const ntp_snippets::Status& status);
DISALLOW_COPY_AND_ASSIGN(SubscriptionManager);
};

Powered by Google App Engine
This is Rietveld 408576698