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

Unified Diff: chrome/browser/ui/webui/ntp/thumbnail_source.cc

Issue 12529027: Chrome: Crash Report : InstantService::MaybeTranslateInstantPathOnIO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/thumbnail_source.cc
diff --git a/chrome/browser/ui/webui/ntp/thumbnail_source.cc b/chrome/browser/ui/webui/ntp/thumbnail_source.cc
index ac6bcbe62f635338b27e9c01e9e2231733a0ad3b..ffdc0d51a6fe633aa51b40682738a04e50c6f90c 100644
--- a/chrome/browser/ui/webui/ntp/thumbnail_source.cc
+++ b/chrome/browser/ui/webui/ntp/thumbnail_source.cc
@@ -24,7 +24,6 @@ using content::BrowserThread;
// Set ThumbnailService now as Profile isn't thread safe.
ThumbnailSource::ThumbnailSource(Profile* profile)
: thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)),
- current_request_(NULL),
profile_(profile) {
}
@@ -40,11 +39,16 @@ void ThumbnailSource::StartDataRequest(
bool is_incognito,
const content::URLDataSource::GotDataCallback& callback) {
// Translate to regular path if |raw_path| is of the form
- // chrome-search://favicon/<rid>, where rid is a uint64.
+ // chrome-search://favicon/<id> or chrome-search://thumb/<id>, where <id> is
+ // an integer.
std::string path = raw_path;
if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
- path = InstantService::MaybeTranslateInstantPathOnIO(
- current_request_, raw_path);
+ std::map<std::string, std::string>::iterator it =
+ id_to_url_map_.find(raw_path);
+ if (it != id_to_url_map_.end()) {
+ path = id_to_url_map_[raw_path];
+ id_to_url_map_.erase(it);
+ }
} else if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
path = InstantService::MaybeTranslateInstantPathOnUI(profile_, raw_path);
}
@@ -56,7 +60,6 @@ void ThumbnailSource::StartDataRequest(
} else {
callback.Run(default_thumbnail_);
}
- current_request_ = NULL;
}
std::string ThumbnailSource::GetMimeType(const std::string&) const {
@@ -74,10 +77,21 @@ MessageLoop* ThumbnailSource::MessageLoopForRequestPath(
bool ThumbnailSource::ShouldServiceRequest(
const net::URLRequest* request) const {
- current_request_ = request;
if (request->url().SchemeIs(chrome::kChromeSearchScheme)) {
- return InstantService::IsInstantPath(request->url()) &&
- InstantIOContext::ShouldServiceRequest(request);
+ if (InstantService::IsInstantPath(request->url()) &&
+ InstantIOContext::ShouldServiceRequest(request)) {
+ // If this request will be serviced on the IO thread, then do the
+ // translation from raw_path to path here, where we have the |request|
+ // object in-hand, saving the result for later use.
+ std::string raw_path = request->url().path().substr(1);
Dan Beam 2013/03/20 19:26:13 why .substr(1)?
dhollowa 2013/03/20 19:58:54 Done. Added comment.
+ if (!MessageLoopForRequestPath(raw_path)) {
+ std::string path =
+ InstantService::MaybeTranslateInstantPathOnIO(request, raw_path);
+ id_to_url_map_[raw_path] = path;
Dan Beam 2013/03/20 19:26:13 nit: id_to_url_map_[raw_path] = InstantSe
dhollowa 2013/03/20 19:58:54 Done.
+ }
+ return true;
+ }
Dan Beam 2013/03/20 19:26:13 should there be a NOTREACHED() here or anything?
dhollowa 2013/03/20 19:58:54 Not really, no. It is allowable to request a non-
+ return false;
}
return URLDataSource::ShouldServiceRequest(request);
}

Powered by Google App Engine
This is Rietveld 408576698