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

Side by Side Diff: components/search_provider_logos/animated_logo_tracker.cc

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 unified diff | Download patch
OLDNEW
(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 #include "components/search_provider_logos/animated_logo_tracker.h"
6 #include "net/url_request/url_fetcher.h"
7 #include "net/url_request/url_request_context_getter.h"
8 #include "net/url_request/url_request_status.h"
9
10 namespace search_provider_logos {
11
12 AnimatedLogoTracker::AnimatedLogoTracker(
13 scoped_refptr<net::URLRequestContextGetter> request_context_getter)
14 : request_context_getter_(request_context_getter) {}
15
16 AnimatedLogoTracker::~AnimatedLogoTracker() {
17 ReturnToIdle();
18 }
19
20 void AnimatedLogoTracker::GetAnimatedLogo(const GURL& animated_logo_url,
21 AnimatedLogoCallback listener) {
22 DCHECK(!animated_logo_url.is_empty());
23 animated_logo_callback_ = listener;
24 fetcher_ =
newt (away) 2015/09/18 20:46:03 resetting fetcher_ will abort any currently in-pro
25 net::URLFetcher::Create(animated_logo_url, net::URLFetcher::GET, this);
26 fetcher_->SetRequestContext(request_context_getter_.get());
27 fetcher_->Start();
28 }
29
30 void AnimatedLogoTracker::ReturnToIdle() {
31 fetcher_.reset();
32 animated_logo_callback_.Reset();
33 }
34
35 void AnimatedLogoTracker::OnURLFetchComplete(const net::URLFetcher* source) {
36 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) {
37 ReturnToIdle();
38 return;
39 }
40 std::string raw_response;
41 source->GetResponseAsString(&raw_response);
42 animated_logo_callback_.Run(raw_response);
43 ReturnToIdle();
44 }
45
46 } // namespace search_provider_logos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698