Chromium Code Reviews| Index: chrome/browser/extensions/app_host/binaries_installer.cc |
| diff --git a/chrome/browser/extensions/app_host/binaries_installer.cc b/chrome/browser/extensions/app_host/binaries_installer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b78c83a140d6a4a6b86b4732411742447cb3854a |
| --- /dev/null |
| +++ b/chrome/browser/extensions/app_host/binaries_installer.cc |
| @@ -0,0 +1,72 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/app_host/binaries_installer.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/threading/platform_thread.h" |
| +#include "base/win/scoped_bstr.h" |
| +#include "base/win/scoped_comptr.h" |
| +#include "chrome/browser/extensions/app_host/binaries_installer_internal.h" |
| +#include "google_update/google_update_idl.h" |
| + |
| +using base::win::ScopedBstr; |
| +using base::win::ScopedComPtr; |
| + |
| +namespace app_host { |
| + |
| +namespace { |
| +const int kInstallationPollingIntervalMs = 50; |
| +} // namespace |
| + |
| +// Attempts to install the Chrome Binaries using the IGoogleUpdate3 interface. |
| +// Blocks until the installation process completes, without message pumping. |
|
robertshield
2012/08/16 13:08:16
What's the end state of the Omaha registry keys if
erikwright (departed)
2012/08/16 21:05:15
It's presumably the equivalent of a failure after
|
| +HRESULT InstallBinaries() { |
| + HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
|
robertshield
2012/08/16 13:08:16
Suggest using the stuff in base/win/scoped_com_ini
erikwright (departed)
2012/08/16 21:05:15
I was shocked such a thing didn't exist, but I gue
|
| + if (FAILED(hr)) { |
| + LOG(ERROR) << "CoInitializeEx failed: " << hr; |
| + return hr; |
| + } |
| + |
| + // After this point, don't return until CoUninitialize is called. |
| + |
| + ScopedComPtr<IGoogleUpdate3> update3; |
| + if (SUCCEEDED(hr)) { |
| + hr = internal::CreateGoogleUpdate3(update3.Receive()); |
| + } |
| + |
| + ScopedBstr ap_value; |
| + if (SUCCEEDED(hr)) { |
| + hr = internal::SelectBinariesApValue(update3, ap_value.Receive()); |
| + } |
| + |
| + ScopedComPtr<IAppBundle> app_bundle; |
| + if (SUCCEEDED(hr)) { |
| + hr = internal::CreateAppBundle(update3, app_bundle.Receive()); |
| + } |
| + |
| + ScopedComPtr<IApp> app; |
| + if (SUCCEEDED(hr)) { |
| + hr = internal::CreateBinariesIApp(app_bundle, ap_value, app.Receive()); |
| + } |
| + |
| + if (SUCCEEDED(hr)) { |
| + hr = app_bundle->checkForUpdate(); |
| + if (FAILED(hr)) { |
| + LOG(ERROR) << "Failed to initiate update check: " << hr; |
| + } |
| + } |
| + |
| + if (SUCCEEDED(hr)) { |
| + while (!internal::CheckIfDone(app_bundle, app, &hr)) { |
| + base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( |
| + kInstallationPollingIntervalMs)); |
| + } |
| + } |
| + |
| + ::CoUninitialize(); |
| + return hr; |
| +} |
| + |
| +} // namespace app_host |