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

Unified Diff: content/renderer/mojo_context_state.cc

Issue 1776263002: Handle JS mojo module fetch failures gracefully. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « content/renderer/mojo_context_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/mojo_context_state.cc
diff --git a/content/renderer/mojo_context_state.cc b/content/renderer/mojo_context_state.cc
index 5495fb9785e650f740fd6b6760671dc20fa8e82b..d9e70e9250a59af9d7a281e1d8c30a0be955bc74 100644
--- a/content/renderer/mojo_context_state.cc
+++ b/content/renderer/mojo_context_state.cc
@@ -170,28 +170,30 @@ void MojoContextState::FetchModule(const std::string& id) {
blink::WebURLRequest::FrameTypeNone,
ResourceFetcher::PLATFORM_LOADER,
base::Bind(&MojoContextState::OnFetchModuleComplete,
- base::Unretained(this), fetcher));
+ base::Unretained(this), fetcher, id));
}
void MojoContextState::OnFetchModuleComplete(
ResourceFetcher* fetcher,
+ const std::string& id,
const blink::WebURLResponse& response,
const std::string& data) {
- DCHECK_EQ(module_prefix_,
- response.url().string().utf8().substr(0, module_prefix_.size()));
- const std::string module =
- response.url().string().utf8().substr(module_prefix_.size());
+ if (response.isNull()) {
+ LOG(ERROR) << "Failed to fetch source for module \"" << id << "\"";
+ return;
+ }
+ DCHECK_EQ(module_prefix_ + id, response.url().string().utf8());
// We can't delete fetch right now as the arguments to this function come from
// it and are used below. Instead use a scope_ptr to cleanup.
scoped_ptr<ResourceFetcher> deleter(fetcher);
module_fetchers_.weak_erase(
std::find(module_fetchers_.begin(), module_fetchers_.end(), fetcher));
if (data.empty()) {
- NOTREACHED();
- return; // TODO(sky): log something?
+ LOG(ERROR) << "Fetched empty source for module \"" << id << "\"";
+ return;
}
- runner_->Run(data, module);
+ runner_->Run(data, id);
}
void MojoContextState::OnDidAddPendingModule(
« no previous file with comments | « content/renderer/mojo_context_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698