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

Side by Side Diff: chrome/browser/thumbnails/thumbnail_list_source.cc

Issue 2856093004: Generalize content::URLDataSource so that it can be used by the network service. (Closed)
Patch Set: Created 3 years, 7 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
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 scoped_refptr<base::SingleThreadTaskRunner> 118 scoped_refptr<base::SingleThreadTaskRunner>
119 ThumbnailListSource::TaskRunnerForRequestPath(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 ? nullptr 122 ? nullptr
123 : content::URLDataSource::TaskRunnerForRequestPath(path); 123 : content::URLDataSource::TaskRunnerForRequestPath(path);
124 } 124 }
125 125
126 bool ThumbnailListSource::ShouldServiceRequest( 126 bool ThumbnailListSource::ShouldServiceRequest(
127 const net::URLRequest* request) const { 127 const GURL& url,
128 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) 128 content::ResourceContext* resource_context,
129 return InstantIOContext::ShouldServiceRequest(request); 129 int render_process_id) const {
130 return URLDataSource::ShouldServiceRequest(request); 130 if (url.SchemeIs(chrome::kChromeSearchScheme))
131 return InstantIOContext::ShouldServiceRequest(url, resource_context,
132 render_process_id);
133 return URLDataSource::ShouldServiceRequest(url, resource_context,
134 render_process_id);
131 } 135 }
132 136
133 bool ThumbnailListSource::ShouldReplaceExistingSource() const { 137 bool ThumbnailListSource::ShouldReplaceExistingSource() const {
134 return false; 138 return false;
135 } 139 }
136 140
137 void ThumbnailListSource::OnMostVisitedURLsAvailable( 141 void ThumbnailListSource::OnMostVisitedURLsAvailable(
138 const content::URLDataSource::GotDataCallback& callback, 142 const content::URLDataSource::GotDataCallback& callback,
139 const history::MostVisitedURLList& mvurl_list) { 143 const history::MostVisitedURLList& mvurl_list) {
140 DCHECK_CURRENTLY_ON(BrowserThread::IO); 144 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 22 matching lines...) Expand all
163 } 167 }
164 if (num_mv_with_thumb < num_mv) { 168 if (num_mv_with_thumb < num_mv) {
165 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); 169 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n");
166 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); 170 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out);
167 } 171 }
168 out.push_back(kHtmlFooter); 172 out.push_back(kHtmlFooter);
169 173
170 std::string out_html = base::JoinString(out, base::StringPiece()); 174 std::string out_html = base::JoinString(out, base::StringPiece());
171 callback.Run(base::RefCountedString::TakeString(&out_html)); 175 callback.Run(base::RefCountedString::TakeString(&out_html));
172 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698