| Index: chrome/renderer/pepper/pnacl_translation_resource_host.cc
|
| diff --git a/chrome/renderer/pepper/pnacl_translation_resource_host.cc b/chrome/renderer/pepper/pnacl_translation_resource_host.cc
|
| index fd6572aab200298fb487b9f230b8b1d2160410cc..17eb614dbf88aab96d143d824961fc14b2dfc49e 100644
|
| --- a/chrome/renderer/pepper/pnacl_translation_resource_host.cc
|
| +++ b/chrome/renderer/pepper/pnacl_translation_resource_host.cc
|
| @@ -26,6 +26,7 @@ PnaclTranslationResourceHost::PnaclTranslationResourceHost(
|
|
|
| PnaclTranslationResourceHost::~PnaclTranslationResourceHost() {
|
| CleanupCacheRequests();
|
| + CleanupEnsurePnaclRequests();
|
| }
|
|
|
| void PnaclTranslationResourceHost::OnFilterAdded(IPC::Channel* channel) {
|
| @@ -49,6 +50,10 @@ bool PnaclTranslationResourceHost::OnMessageReceived(
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(PnaclTranslationResourceHost, message)
|
| IPC_MESSAGE_HANDLER(NaClViewMsg_NexeTempFileReply, OnNexeTempFileReply)
|
| + IPC_MESSAGE_HANDLER(NaClViewMsg_EnsurePnaclInstalledReply,
|
| + OnEnsurePnaclInstalledReply)
|
| + IPC_MESSAGE_HANDLER(NaClViewMsg_EnsurePnaclInstalledProgress,
|
| + OnEnsurePnaclInstalledProgress)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -144,4 +149,66 @@ void PnaclTranslationResourceHost::CleanupCacheRequests() {
|
| pending_cache_requests_.clear();
|
| }
|
|
|
| +
|
| +
|
| +void PnaclTranslationResourceHost::EnsurePnaclInstalled(
|
| + PP_Instance instance,
|
| + scoped_refptr<TrackedCallback> callback) {
|
| + if (!io_message_loop_->BelongsToCurrentThread()) {
|
| + io_message_loop_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&PnaclTranslationResourceHost::EnsurePnaclInstalled,
|
| + this, instance, callback));
|
| + return;
|
| + }
|
| + if (!channel_ || !channel_->Send(new NaClHostMsg_EnsurePnaclInstalled(
|
| + instance))) {
|
| + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&TrackedCallback::Run,
|
| + callback,
|
| + static_cast<int32_t>(PP_ERROR_FAILED)));
|
| + return;
|
| + }
|
| + pending_ensure_pnacl_requests_.insert(
|
| + std::make_pair(instance, callback));
|
| +}
|
| +
|
| +void PnaclTranslationResourceHost::OnEnsurePnaclInstalledReply(
|
| + PP_Instance instance,
|
| + bool success) {
|
| + EnsurePnaclInstalledMap::iterator it =
|
| + pending_ensure_pnacl_requests_.find(instance);
|
| + if (it == pending_ensure_pnacl_requests_.end()) {
|
| + DLOG(ERROR) << "Could not find pending request for reply";
|
| + } else {
|
| + if (TrackedCallback::IsPending(it->second)) {
|
| + PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&TrackedCallback::Run,
|
| + it->second,
|
| + static_cast<int32_t>(success ? PP_OK : PP_ERROR_FAILED)));
|
| + }
|
| + pending_ensure_pnacl_requests_.erase(it);
|
| + }
|
| +}
|
| +
|
| +void PnaclTranslationResourceHost::OnEnsurePnaclInstalledProgress(
|
| + PP_Instance instance,
|
| + int64_t current_progress,
|
| + int64_t total) {
|
| + // TODO(jvoung): Issue a progress event w/ dmichael's new DispatchEvent
|
| + // interface: https://codereview.chromium.org/14588009/
|
| +}
|
| +
|
| +void PnaclTranslationResourceHost::CleanupEnsurePnaclRequests() {
|
| + for (EnsurePnaclInstalledMap::iterator it =
|
| + pending_ensure_pnacl_requests_.begin();
|
| + it != pending_ensure_pnacl_requests_.end();
|
| + ++it) {
|
| + it->second->PostAbort();
|
| + }
|
| + pending_ensure_pnacl_requests_.clear();
|
| +}
|
| +
|
| #endif // DISABLE_NACL
|
|
|