Index: components/search_provider_logos/animated_logo_tracker.h |
diff --git a/components/search_provider_logos/animated_logo_tracker.h b/components/search_provider_logos/animated_logo_tracker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4a091f5e621dbb3d4ab4d971ab62ee4efe9e52dc |
--- /dev/null |
+++ b/components/search_provider_logos/animated_logo_tracker.h |
@@ -0,0 +1,57 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_SEARCH_PROVIDER_LOGOS_ANIMATED_LOGO_TRACKER_H_ |
+#define COMPONENTS_SEARCH_PROVIDER_LOGOS_ANIMATED_LOGO_TRACKER_H_ |
+ |
+#include "base/callback.h" |
+#include "net/url_request/url_fetcher_delegate.h" |
+#include "url/gurl.h" |
+ |
+namespace net { |
+class URLFetcher; |
+class URLRequestContextGetter; |
+} |
+ |
+namespace search_provider_logos { |
+ |
+typedef base::Callback<void(const std::string&)> AnimatedLogoCallback; |
+ |
+// This class fetches the animated logo for given urls, which are specified in |
+// the logo downloaded by LogoTracker. |
+class AnimatedLogoTracker : public net::URLFetcherDelegate { |
+ public: |
+ explicit AnimatedLogoTracker( |
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter); |
+ |
+ ~AnimatedLogoTracker() override; |
+ |
+ // Gets the animated logo asynchronously for the given url, and cancels all |
+ // previous fetches. |
+ void GetAnimatedLogo(const GURL& animated_logo_url, |
+ AnimatedLogoCallback listener); |
+ |
+ private: |
+ // Cancels the current fetch, if any, and resets all member variables. |
+ void ReturnToIdle(); |
+ |
+ // net::URLFetcherDelegate: |
+ void OnURLFetchComplete(const net::URLFetcher* source) override; |
+ |
+ // The URLRequestContextGetter used for network requests. |
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
+ |
+ // The URLFetcher currently fetching the logo. NULL when not fetching. |
+ scoped_ptr<net::URLFetcher> fetcher_; |
+ |
+ // The callback that will be executed when the animated logo is successfully |
+ // downloaded. |
+ AnimatedLogoCallback animated_logo_callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AnimatedLogoTracker); |
+}; |
+ |
+} // namespace search_provider_logos |
+ |
+#endif // COMPONENTS_SEARCH_PROVIDER_LOGOS_ANIMATED_LOGO_TRACKER_H_ |