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

Side by Side Diff: chrome/browser/interests/interests_fetcher.h

Issue 1317513004: Add InterestsFetcher which retrieves a user's interests from the server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed the use of FakeURLFetcher Created 5 years, 3 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_INTERESTS_INTERESTS_FETCHER_H_
6 #define CHROME_BROWSER_INTERESTS_INTERESTS_FETCHER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "net/url_request/url_fetcher.h"
16 #include "net/url_request/url_fetcher_delegate.h"
17 #include "net/url_request/url_fetcher_factory.h"
Marc Treib 2015/09/22 12:02:59 Not needed anymore
tache 2015/09/29 09:33:34 Done.
18
19 FORWARD_DECLARE_TEST(InterestsFetcherTest, DefaultFakeResponse);
Marc Treib 2015/09/22 12:02:59 not needed anymore (test doesn't exist anymore)
tache 2015/09/29 09:33:34 Done.
20
21 // Class to asynchronously retrieve the topics of interests for a user.
22 // Authentication is done using the user's OAuth access_token.
23 //
24 // The user of this class is responsible of ensuring that the instance is
25 // deleted only after the callback has been called.
Marc Treib 2015/09/22 12:02:59 This sounds like bad things will happen if you del
tache 2015/09/29 09:33:34 Done.
26 //
27 // Example Usage:
28 //
29 // auto request = make_scoped_ptr(new InterestsFetcher(
30 // "user_access_token",
31 // callback));
32 //
33 class InterestsFetcher : public net::URLFetcherDelegate {
34 public:
35 struct Interest {
36 std::string name;
37 std::string image_url;
38 double relevance;
39
40 bool operator==(const Interest& interest) const;
41 };
42
43 typedef base::Callback<void(const std::vector<Interest>&)>
44 InterestsCallback;
45
46 InterestsFetcher(net::URLRequestContextGetter* url_request_context,
47 const std::string& access_token);
Marc Treib 2015/09/22 12:02:59 nit: alignment
tache 2015/09/29 09:33:34 Done.
48
49 void Start(const InterestsCallback& callback);
50
51 ~InterestsFetcher() override;
52
53 private:
54 FRIEND_TEST_ALL_PREFIXES(::InterestsFetcherTest, DefaultFakeResponse);
Marc Treib 2015/09/22 12:02:59 not needed anymore
tache 2015/09/29 09:33:34 Done.
55
56 // net::URLFetcherDelegate implementation.
57 void OnURLFetchComplete(const net::URLFetcher* source) override;
58
59 scoped_ptr<net::URLFetcher> CreateFetcher();
60
61 // parse the json response
62 std::vector<Interest> ExtractInterests(const std::string& response);
63
64 net::URLRequestContextGetter* url_request_context_;
65
66 std::string access_token_;
67
68 InterestsCallback callback_;
69
70 scoped_ptr<net::URLFetcher> fetcher_;
71
72
73 DISALLOW_COPY_AND_ASSIGN(InterestsFetcher);
74 };
75
76 #endif // CHROME_BROWSER_INTERESTS_INTERESTS_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/interests/interests_fetcher.cc » ('j') | chrome/browser/interests/interests_fetcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698