| Index: chrome/browser/nacl_host/nacl_file_host.cc
|
| diff --git a/chrome/browser/nacl_host/nacl_file_host.cc b/chrome/browser/nacl_host/nacl_file_host.cc
|
| index ca1feb9f67c81f6242837d4b032acf9e45d3d298..1718018f1d27aad4016038a535a61ec8d927c180 100644
|
| --- a/chrome/browser/nacl_host/nacl_file_host.cc
|
| +++ b/chrome/browser/nacl_host/nacl_file_host.cc
|
| @@ -43,6 +43,69 @@ void NotifyRendererOfError(
|
| nacl_host_message_filter->Send(reply_msg);
|
| }
|
|
|
| +void ReplyEnsurePnaclInstalledOnIOThread(
|
| + nacl_file_host::InstallCallback cb,
|
| + bool success) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + cb.Run(success);
|
| +}
|
| +
|
| +void PnaclCheckDone(
|
| + nacl_file_host::InstallCallback done_callback,
|
| + nacl_file_host::InstallProgressCallback progress_callback,
|
| + bool success) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&ReplyEnsurePnaclInstalledOnIOThread,
|
| + done_callback, success));
|
| +}
|
| +
|
| +void TryInstallPnacl(
|
| + nacl_file_host::InstallCallback done_callback,
|
| + nacl_file_host::InstallProgressCallback progress_callback) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + NaClBrowser::GetDelegate()->TryInstallPnacl(
|
| + base::Bind(&PnaclCheckDone,
|
| + done_callback,
|
| + progress_callback));
|
| +}
|
| +
|
| +void SendNotInstalledProgress(
|
| + nacl_file_host::InstallCallback done_callback,
|
| + nacl_file_host::InstallProgressCallback progress_callback) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + progress_callback.Run(0, -1);
|
| + // TryInstall after sending the progress event so that they are more ordered.
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI,
|
| + FROM_HERE,
|
| + base::Bind(&TryInstallPnacl, done_callback, progress_callback));
|
| +}
|
| +
|
| +void DoEnsurePnaclInstalled(
|
| + nacl_file_host::InstallCallback done_callback,
|
| + nacl_file_host::InstallProgressCallback progress_callback) {
|
| + // If already installed, return on IO thread.
|
| + base::FilePath pnacl_dir;
|
| + if (NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir) &&
|
| + base::PathExists(pnacl_dir)) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&ReplyEnsurePnaclInstalledOnIOThread,
|
| + done_callback, true));
|
| + return;
|
| + }
|
| +
|
| + // Otherwise, request an install (but send some "unknown" progress first).
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&SendNotInstalledProgress, done_callback, progress_callback));
|
| +}
|
| +
|
| bool PnaclDoOpenFile(const base::FilePath& file_to_open,
|
| base::PlatformFile* out_file) {
|
| base::PlatformFileError error_code;
|
| @@ -60,47 +123,6 @@ bool PnaclDoOpenFile(const base::FilePath& file_to_open,
|
| void DoOpenPnaclFile(
|
| scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
|
| const std::string& filename,
|
| - IPC::Message* reply_msg);
|
| -
|
| -void PnaclCheckDone(
|
| - scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
|
| - const std::string& filename,
|
| - IPC::Message* reply_msg,
|
| - bool success) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - if (!success) {
|
| - NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
|
| - } else {
|
| - if (!BrowserThread::PostBlockingPoolTask(
|
| - FROM_HERE,
|
| - base::Bind(&DoOpenPnaclFile,
|
| - nacl_host_message_filter,
|
| - filename,
|
| - reply_msg))) {
|
| - NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
|
| - }
|
| - }
|
| -}
|
| -
|
| -void TryInstallPnacl(
|
| - scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
|
| - const std::string& filename,
|
| - IPC::Message* reply_msg) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - ComponentUpdateService* cus = g_browser_process->component_updater();
|
| - PnaclComponentInstaller* pci =
|
| - g_browser_process->pnacl_component_installer();
|
| - RequestFirstInstall(cus,
|
| - pci,
|
| - base::Bind(&PnaclCheckDone,
|
| - nacl_host_message_filter,
|
| - filename,
|
| - reply_msg));
|
| -}
|
| -
|
| -void DoOpenPnaclFile(
|
| - scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
|
| - const std::string& filename,
|
| IPC::Message* reply_msg) {
|
| DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
|
| base::FilePath full_filepath;
|
| @@ -109,12 +131,7 @@ void DoOpenPnaclFile(
|
| base::FilePath pnacl_dir;
|
| if (!NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir) ||
|
| !base::PathExists(pnacl_dir)) {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&TryInstallPnacl,
|
| - nacl_host_message_filter,
|
| - filename,
|
| - reply_msg));
|
| + NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
|
| return;
|
| }
|
|
|
| @@ -254,6 +271,19 @@ void DoOpenNaClExecutableOnThreadPool(
|
|
|
| namespace nacl_file_host {
|
|
|
| +void EnsurePnaclInstalled(
|
| + InstallCallback done_callback,
|
| + InstallProgressCallback progress_callback) {
|
| + if (!BrowserThread::PostBlockingPoolTask(
|
| + FROM_HERE,
|
| + base::Bind(&DoEnsurePnaclInstalled,
|
| + done_callback,
|
| + progress_callback))) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + done_callback.Run(false);
|
| + }
|
| +}
|
| +
|
| void GetReadonlyPnaclFd(
|
| scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
|
| const std::string& filename,
|
|
|