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

Side by Side Diff: chrome/browser/interests/interests_retriever.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: 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_RETRIEVER_H_
6 #define CHROME_BROWSER_INTERESTS_INTERESTS_RETRIEVER_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"
18
19 FORWARD_DECLARE_TEST(InterestsRetrieverTest, DefaultFakeResponse);
20
21 class InterestsRetriever : public net::URLFetcherDelegate {
Marc Treib 2015/09/03 13:54:55 Please add a comment explaining what this class do
tache 2015/09/03 15:21:52 Done.
22 public:
23 struct Interest {
24 std::string name;
25 std::string image_url;
26 double relevance;
27
28 bool operator==(const Interest& interest) const;
29 };
30
31 typedef base::Callback<void(std::vector<Interest>)>
Marc Treib 2015/09/03 13:54:55 should the param be a const vector& ?
tache 2015/09/03 15:21:52 Done.
32 InterestsCallback;
33
34 InterestsRetriever(net::URLRequestContextGetter* url_request_context,
35 const std::string& access_token,
36 const InterestsCallback& callback,
37 net::URLFetcherFactory* url_fetcher_factory);
38
39 ~InterestsRetriever() override;
40
41 private:
42 FRIEND_TEST_ALL_PREFIXES(::InterestsRetrieverTest, DefaultFakeResponse);
43
44 // net::URLFetcherDelegate implementation.
45 void OnURLFetchComplete(const net::URLFetcher* source) override;
46
47 scoped_ptr<net::URLFetcher> CreateFetcher();
48
49 // parse the json response
50 std::vector<Interest> ExtractInterests(const std::string& response);
51
52 /*
Marc Treib 2015/09/03 13:54:55 nit: /* */ are quite uncommon in chromium code.
tache 2015/09/03 15:21:52 Done.
53 * Currently the InterestsRetreiever servers a static response since the API
54 * is not ready yet.
55 * This method is needed to access the static response in tests.
56 *
57 * TODO(tache): Remove this once the API is ready.
58 */
59 static std::string GetFakeResponseForTest();
60
61 net::URLRequestContextGetter* url_request_context_;
62
63 std::string access_token_;
64
65 InterestsCallback callback_;
66
67 scoped_ptr<net::URLFetcher> fetcher_;
68
69 net::URLFetcherFactory* url_fetcher_factory_;
70
71
72 DISALLOW_COPY_AND_ASSIGN(InterestsRetriever);
73 };
74
75 #endif // CHROME_BROWSER_INTERESTS_INTERESTS_RETRIEVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698