Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
Marc Treib
2015/09/03 09:04:37
WHAT YEAR IS THIS?! :D
tache
2015/09/03 13:26:29
Done.
| |
| 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> | |
|
Marc Treib
2015/09/03 09:04:37
Quotes instead of angle brackets for non-stdlib in
tache
2015/09/03 13:26:29
Eclipse "organize imports" is so broken...
Done.
| |
| 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 namespace net { | |
| 20 class URLFetcher; | |
|
Marc Treib
2015/09/03 09:04:37
Either include or forward declare, not both.
tache
2015/09/03 13:26:29
Done.
| |
| 21 class URLRequestContextGetter; | |
| 22 } // namespace net | |
| 23 | |
| 24 FORWARD_DECLARE_TEST(InterestsRetrieverTest, DefaultFakeResponse); | |
|
Marc Treib
2015/09/03 09:04:37
Is this required? I don't think I've ever seen thi
tache
2015/09/03 13:26:29
https://code.google.com/p/chromium/codesearch#chro
Marc Treib
2015/09/03 13:54:55
Generally it doesn't need to be forward-declared,
| |
| 25 | |
| 26 class InterestsRetriever : public net::URLFetcherDelegate { | |
| 27 public: | |
| 28 struct Interest { | |
| 29 std::string name; | |
| 30 std::string image_url; | |
| 31 double relevance; | |
| 32 | |
| 33 bool operator==(const Interest &interest) const { | |
|
Marc Treib
2015/09/03 09:04:37
Do you actually need this operator? If so, please
tache
2015/09/03 13:26:29
Only used for testing atm.
Moved it to the .cc fi
Marc Treib
2015/09/03 13:54:55
Then you could also move it to the test file (as a
| |
| 34 return name == interest.name && image_url == interest.image_url && | |
| 35 relevance == interest.relevance; | |
| 36 } | |
| 37 }; | |
| 38 | |
| 39 typedef base::Callback<void(std::vector<Interest, std::allocator<Interest>>)> | |
|
Marc Treib
2015/09/03 09:04:37
Remove the explicit allocator?
Also, I find
using
tache
2015/09/03 13:26:29
Done.
| |
| 40 InterestsCallback; | |
| 41 | |
| 42 InterestsRetriever(net::URLRequestContextGetter *url_request_context, | |
|
Marc Treib
2015/09/03 09:04:37
nit: * goes with the type, not the name. Also the
tache
2015/09/03 13:26:28
Done.
| |
| 43 const std::string &token, | |
|
Marc Treib
2015/09/03 09:04:37
What exactly is |token|? An OAuth access token? Th
tache
2015/09/03 13:26:29
Done.
| |
| 44 const InterestsCallback &callback, | |
| 45 net::URLFetcherFactory *url_fetcher_factory); | |
| 46 | |
| 47 ~InterestsRetriever() override; | |
| 48 | |
| 49 private: | |
| 50 // net::URLFetcherDelegate implementation. | |
| 51 void OnURLFetchComplete(const net::URLFetcher *source) override; | |
| 52 | |
| 53 // create URLFetcher | |
|
Marc Treib
2015/09/03 09:04:37
Not a very useful comment ;P
tache
2015/09/03 13:26:29
Done.
| |
| 54 scoped_ptr<net::URLFetcher> CreateFetcher(); | |
| 55 | |
| 56 // parse the json response | |
| 57 std::vector<Interest> ExtractInterests(const std::string &response); | |
| 58 | |
| 59 static std::string FakeResponse(); | |
|
Marc Treib
2015/09/03 09:04:37
This one, OTOH, would deserve a comment, or at lea
tache
2015/09/03 13:26:29
Done.
| |
| 60 | |
| 61 net::URLRequestContextGetter *url_request_context_; | |
| 62 | |
| 63 std::string 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 FRIEND_TEST_ALL_PREFIXES(::InterestsRetrieverTest, DefaultFakeResponse); | |
|
Marc Treib
2015/09/03 09:04:37
By convention, the FRIEND_TEST goes to the top of
tache
2015/09/03 13:26:29
Done.
| |
| 74 }; | |
| 75 | |
| 76 #endif // CHROME_BROWSER_INTERESTS_INTERESTS_RETRIEVER_H_ | |
| OLD | NEW |