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

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

Issue 2710003006: [Doodle] Introduce a DoodleService (Closed)
Patch Set: comment 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
« no previous file with comments | « components/doodle/doodle_fetcher.h ('k') | components/doodle/doodle_fetcher_impl.cc » ('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_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>
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 "base/time/clock.h"
18 #include "components/doodle/doodle_fetcher.h" 19 #include "components/doodle/doodle_fetcher.h"
19 #include "components/doodle/doodle_types.h" 20 #include "components/doodle/doodle_types.h"
20 #include "net/url_request/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 class GoogleURLTracker; 25 class GoogleURLTracker;
25 26
26 namespace base { 27 namespace base {
27 class Clock;
28 class DictionaryValue; 28 class DictionaryValue;
29 class Value; 29 class Value;
30 } 30 }
31 31
32 namespace doodle { 32 namespace doodle {
33 33
34 // This class provides information about any recent doodle. 34 // This class provides information about any recent doodle.
35 // It works asynchronously and calls a callback when finished fetching the 35 // It works asynchronously and calls a callback when finished fetching the
36 // information from the remote enpoint. 36 // information from the remote enpoint.
37 class DoodleFetcherImpl : public DoodleFetcher, public net::URLFetcherDelegate { 37 class DoodleFetcherImpl : public DoodleFetcher, public net::URLFetcherDelegate {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // Returns whether a fetch is still in progress. A fetch begins when a 85 // 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. 86 // callback is added and ends when the last callback was called.
87 bool IsFetchInProgress() const { return !callbacks_.empty(); } 87 bool IsFetchInProgress() const { return !callbacks_.empty(); }
88 88
89 // Parameters set from constructor. 89 // Parameters set from constructor.
90 scoped_refptr<net::URLRequestContextGetter> const download_context_; 90 scoped_refptr<net::URLRequestContextGetter> const download_context_;
91 ParseJSONCallback json_parsing_callback_; 91 ParseJSONCallback json_parsing_callback_;
92 GoogleURLTracker* google_url_tracker_; 92 GoogleURLTracker* google_url_tracker_;
93 93
94 // Allow for an injectable tick clock for testing. 94 // Allow for an injectable clock for testing.
95 std::unique_ptr<base::Clock> clock_; 95 std::unique_ptr<base::Clock> clock_;
96 96
97 std::vector<FinishedCallback> callbacks_; 97 std::vector<FinishedCallback> callbacks_;
98 std::unique_ptr<net::URLFetcher> fetcher_; 98 std::unique_ptr<net::URLFetcher> fetcher_;
99 99
100 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_; 100 base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_;
101 101
102 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl); 102 DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl);
103 }; 103 };
104 104
105 } // namespace doodle 105 } // namespace doodle
106 106
107 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_ 107 #endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
OLDNEW
« no previous file with comments | « components/doodle/doodle_fetcher.h ('k') | components/doodle/doodle_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698