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

Side by Side Diff: components/doodle/doodle_fetcher_impl.h

Issue 2768333002: [Doodle] Pass parameters to the server endpoint (Closed)
Patch Set: ifdef android Created 3 years, 9 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_DOODLE_DOODLE_FETCHER_IMPL_H_ 5 #ifndef COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
6 #define COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_ 6 #define COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 27 matching lines...) Expand all
38 public: 38 public:
39 // Callback for JSON parsing to allow injecting platform-dependent code. 39 // Callback for JSON parsing to allow injecting platform-dependent code.
40 using ParseJSONCallback = base::Callback<void( 40 using ParseJSONCallback = base::Callback<void(
41 const std::string& unsafe_json, 41 const std::string& unsafe_json,
42 const base::Callback<void(std::unique_ptr<base::Value> json)>& success, 42 const base::Callback<void(std::unique_ptr<base::Value> json)>& success,
43 const base::Callback<void(const std::string&)>& error)>; 43 const base::Callback<void(const std::string&)>& error)>;
44 44
45 DoodleFetcherImpl( 45 DoodleFetcherImpl(
46 scoped_refptr<net::URLRequestContextGetter> download_context, 46 scoped_refptr<net::URLRequestContextGetter> download_context,
47 GoogleURLTracker* google_url_tracker, 47 GoogleURLTracker* google_url_tracker,
48 const ParseJSONCallback& json_parsing_callback); 48 const ParseJSONCallback& json_parsing_callback,
49 bool gray_background);
49 ~DoodleFetcherImpl() override; 50 ~DoodleFetcherImpl() override;
50 51
51 // Fetches a doodle asynchronously. The |callback| is called with a 52 // Fetches a doodle asynchronously. The |callback| is called with a
52 // DoodleState indicating whether the request succeded in fetching a doodle. 53 // DoodleState indicating whether the request succeded in fetching a doodle.
53 // If a fetch is already running, the callback will be queued and invoked with 54 // If a fetch is already running, the callback will be queued and invoked with
54 // result from the next completed request. 55 // result from the next completed request.
55 void FetchDoodle(FinishedCallback callback) override; 56 void FetchDoodle(FinishedCallback callback) override;
56 57
57 private: 58 private:
58 // net::URLFetcherDelegate implementation. 59 // net::URLFetcherDelegate implementation.
(...skipping 13 matching lines...) Expand all
72 const base::Optional<DoodleConfig>& config); 73 const base::Optional<DoodleConfig>& config);
73 74
74 GURL GetGoogleBaseUrl() const; 75 GURL GetGoogleBaseUrl() const;
75 76
76 // Returns whether a fetch is still in progress. A fetch begins when a 77 // Returns whether a fetch is still in progress. A fetch begins when a
77 // callback is added and ends when the last callback was called. 78 // callback is added and ends when the last callback was called.
78 bool IsFetchInProgress() const { return !callbacks_.empty(); } 79 bool IsFetchInProgress() const { return !callbacks_.empty(); }
79 80
80 // Parameters set from constructor. 81 // Parameters set from constructor.
81 scoped_refptr<net::URLRequestContextGetter> const download_context_; 82 scoped_refptr<net::URLRequestContextGetter> const download_context_;
83 GoogleURLTracker* google_url_tracker_;
82 ParseJSONCallback json_parsing_callback_; 84 ParseJSONCallback json_parsing_callback_;
83 GoogleURLTracker* google_url_tracker_; 85 const bool gray_background_;
84 86
85 std::vector<FinishedCallback> callbacks_; 87 std::vector<FinishedCallback> callbacks_;
86 std::unique_ptr<net::URLFetcher> fetcher_; 88 std::unique_ptr<net::URLFetcher> fetcher_;
87 89
88 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_; 90 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_;
89 91
90 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl); 92 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl);
91 }; 93 };
92 94
93 } // namespace doodle 95 } // namespace doodle
94 96
95 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_ 97 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/doodle/doodle_service_factory.cc ('k') | components/doodle/doodle_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698