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

Unified Diff: src/trusted/plugin/srpc/closure.cc

Issue 1092005: Issue 1092005 (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: Created 10 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: src/trusted/plugin/srpc/closure.cc
===================================================================
--- src/trusted/plugin/srpc/closure.cc (revision 1695)
+++ src/trusted/plugin/srpc/closure.cc (working copy)
@@ -7,6 +7,7 @@
#include <string.h>
#include <string>
+#include <list>
#include "native_client/src/shared/npruntime/npmodule.h"
#include "native_client/src/shared/platform/nacl_host_desc.h"
@@ -36,9 +37,13 @@
return (NPERR_NO_ERROR == err);
}
-LoadNaClAppNotify::LoadNaClAppNotify(Plugin* plugin, std::string url)
- : Closure(plugin, url) {
- dprintf(("LoadNaClAppNotify ctor\n"));
+LoadNaClAppNotify::LoadNaClAppNotify(Plugin* plugin,
+ const std::list<std::string>& urls)
+ : Closure(plugin, urls.front()),
+ fallback_urls_(urls) {
+ fallback_urls_.pop_front();
+ dprintf(("LoadNaClAppNotify ctor (trying URL %s + %d more)\n",
+ url().c_str(), fallback_urls_.size()));
}
LoadNaClAppNotify::~LoadNaClAppNotify() {
@@ -50,7 +55,21 @@
static_cast<void*>(stream),
fname));
if (NULL != fname) {
+ assert(stream != NULL);
plugin()->Load(stream->url, fname);
+ } else {
+ // Loading failed. Try another URL if we have one.
+ if (fallback_urls_.size() > 0) {
+ LoadNaClAppNotify* callback =
+ new(std::nothrow) LoadNaClAppNotify(plugin(), fallback_urls_);
+ if ((NULL == callback) || (!callback->StartDownload())) {
+ dprintf(("Failed to load URL to local file.\n"));
+ // callback is always deleted in URLNotify
+ // FIXME(adonovan): it is? even when StartDownload failed?
+ // FIXME(adonovan): shouldn't this result in the onfail handler
+ // getting called?
+ }
+ }
}
}
@@ -63,7 +82,6 @@
}
}
-
UrlAsNaClDescNotify::UrlAsNaClDescNotify(Plugin* plugin,
std::string url,
void* callback_obj) :

Powered by Google App Engine
This is Rietveld 408576698