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

Side by Side Diff: chrome/browser/search/thumbnail_source.cc

Issue 2476433002: Replace URLDataSource::MessageLoopForRequestPath() with TaskRunnerForRequestPath(). (Closed)
Patch Set: rebase off local branch Created 4 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/search/thumbnail_source.h" 5 #include "chrome/browser/search/thumbnail_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (page_url.is_valid() && capture_thumbnails_) 72 if (page_url.is_valid() && capture_thumbnails_)
73 thumbnail_service_->AddForcedURL(page_url); 73 thumbnail_service_->AddForcedURL(page_url);
74 } 74 }
75 75
76 std::string ThumbnailSource::GetMimeType(const std::string&) const { 76 std::string ThumbnailSource::GetMimeType(const std::string&) const {
77 // We need to explicitly return a mime type, otherwise if the user tries to 77 // We need to explicitly return a mime type, otherwise if the user tries to
78 // drag the image they get no extension. 78 // drag the image they get no extension.
79 return "image/png"; 79 return "image/png";
80 } 80 }
81 81
82 base::MessageLoop* ThumbnailSource::MessageLoopForRequestPath( 82 scoped_refptr<base::SingleThreadTaskRunner>
83 const std::string& path) const { 83 ThumbnailSource::TaskRunnerForRequestPath(const std::string& path) const {
84 // TopSites can be accessed from the IO thread. Otherwise, the URLs should be 84 // TopSites can be accessed from the IO thread. Otherwise, the URLs should be
85 // accessed on the UI thread. 85 // accessed on the UI thread.
86 return thumbnail_service_.get() 86 return thumbnail_service_.get()
87 ? nullptr 87 ? nullptr
88 : content::URLDataSource::MessageLoopForRequestPath(path); 88 : content::URLDataSource::TaskRunnerForRequestPath(path);
89 } 89 }
90 90
91 bool ThumbnailSource::ShouldServiceRequest( 91 bool ThumbnailSource::ShouldServiceRequest(
92 const net::URLRequest* request) const { 92 const net::URLRequest* request) const {
93 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) 93 if (request->url().SchemeIs(chrome::kChromeSearchScheme))
94 return InstantIOContext::ShouldServiceRequest(request); 94 return InstantIOContext::ShouldServiceRequest(request);
95 return URLDataSource::ShouldServiceRequest(request); 95 return URLDataSource::ShouldServiceRequest(request);
96 } 96 }
97 97
98 void ThumbnailSource::ExtractPageAndThumbnailUrls( 98 void ThumbnailSource::ExtractPageAndThumbnailUrls(
(...skipping 26 matching lines...) Expand all
125 const SkBitmap* bitmap = image.ToSkBitmap(); 125 const SkBitmap* bitmap = image.ToSkBitmap();
126 scoped_refptr<base::RefCountedBytes> encoded_data( 126 scoped_refptr<base::RefCountedBytes> encoded_data(
127 new base::RefCountedBytes()); 127 new base::RefCountedBytes());
128 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) { 128 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) {
129 callback.Run(default_thumbnail_.get()); 129 callback.Run(default_thumbnail_.get());
130 return; 130 return;
131 } 131 }
132 132
133 callback.Run(encoded_data.get()); 133 callback.Run(encoded_data.get());
134 } 134 }
OLDNEW
« no previous file with comments | « chrome/browser/search/thumbnail_source.h ('k') | chrome/browser/thumbnails/thumbnail_list_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698