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

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

Issue 2798033002: [Doodle] Allow overriding the API URL via a fieldtrial param (Closed)
Patch Set: .name Created 3 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 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 28 matching lines...) Expand all
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 bool gray_background,
50 const base::Optional<std::string>& override_url);
50 ~DoodleFetcherImpl() override; 51 ~DoodleFetcherImpl() override;
51 52
52 // Fetches a doodle asynchronously. The |callback| is called with a 53 // Fetches a doodle asynchronously. The |callback| is called with a
53 // DoodleState indicating whether the request succeded in fetching a doodle. 54 // DoodleState indicating whether the request succeded in fetching a doodle.
54 // If a fetch is already running, the callback will be queued and invoked with 55 // If a fetch is already running, the callback will be queued and invoked with
55 // result from the next completed request. 56 // result from the next completed request.
56 void FetchDoodle(FinishedCallback callback) override; 57 void FetchDoodle(FinishedCallback callback) override;
57 58
58 private: 59 private:
59 // net::URLFetcherDelegate implementation. 60 // net::URLFetcherDelegate implementation.
(...skipping 16 matching lines...) Expand all
76 77
77 // Returns whether a fetch is still in progress. A fetch begins when a 78 // Returns whether a fetch is still in progress. A fetch begins when a
78 // callback is added and ends when the last callback was called. 79 // callback is added and ends when the last callback was called.
79 bool IsFetchInProgress() const { return !callbacks_.empty(); } 80 bool IsFetchInProgress() const { return !callbacks_.empty(); }
80 81
81 // Parameters set from constructor. 82 // Parameters set from constructor.
82 scoped_refptr<net::URLRequestContextGetter> const download_context_; 83 scoped_refptr<net::URLRequestContextGetter> const download_context_;
83 GoogleURLTracker* google_url_tracker_; 84 GoogleURLTracker* google_url_tracker_;
84 ParseJSONCallback json_parsing_callback_; 85 ParseJSONCallback json_parsing_callback_;
85 const bool gray_background_; 86 const bool gray_background_;
87 const base::Optional<std::string> override_url_;
86 88
87 std::vector<FinishedCallback> callbacks_; 89 std::vector<FinishedCallback> callbacks_;
88 std::unique_ptr<net::URLFetcher> fetcher_; 90 std::unique_ptr<net::URLFetcher> fetcher_;
89 91
90 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_; 92 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_;
91 93
92 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl); 94 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl);
93 }; 95 };
94 96
95 } // namespace doodle 97 } // namespace doodle
96 98
97 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_ 99 #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