OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_SEARCH_PROVIDER_LOGOS_ANIMATED_LOGO_TRACKER_H_ |
| 6 #define COMPONENTS_SEARCH_PROVIDER_LOGOS_ANIMATED_LOGO_TRACKER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "net/url_request/url_fetcher_delegate.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 namespace net { |
| 13 class URLFetcher; |
| 14 class URLRequestContextGetter; |
| 15 } |
| 16 |
| 17 namespace search_provider_logos { |
| 18 |
| 19 typedef base::Callback<void(const std::string&)> AnimatedLogoCallback; |
| 20 |
| 21 // This class fetches the animated logo for given urls, which are specified in |
| 22 // the logo downloaded by LogoTracker. |
| 23 class AnimatedLogoTracker : public net::URLFetcherDelegate { |
| 24 public: |
| 25 explicit AnimatedLogoTracker( |
| 26 scoped_refptr<net::URLRequestContextGetter> request_context_getter); |
| 27 |
| 28 ~AnimatedLogoTracker() override; |
| 29 |
| 30 // Gets the animated logo asynchronously for the given url, and cancels all |
| 31 // previous fetches. |
| 32 void GetAnimatedLogo(const GURL& animated_logo_url, |
| 33 AnimatedLogoCallback listener); |
| 34 |
| 35 private: |
| 36 // Cancels the current fetch, if any, and resets all member variables. |
| 37 void ReturnToIdle(); |
| 38 |
| 39 // net::URLFetcherDelegate: |
| 40 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 41 |
| 42 // The URLRequestContextGetter used for network requests. |
| 43 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 44 |
| 45 // The URLFetcher currently fetching the logo. NULL when not fetching. |
| 46 scoped_ptr<net::URLFetcher> fetcher_; |
| 47 |
| 48 // The callback that will be executed when the animated logo is successfully |
| 49 // downloaded. |
| 50 AnimatedLogoCallback animated_logo_callback_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(AnimatedLogoTracker); |
| 53 }; |
| 54 |
| 55 } // namespace search_provider_logos |
| 56 |
| 57 #endif // COMPONENTS_SEARCH_PROVIDER_LOGOS_ANIMATED_LOGO_TRACKER_H_ |
OLD | NEW |