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

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

Issue 2740013005: [Doodle] Move parsing from fetcher into the types themselves (Closed)
Patch Set: -auto 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // ParseJSONCallback Success callback 61 // ParseJSONCallback Success callback
62 void OnJsonParsed(std::unique_ptr<base::Value> json); 62 void OnJsonParsed(std::unique_ptr<base::Value> json);
63 // ParseJSONCallback Failure callback 63 // ParseJSONCallback Failure callback
64 void OnJsonParseFailed(const std::string& error_message); 64 void OnJsonParseFailed(const std::string& error_message);
65 65
66 base::Optional<DoodleConfig> ParseDoodleConfigAndTimeToLive( 66 base::Optional<DoodleConfig> ParseDoodleConfigAndTimeToLive(
67 const base::DictionaryValue& ddljson, 67 const base::DictionaryValue& ddljson,
68 base::TimeDelta* time_to_live) const; 68 base::TimeDelta* time_to_live) const;
69 69
70 bool ParseImage(const base::DictionaryValue& image_dict,
71 const std::string& image_name,
72 DoodleImage* image) const;
73 void ParseBaseInformation(const base::DictionaryValue& ddljson,
74 DoodleConfig* config,
75 base::TimeDelta* time_to_live) const;
76 GURL ParseRelativeUrl(const base::DictionaryValue& dict_value,
77 const std::string& key) const;
78
79 void RespondToAllCallbacks(DoodleState state, 70 void RespondToAllCallbacks(DoodleState state,
80 base::TimeDelta time_to_live, 71 base::TimeDelta time_to_live,
81 const base::Optional<DoodleConfig>& config); 72 const base::Optional<DoodleConfig>& config);
82 73
83 GURL GetGoogleBaseUrl() const; 74 GURL GetGoogleBaseUrl() const;
84 75
85 // Returns whether a fetch is still in progress. A fetch begins when a 76 // Returns whether a fetch is still in progress. A fetch begins when a
86 // callback is added and ends when the last callback was called. 77 // callback is added and ends when the last callback was called.
87 bool IsFetchInProgress() const { return !callbacks_.empty(); } 78 bool IsFetchInProgress() const { return !callbacks_.empty(); }
88 79
89 // Parameters set from constructor. 80 // Parameters set from constructor.
90 scoped_refptr<net::URLRequestContextGetter> const download_context_; 81 scoped_refptr<net::URLRequestContextGetter> const download_context_;
91 ParseJSONCallback json_parsing_callback_; 82 ParseJSONCallback json_parsing_callback_;
92 GoogleURLTracker* google_url_tracker_; 83 GoogleURLTracker* google_url_tracker_;
93 84
94 std::vector<FinishedCallback> callbacks_; 85 std::vector<FinishedCallback> callbacks_;
95 std::unique_ptr<net::URLFetcher> fetcher_; 86 std::unique_ptr<net::URLFetcher> fetcher_;
96 87
97 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_; 88 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_;
98 89
99 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl); 90 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl);
100 }; 91 };
101 92
102 } // namespace doodle 93 } // namespace doodle
103 94
104 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_ 95 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/doodle/doodle_fetcher_impl.cc » ('j') | components/doodle/doodle_types.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698