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

Side by Side Diff: chrome/browser/thumbnails/thumbnail_list_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 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/thumbnails/thumbnail_list_source.h" 5 #include "chrome/browser/thumbnails/thumbnail_list_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 std::string ThumbnailListSource::GetSource() const { 94 std::string ThumbnailListSource::GetSource() const {
95 return chrome::kChromeUIThumbnailListHost; 95 return chrome::kChromeUIThumbnailListHost;
96 } 96 }
97 97
98 void ThumbnailListSource::StartDataRequest( 98 void ThumbnailListSource::StartDataRequest(
99 const std::string& path, 99 const std::string& path,
100 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, 100 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
101 const content::URLDataSource::GotDataCallback& callback) { 101 const content::URLDataSource::GotDataCallback& callback) {
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); 102 DCHECK_CURRENTLY_ON(BrowserThread::IO);
103 if (!top_sites_) { 103 if (!top_sites_) {
104 callback.Run(NULL); 104 callback.Run(nullptr);
105 return; 105 return;
106 } 106 }
107 107
108 top_sites_->GetMostVisitedURLs( 108 top_sites_->GetMostVisitedURLs(
109 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable, 109 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable,
110 weak_ptr_factory_.GetWeakPtr(), callback), 110 weak_ptr_factory_.GetWeakPtr(), callback),
111 true); 111 true);
112 } 112 }
113 113
114 std::string ThumbnailListSource::GetMimeType(const std::string& path) const { 114 std::string ThumbnailListSource::GetMimeType(const std::string& path) const {
115 return "text/html"; 115 return "text/html";
116 } 116 }
117 117
118 base::MessageLoop* ThumbnailListSource::MessageLoopForRequestPath( 118 scoped_refptr<base::SingleThreadTaskRunner>
119 const std::string& path) const { 119 ThumbnailListSource::TaskRunnerForRequestPath(const std::string& path) const {
120 // TopSites can be accessed from the IO thread. 120 // TopSites can be accessed from the IO thread.
121 return thumbnail_service_.get() ? 121 return thumbnail_service_.get()
122 NULL : content::URLDataSource::MessageLoopForRequestPath(path); 122 ? nullptr
123 : content::URLDataSource::TaskRunnerForRequestPath(path);
123 } 124 }
124 125
125 bool ThumbnailListSource::ShouldServiceRequest( 126 bool ThumbnailListSource::ShouldServiceRequest(
126 const net::URLRequest* request) const { 127 const net::URLRequest* request) const {
127 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) 128 if (request->url().SchemeIs(chrome::kChromeSearchScheme))
128 return InstantIOContext::ShouldServiceRequest(request); 129 return InstantIOContext::ShouldServiceRequest(request);
129 return URLDataSource::ShouldServiceRequest(request); 130 return URLDataSource::ShouldServiceRequest(request);
130 } 131 }
131 132
132 bool ThumbnailListSource::ShouldReplaceExistingSource() const { 133 bool ThumbnailListSource::ShouldReplaceExistingSource() const {
(...skipping 29 matching lines...) Expand all
162 } 163 }
163 if (num_mv_with_thumb < num_mv) { 164 if (num_mv_with_thumb < num_mv) {
164 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); 165 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n");
165 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); 166 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out);
166 } 167 }
167 out.push_back(kHtmlFooter); 168 out.push_back(kHtmlFooter);
168 169
169 std::string out_html = base::JoinString(out, base::StringPiece()); 170 std::string out_html = base::JoinString(out, base::StringPiece());
170 callback.Run(base::RefCountedString::TakeString(&out_html)); 171 callback.Run(base::RefCountedString::TakeString(&out_html));
171 } 172 }
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_list_source.h ('k') | chrome/browser/ui/webui/theme_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698