| 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 <string> | 9 #include <string> |
| 9 #include <vector> | |
| 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/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" | 15 #include "net/url_request/url_fetcher_delegate.h" |
| 16 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
| 17 | 17 |
| 18 namespace ntp_snippets { | 18 namespace ntp_snippets { |
| 19 | 19 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 bool is_stable_channel); | 30 bool is_stable_channel); |
| 31 ~NTPSnippetsFetcher() override; | 31 ~NTPSnippetsFetcher() override; |
| 32 | 32 |
| 33 // Adds a callback that is called when a new set of snippets are downloaded. | 33 // Adds a callback that is called when a new set of snippets are downloaded. |
| 34 scoped_ptr<SnippetsAvailableCallbackList::Subscription> AddCallback( | 34 scoped_ptr<SnippetsAvailableCallbackList::Subscription> AddCallback( |
| 35 const SnippetsAvailableCallback& callback) WARN_UNUSED_RESULT; | 35 const SnippetsAvailableCallback& callback) WARN_UNUSED_RESULT; |
| 36 | 36 |
| 37 // Fetches snippets from the server. |hosts| can be used to restrict the | 37 // Fetches snippets from the server. |hosts| can be used to restrict the |
| 38 // results to a set of hosts, e.g. "www.google.com". If it is empty, no | 38 // results to a set of hosts, e.g. "www.google.com". If it is empty, no |
| 39 // restrictions are applied. | 39 // restrictions are applied. |
| 40 void FetchSnippets(const std::vector<std::string>& hosts); | 40 void FetchSnippets(const std::set<std::string>& hosts); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 // URLFetcherDelegate implementation. | 43 // URLFetcherDelegate implementation. |
| 44 void OnURLFetchComplete(const net::URLFetcher* source) override; | 44 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 45 | 45 |
| 46 // The SequencedTaskRunner on which file system operations will be run. | 46 // The SequencedTaskRunner on which file system operations will be run. |
| 47 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 47 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 48 | 48 |
| 49 // Holds the URL request context. | 49 // Holds the URL request context. |
| 50 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 50 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 51 | 51 |
| 52 // The fetcher for downloading the snippets. | 52 // The fetcher for downloading the snippets. |
| 53 scoped_ptr<net::URLFetcher> url_fetcher_; | 53 scoped_ptr<net::URLFetcher> url_fetcher_; |
| 54 | 54 |
| 55 // The callbacks to notify when new snippets get fetched. | 55 // The callbacks to notify when new snippets get fetched. |
| 56 SnippetsAvailableCallbackList callback_list_; | 56 SnippetsAvailableCallbackList callback_list_; |
| 57 | 57 |
| 58 // Flag for picking the right (stable/non-stable) API key for Chrome Reader | 58 // Flag for picking the right (stable/non-stable) API key for Chrome Reader |
| 59 bool is_stable_channel_; | 59 bool is_stable_channel_; |
| 60 | 60 |
| 61 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; | 61 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); | 63 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); |
| 64 }; | 64 }; |
| 65 } // namespace ntp_snippets | 65 } // namespace ntp_snippets |
| 66 | 66 |
| 67 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ | 67 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ |
| OLD | NEW |