Chromium Code Reviews| Index: components/ntp_snippets/breaking_news/breaking_news_subscription_manager.cc |
| diff --git a/components/ntp_snippets/breaking_news/breaking_news_subscription_manager.cc b/components/ntp_snippets/breaking_news/breaking_news_subscription_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b4bc3f43d96a6849c05d1cf8f789508e645a45bc |
| --- /dev/null |
| +++ b/components/ntp_snippets/breaking_news/breaking_news_subscription_manager.cc |
| @@ -0,0 +1,39 @@ |
| +// 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. |
| + |
| +#include "components/ntp_snippets/breaking_news/breaking_news_subscription_manager.h" |
| +#include "base/bind.h" |
| +#include "components/ntp_snippets/breaking_news/subscription_json_request.h" |
| + |
| +namespace ntp_snippets { |
| + |
| +using internal::SubscriptionJsonRequest; |
| + |
| +BreakingNewsSubscriptionManager::BreakingNewsSubscriptionManager( |
| + scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) |
| + : url_request_context_getter_(std::move(url_request_context_getter)) {} |
| + |
| +void BreakingNewsSubscriptionManager::Subscribe(const std::string& token) { |
| + SubscriptionJsonRequest::Builder builder; |
| + builder.SetToken(token) |
| + .SetUrlRequestContextGetter(url_request_context_getter_) |
| + .SetUrl(subscribe_url_); |
| + |
| + std::unique_ptr<SubscriptionJsonRequest> request = builder.Build(); |
| + SubscriptionJsonRequest* raw_request = request.get(); |
| + raw_request->Start( |
| + base::BindOnce(&BreakingNewsSubscriptionManager::SubscribeDone, |
| + base::Unretained(this), std::move(request))); |
|
fhorschig
2017/06/02 09:11:49
I see that you did, what I did. Having aged 6 mont
mamir
2017/06/04 10:17:03
I have changed the design as per our offline discu
|
| +} |
| + |
| +void BreakingNewsSubscriptionManager::SubscribeDone( |
| + std::unique_ptr<SubscriptionJsonRequest> request, |
| + const ntp_snippets::Status& status) { |
| + // TODO(mamir): Handle success and failure cases. |
| +} |
| + |
| +void BreakingNewsSubscriptionManager::Unsubscribe(const std::string& token) { |
| + // TODO(mamir): Implement. |
| +} |
| +} // namespace ntp_snippets |