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

Side by Side Diff: components/ntp_snippets/ntp_snippets_fetcher.h

Issue 1918083002: Convert //components/[f-n]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: … Created 4 years, 8 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
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 <memory>
8 #include <set> 9 #include <set>
9 #include <string> 10 #include <string>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/callback_list.h" 13 #include "base/callback_list.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 // If problems occur (explained in |status_message|), |snippets_json| is 24 // If problems occur (explained in |status_message|), |snippets_json| is
25 // empty; otherwise, |status_message| is empty. 25 // empty; otherwise, |status_message| is empty.
26 using SnippetsAvailableCallback = 26 using SnippetsAvailableCallback =
27 base::Callback<void(const std::string& snippets_json, 27 base::Callback<void(const std::string& snippets_json,
28 const std::string& status_message)>; 28 const std::string& status_message)>;
29 using SnippetsAvailableCallbackList = 29 using SnippetsAvailableCallbackList =
30 base::CallbackList<void(const std::string&, const std::string&)>; 30 base::CallbackList<void(const std::string&, const std::string&)>;
31 31
32 NTPSnippetsFetcher( 32 NTPSnippetsFetcher(
33 scoped_refptr<base::SequencedTaskRunner> file_task_runner, 33 scoped_refptr<base::SequencedTaskRunner> file_task_runner,
34 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, 34 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
35 bool is_stable_channel); 35 bool is_stable_channel);
36 ~NTPSnippetsFetcher() override; 36 ~NTPSnippetsFetcher() override;
37 37
38 // 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.
39 scoped_ptr<SnippetsAvailableCallbackList::Subscription> AddCallback( 39 std::unique_ptr<SnippetsAvailableCallbackList::Subscription> AddCallback(
40 const SnippetsAvailableCallback& callback) WARN_UNUSED_RESULT; 40 const SnippetsAvailableCallback& callback) WARN_UNUSED_RESULT;
41 41
42 // Fetches snippets from the server. |hosts| can be used to restrict the 42 // Fetches snippets from the server. |hosts| can be used to restrict the
43 // results to a set of hosts, e.g. "www.google.com". If it is empty, no 43 // results to a set of hosts, e.g. "www.google.com". If it is empty, no
44 // restrictions are applied. 44 // restrictions are applied.
45 void FetchSnippets(const std::set<std::string>& hosts, int count); 45 void FetchSnippets(const std::set<std::string>& hosts, int count);
46 46
47 private: 47 private:
48 // URLFetcherDelegate implementation. 48 // URLFetcherDelegate implementation.
49 void OnURLFetchComplete(const net::URLFetcher* source) override; 49 void OnURLFetchComplete(const net::URLFetcher* source) override;
50 50
51 // The SequencedTaskRunner on which file system operations will be run. 51 // The SequencedTaskRunner on which file system operations will be run.
52 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 52 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
53 53
54 // Holds the URL request context. 54 // Holds the URL request context.
55 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 55 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
56 56
57 // The fetcher for downloading the snippets. 57 // The fetcher for downloading the snippets.
58 scoped_ptr<net::URLFetcher> url_fetcher_; 58 std::unique_ptr<net::URLFetcher> url_fetcher_;
59 59
60 // The callbacks to notify when new snippets get fetched. 60 // The callbacks to notify when new snippets get fetched.
61 SnippetsAvailableCallbackList callback_list_; 61 SnippetsAvailableCallbackList callback_list_;
62 62
63 // 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
64 bool is_stable_channel_; 64 bool is_stable_channel_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); 66 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
67 }; 67 };
68 } // namespace ntp_snippets 68 } // namespace ntp_snippets
69 69
70 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ 70 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
OLDNEW
« no previous file with comments | « components/network_time/network_time_tracker_unittest.cc ('k') | components/ntp_snippets/ntp_snippets_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698