Skip to content

Commit

Permalink
Remove PNaCl's RequestFirstInstall, use resource throttle instead
Browse files Browse the repository at this point in the history
This removes PNaCl's RequestFirstInstall and its use of
the component updater OnDemand API. A different CL:
https://codereview.chromium.org/25713007/
will do the OnDemand calls internally.

This removes the async IPCs, callbacks, and observers that
were used to support the old code. The new code just
throttles/blocks the pexe URL request until OnDemand
installation is done.

Reverts: https://codereview.chromium.org/19863003/, plus
other CLs.

BUG=none
R=cpu@chromium.org, dmichael@chromium.org
TBR=jln

Review URL: https://codereview.chromium.org/55463002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232827 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jvoung@google.com committed Nov 4, 2013
1 parent 59bda5a commit 355c3aa
Show file tree
Hide file tree
Showing 25 changed files with 46 additions and 628 deletions.
3 changes: 0 additions & 3 deletions chrome/browser/component_updater/component_updater_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ class ComponentUpdateService {

virtual ~ComponentUpdateService() {}

// TODO(waffles): Remove PNaCl as a friend once an alternative on-demand
// trigger is available.
friend class ComponentsUI;
friend class PnaclComponentInstaller;
friend class OnDemandTester;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ PnaclComponentInstaller::PnaclComponentInstaller()
#if defined(OS_CHROMEOS)
per_user_ = true;
#endif
updater_observer_.reset(new PnaclUpdaterObserver(this));
}

PnaclComponentInstaller::~PnaclComponentInstaller() {
Expand Down Expand Up @@ -243,20 +242,17 @@ bool PnaclComponentInstaller::Install(const base::DictionaryValue& manifest,
ReadPnaclManifest(unpack_path));
if (pnacl_manifest == NULL) {
LOG(WARNING) << "Failed to read pnacl manifest.";
NotifyInstallError();
return false;
}

Version version;
if (!CheckPnaclComponentManifest(manifest, *pnacl_manifest, &version)) {
LOG(WARNING) << "CheckPnaclComponentManifest failed, not installing.";
NotifyInstallError();
return false;
}

// Don't install if the current version is actually newer.
if (current_version().CompareTo(version) > 0) {
NotifyInstallError();
return false;
}

Expand All @@ -265,20 +261,17 @@ bool PnaclComponentInstaller::Install(const base::DictionaryValue& manifest,
version.GetString());
if (base::PathExists(path)) {
LOG(WARNING) << "Target path already exists, not installing.";
NotifyInstallError();
return false;
}
if (!base::Move(unpack_path, path)) {
LOG(WARNING) << "Move failed, not installing.";
NotifyInstallError();
return false;
}

// Installation is done. Now tell the rest of chrome.
// - The path service.
// - Callbacks that requested an update.
set_current_version(version);
NotifyInstallSuccess();
OverrideDirPnaclComponent(path);
return true;
}
Expand All @@ -297,44 +290,11 @@ bool PnaclComponentInstaller::GetInstalledFile(
return true;
}

void PnaclComponentInstaller::NotifyInstallError() {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&PnaclComponentInstaller::NotifyInstallError,
// Unretained because installer lives until process shutdown.
base::Unretained(this)));
return;
}
if (!install_callback_.is_null()) {
updater_observer_->StopObserving();
install_callback_.Run(false);
install_callback_.Reset();
}
}

void PnaclComponentInstaller::NotifyInstallSuccess() {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&PnaclComponentInstaller::NotifyInstallSuccess,
// Unretained because installer lives until process shutdown.
base::Unretained(this)));
return;
}
if (!install_callback_.is_null()) {
updater_observer_->StopObserving();
install_callback_.Run(true);
install_callback_.Reset();
}
}

CrxComponent PnaclComponentInstaller::GetCrxComponent() {
CrxComponent pnacl_component;
pnacl_component.version = current_version();
pnacl_component.name = "pnacl";
pnacl_component.installer = this;
pnacl_component.observer = updater_observer_.get();
pnacl_component.fingerprint = current_fingerprint();
SetPnaclHash(&pnacl_component);

Expand Down Expand Up @@ -478,22 +438,3 @@ void PnaclComponentInstaller::ReRegisterPnacl() {
BrowserThread::UI, FROM_HERE,
base::Bind(&GetProfileInformation, this));
}

void PnaclComponentInstaller::RequestFirstInstall(const InstallCallback& cb) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Only one request can happen at once.
if (!install_callback_.is_null()) {
cb.Run(false);
return;
}
set_current_version(Version(kNullVersion));
CrxComponent pnacl_component = GetCrxComponent();
ComponentUpdateService::Status status = cus_->OnDemandUpdate(
GetCrxComponentID(pnacl_component));
if (status != ComponentUpdateService::kOk) {
cb.Run(false);
return;
}
install_callback_ = cb;
updater_observer_->EnsureObserving();
}
21 changes: 0 additions & 21 deletions chrome/browser/component_updater/pnacl/pnacl_component_installer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/version.h"
#include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h"
#include "chrome/browser/component_updater/pnacl/pnacl_updater_observer.h"

class CommandLine;

