Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/callback_list.h" | 12 #include "base/callback_list.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 | 18 |
| 19 namespace ntp_snippets { | 19 namespace ntp_snippets { |
| 20 | 20 |
| 21 // Fetches snippet data for the NTP from the server | 21 // Fetches snippet data for the NTP from the server |
| 22 class NTPSnippetsFetcher : public net::URLFetcherDelegate { | 22 class NTPSnippetsFetcher : public net::URLFetcherDelegate { |
| 23 public: | 23 public: |
| 24 using SnippetsAvailableCallback = base::Callback<void(const std::string&)>; | 24 // If problems occur (explained in status_message), snippets_json is empty. |
|
Bernhard Bauer
2016/04/22 09:42:17
Put variable names in comments between |pipe| symb
jkrcal
2016/04/22 11:11:59
Done.
| |
| 25 // Otherwise, status_message is empty. | |
| 26 using SnippetsAvailableCallback = | |
| 27 base::Callback<void(const std::string& snippets_json, | |
| 28 const std::string& status_message)>; | |
| 25 using SnippetsAvailableCallbackList = | 29 using SnippetsAvailableCallbackList = |
| 26 base::CallbackList<void(const std::string&)>; | 30 base::CallbackList<void(const std::string&, const std::string&)>; |
| 27 | 31 |
| 28 NTPSnippetsFetcher( | 32 NTPSnippetsFetcher( |
| 29 scoped_refptr<base::SequencedTaskRunner> file_task_runner, | 33 scoped_refptr<base::SequencedTaskRunner> file_task_runner, |
| 30 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 34 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
| 31 bool is_stable_channel); | 35 bool is_stable_channel); |
| 32 ~NTPSnippetsFetcher() override; | 36 ~NTPSnippetsFetcher() override; |
| 33 | 37 |
| 34 // Adds a callback that is called when a new set of snippets are downloaded. | 38 // Adds a callback that is called when a new set of snippets are downloaded. |
| 35 scoped_ptr<SnippetsAvailableCallbackList::Subscription> AddCallback( | 39 scoped_ptr<SnippetsAvailableCallbackList::Subscription> AddCallback( |
| 36 const SnippetsAvailableCallback& callback) WARN_UNUSED_RESULT; | 40 const SnippetsAvailableCallback& callback) WARN_UNUSED_RESULT; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 57 SnippetsAvailableCallbackList callback_list_; | 61 SnippetsAvailableCallbackList callback_list_; |
| 58 | 62 |
| 59 // Flag for picking the right (stable/non-stable) API key for Chrome Reader | 63 // Flag for picking the right (stable/non-stable) API key for Chrome Reader |
| 60 bool is_stable_channel_; | 64 bool is_stable_channel_; |
| 61 | 65 |
| 62 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); | 66 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); |
| 63 }; | 67 }; |
| 64 } // namespace ntp_snippets | 68 } // namespace ntp_snippets |
| 65 | 69 |
| 66 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ | 70 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ |
| OLD | NEW |