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

Side by Side Diff: chrome/browser/android/logo_service.cc

Issue 1067593005: Fix race conditions in ImageDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use TestBrowserThreadBundle, cleanup tests Created 5 years, 8 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 | « no previous file | chrome/browser/apps/drive/drive_app_converter.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/android/logo_service.h" 5 #include "chrome/browser/android/logo_service.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "chrome/browser/image_decoder.h" 8 #include "chrome/browser/image_decoder.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h" 10 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 22 matching lines...) Expand all
33 const char kGoogleDoodleURLPath[] = "async/newtab_mobile"; 33 const char kGoogleDoodleURLPath[] = "async/newtab_mobile";
34 GURL::Replacements replacements; 34 GURL::Replacements replacements;
35 replacements.SetPathStr(kGoogleDoodleURLPath); 35 replacements.SetPathStr(kGoogleDoodleURLPath);
36 return google_base_url.ReplaceComponents(replacements); 36 return google_base_url.ReplaceComponents(replacements);
37 } 37 }
38 38
39 class LogoDecoderDelegate : public ImageDecoder::ImageRequest { 39 class LogoDecoderDelegate : public ImageDecoder::ImageRequest {
40 public: 40 public:
41 LogoDecoderDelegate( 41 LogoDecoderDelegate(
42 const base::Callback<void(const SkBitmap&)>& image_decoded_callback) 42 const base::Callback<void(const SkBitmap&)>& image_decoded_callback)
43 : ImageRequest(base::MessageLoopProxy::current()), 43 : image_decoded_callback_(image_decoded_callback),
44 image_decoded_callback_(image_decoded_callback),
45 weak_ptr_factory_(this) { 44 weak_ptr_factory_(this) {
46 // If the ImageDecoder crashes or otherwise never completes, call 45 // If the ImageDecoder crashes or otherwise never completes, call
47 // OnImageDecodeTimedOut() eventually to ensure that image_decoded_callback_ 46 // OnImageDecodeTimedOut() eventually to ensure that image_decoded_callback_
48 // is run. 47 // is run.
49 base::MessageLoopProxy::current()->PostDelayedTask( 48 base::MessageLoopProxy::current()->PostDelayedTask(
50 FROM_HERE, base::Bind(&LogoDecoderDelegate::OnDecodeImageFailed, 49 FROM_HERE, base::Bind(&LogoDecoderDelegate::OnDecodeImageFailed,
51 weak_ptr_factory_.GetWeakPtr()), 50 weak_ptr_factory_.GetWeakPtr()),
52 base::TimeDelta::FromSeconds(kDecodeLogoTimeoutSeconds)); 51 base::TimeDelta::FromSeconds(kDecodeLogoTimeoutSeconds));
53 } 52 }
54 53
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 148 }
150 149
151 LogoServiceFactory::~LogoServiceFactory() {} 150 LogoServiceFactory::~LogoServiceFactory() {}
152 151
153 KeyedService* LogoServiceFactory::BuildServiceInstanceFor( 152 KeyedService* LogoServiceFactory::BuildServiceInstanceFor(
154 content::BrowserContext* context) const { 153 content::BrowserContext* context) const {
155 Profile* profile = static_cast<Profile*>(context); 154 Profile* profile = static_cast<Profile*>(context);
156 DCHECK(!profile->IsOffTheRecord()); 155 DCHECK(!profile->IsOffTheRecord());
157 return new LogoService(profile); 156 return new LogoService(profile);
158 } 157 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/apps/drive/drive_app_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698