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

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

Issue 2710673006: [Doodle] Pull a doodle_types.h out of doodle_fetcher.h (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « components/doodle/BUILD.gn ('k') | components/doodle/doodle_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef COMPONENTS_DOODLE_DOODLE_FETCHER_H_
6 #define COMPONENTS_DOODLE_DOODLE_FETCHER_H_ 6 #define COMPONENTS_DOODLE_DOODLE_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/optional.h" 17 #include "base/optional.h"
18 #include "components/doodle/doodle_types.h"
18 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
19 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 class GoogleURLTracker; 23 class GoogleURLTracker;
23 24
24 namespace base { 25 namespace base {
25 class Clock; 26 class Clock;
26 class DictionaryValue; 27 class DictionaryValue;
27 class Value; 28 class Value;
28 } 29 }
29 30
30 namespace doodle { 31 namespace doodle {
31 32
32 enum class DoodleState {
33 AVAILABLE,
34 NO_DOODLE,
35 DOWNLOAD_ERROR,
36 PARSING_ERROR,
37 };
38
39 enum class DoodleType {
40 UNKNOWN,
41 SIMPLE,
42 RANDOM,
43 VIDEO,
44 INTERACTIVE,
45 INLINE_INTERACTIVE,
46 SLIDESHOW,
47 };
48
49 // Information about a Doodle image. If the image is invalid, the |url| will be
50 // empty and invalid. By default the dimensions are 0.
51 struct DoodleImage {
52 DoodleImage();
53 ~DoodleImage();
54
55 GURL url;
56 int height;
57 int width;
58 bool is_animated_gif;
59 bool is_cta;
60
61 // Copying and assignment allowed.
62 };
63
64 // All information about a current doodle that can be fetched from the remote
65 // end. By default, all URLs are empty and therefore invalid.
66 struct DoodleConfig {
67 DoodleConfig();
68 DoodleConfig(const DoodleConfig& config); // = default;
69 ~DoodleConfig();
70
71 DoodleType doodle_type;
72 std::string alt_text;
73 std::string interactive_html;
74
75 base::Time expiry_date;
76 GURL search_url;
77 GURL target_url;
78 GURL fullpage_interactive_url;
79
80 DoodleImage large_image;
81 DoodleImage large_cta_image;
82 DoodleImage transparent_large_image;
83 };
84
85 // This class provides information about any recent doodle. 33 // This class provides information about any recent doodle.
86 // It works asynchronously and calls a callback when finished fetching the 34 // It works asynchronously and calls a callback when finished fetching the
87 // information from the remote enpoint. 35 // information from the remote enpoint.
88 class DoodleFetcher : public net::URLFetcherDelegate { 36 class DoodleFetcher : public net::URLFetcherDelegate {
89 public: 37 public:
90 // Callback that is invoked when the fetching is done. 38 // Callback that is invoked when the fetching is done.
91 // |doodle_config| will only contain a value if |state| is AVAILABLE. 39 // |doodle_config| will only contain a value if |state| is AVAILABLE.
92 using FinishedCallback = base::OnceCallback<void( 40 using FinishedCallback = base::OnceCallback<void(
93 DoodleState state, 41 DoodleState state,
94 const base::Optional<DoodleConfig>& doodle_config)>; 42 const base::Optional<DoodleConfig>& doodle_config)>;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 std::unique_ptr<net::URLFetcher> fetcher_; 101 std::unique_ptr<net::URLFetcher> fetcher_;
154 102
155 base::WeakPtrFactory<DoodleFetcher> weak_ptr_factory_; 103 base::WeakPtrFactory<DoodleFetcher> weak_ptr_factory_;
156 104
157 DISALLOW_COPY_AND_ASSIGN(DoodleFetcher); 105 DISALLOW_COPY_AND_ASSIGN(DoodleFetcher);
158 }; 106 };
159 107
160 } // namespace doodle 108 } // namespace doodle
161 109
162 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_H_ 110 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_H_
OLDNEW
« no previous file with comments | « components/doodle/BUILD.gn ('k') | components/doodle/doodle_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698