Expand Down Expand Up @@ -75,34 +74,14 @@ class PnaclComponentInstaller : public ComponentInstaller {

ComponentUpdateService* cus() const { return cus_; }

typedef base::Callback<void(bool)> InstallCallback;

// Ask the component updater service to do a first-install for PNaCl.
// The |installed| callback will be run with |true| on success,
// or run with |false| on an error. The callback is called on the UI thread.
void RequestFirstInstall(const InstallCallback& installed);

private:
friend class PnaclUpdaterObserver;

// Called when a RequestFirstInstall completed successfully.
void NotifyInstallSuccess();

// Called when a RequestFirstInstall will not happen, or an error occurred.
void NotifyInstallError();

bool per_user_;
bool updates_disabled_;
scoped_ptr<PnaclProfileObserver> profile_observer_;
base::FilePath current_profile_path_;
base::Version current_version_;
std::string current_fingerprint_;
ComponentUpdateService* cus_;
// The one callback to call when there is a RequestFirstInstall.
InstallCallback install_callback_;
// Component updater service observer, to determine when an on-demand
// install request failed.
scoped_ptr<PnaclUpdaterObserver> updater_observer_;
DISALLOW_COPY_AND_ASSIGN(PnaclComponentInstaller);
};

Expand Down
49 changes: 0 additions & 49 deletions chrome/browser/component_updater/pnacl/pnacl_updater_observer.cc

This file was deleted.

31 changes: 0 additions & 31 deletions chrome/browser/component_updater/pnacl/pnacl_updater_observer.h

This file was deleted.

10 changes: 0 additions & 10 deletions chrome/browser/nacl_host/nacl_browser_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ ppapi::host::HostFactory* NaClBrowserDelegateImpl::CreatePpapiHostFactory(
return new chrome::ChromeBrowserPepperHostFactory(ppapi_host);
}

void NaClBrowserDelegateImpl::TryInstallPnacl(
const base::Callback<void(bool)>& installed) {
PnaclComponentInstaller* pci =
g_browser_process->pnacl_component_installer();
if (pci)
pci->RequestFirstInstall(installed);
else
installed.Run(false);
}

void NaClBrowserDelegateImpl::SetDebugPatterns(std::string debug_patterns) {
if (!debug_patterns.empty() && debug_patterns[0] == '!') {
inverse_debug_patterns_ = true;
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/nacl_host/nacl_browser_delegate_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class NaClBrowserDelegateImpl : public NaClBrowserDelegate {
virtual std::string GetVersionString() const OVERRIDE;
virtual ppapi::host::HostFactory* CreatePpapiHostFactory(
content::BrowserPpapiHost* ppapi_host) OVERRIDE;
virtual void TryInstallPnacl(
const base::Callback<void(bool)>& installed) OVERRIDE;
virtual bool MapUrlToLocalFilePath(const GURL& url,
bool is_blocking,
base::FilePath* file_path) OVERRIDE;
Expand Down
44 changes: 0 additions & 44 deletions chrome/browser/nacl_host/nacl_file_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_browser_delegate.h"
#include "components/nacl/common/nacl_host_messages.h"
#include "components/nacl/common/pnacl_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
Expand All @@ -39,37 +38,6 @@ void NotifyRendererOfError(
nacl_host_message_filter->Send(reply_msg);
}

void TryInstallPnacl(
const nacl_file_host::InstallCallback& done_callback,
const nacl_file_host::InstallProgressCallback& progress_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// TODO(jvoung): Figure out a way to get progress events and
// call progress_callback.
nacl::NaClBrowser::GetDelegate()->TryInstallPnacl(done_callback);
}

void DoEnsurePnaclInstalled(
const nacl_file_host::InstallCallback& done_callback,
const nacl_file_host::InstallProgressCallback& progress_callback) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
// If already installed, return reply w/ success immediately.
base::FilePath pnacl_dir;
if (nacl::NaClBrowser::GetDelegate()->GetPnaclDirectory(&pnacl_dir)
&& !pnacl_dir.empty()
&& base::PathExists(pnacl_dir)) {
done_callback.Run(true);
return;
}

// Otherwise, request an install (but send some "unknown" progress first).
progress_callback.Run(nacl::PnaclInstallProgress::Unknown());
// 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));
}

bool PnaclDoOpenFile(const base::FilePath& file_to_open,
base::PlatformFile* out_file) {
base::PlatformFileError error_code;
Expand Down Expand Up @@ -186,18 +154,6 @@ void DoOpenNaClExecutableOnThreadPool(

namespace nacl_file_host {

void EnsurePnaclInstalled(
const InstallCallback& done_callback,
const InstallProgressCallback& progress_callback) {
if (!BrowserThread::PostBlockingPoolTask(
FROM_HERE,
base::Bind(&DoEnsurePnaclInstalled,
done_callback,
progress_callback))) {
done_callback.Run(false);
}
}

void GetReadonlyPnaclFd(
scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
const std::string& filename,
Expand Down
17 changes: 0 additions & 17 deletions chrome/browser/nacl_host/nacl_file_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <string>

#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"

class GURL;
Expand All @@ -21,25 +20,9 @@ namespace IPC {
class Message;
}

namespace nacl {
struct PnaclInstallProgress;
}

// Opens NaCl Files in the Browser process, on behalf of the NaCl plugin.

namespace nacl_file_host {
typedef base::Callback<void(bool)> InstallCallback;
typedef base::Callback<void(const nacl::PnaclInstallProgress&)>
InstallProgressCallback;

// Ensure that PNaCl is installed. Calls |done_callback| if PNaCl is already
// installed. Otherwise, issues a request to install and calls |done_callback|
// after that request completes w/ success or failure.
// If a request to install is issued, then |progress_callback| is called
// with progress updates.
void EnsurePnaclInstalled(
const InstallCallback& done_callback,
const InstallProgressCallback& progress_callback);

// Open a PNaCl file (readonly) on behalf of the NaCl plugin.
void GetReadonlyPnaclFd(
Expand Down
Loading

0 comments on commit 355c3aa

Please sign in to comment.