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

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

Issue 2856093004: Generalize content::URLDataSource so that it can be used by the network service. (Closed)
Patch Set: review comments 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 (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 "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_io_context.h" 10 #include "chrome/browser/search/instant_io_context.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return thumbnail_service_.get() 77 return thumbnail_service_.get()
78 ? nullptr 78 ? nullptr
79 : content::URLDataSource::TaskRunnerForRequestPath(path); 79 : content::URLDataSource::TaskRunnerForRequestPath(path);
80 } 80 }
81 81
82 bool ThumbnailSource::AllowCaching() const { 82 bool ThumbnailSource::AllowCaching() const {
83 return false; 83 return false;
84 } 84 }
85 85
86 bool ThumbnailSource::ShouldServiceRequest( 86 bool ThumbnailSource::ShouldServiceRequest(
87 const net::URLRequest* request) const { 87 const GURL& url,
88 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) 88 content::ResourceContext* resource_context,
89 return InstantIOContext::ShouldServiceRequest(request); 89 int render_process_id) const {
90 return URLDataSource::ShouldServiceRequest(request); 90 if (url.SchemeIs(chrome::kChromeSearchScheme)) {
91 return InstantIOContext::ShouldServiceRequest(url, resource_context,
92 render_process_id);
93 }
94 return URLDataSource::ShouldServiceRequest(url, resource_context,
95 render_process_id);
91 } 96 }
92 97
93 void ThumbnailSource::ExtractPageAndThumbnailUrls( 98 void ThumbnailSource::ExtractPageAndThumbnailUrls(
94 const std::string& path, 99 const std::string& path,
95 GURL* page_url, 100 GURL* page_url,
96 GURL* fallback_thumbnail_url) { 101 GURL* fallback_thumbnail_url) {
97 std::string page_url_str = path; 102 std::string page_url_str = path;
98 std::string fallback_thumbnail_url_str; 103 std::string fallback_thumbnail_url_str;
99 104
100 size_t pos = path.find(kUrlDelimiter); 105 size_t pos = path.find(kUrlDelimiter);
(...skipping 10 matching lines...) Expand all
111 const content::URLDataSource::GotDataCallback& callback, 116 const content::URLDataSource::GotDataCallback& callback,
112 const std::string& image_data, 117 const std::string& image_data,
113 const image_fetcher::RequestMetadata& metadata) { 118 const image_fetcher::RequestMetadata& metadata) {
114 if (image_data.empty()) { 119 if (image_data.empty()) {
115 callback.Run(nullptr); 120 callback.Run(nullptr);
116 return; 121 return;
117 } 122 }
118 std::string image_data_copy = image_data; 123 std::string image_data_copy = image_data;
119 callback.Run(base::RefCountedString::TakeString(&image_data_copy)); 124 callback.Run(base::RefCountedString::TakeString(&image_data_copy));
120 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698