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

Unified Diff: components/search_provider_logos/animated_logo_tracker.h

Issue 1343913002: Introduce Animated Logo to Chrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698