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

Unified Diff: chrome/browser/extensions/app_host/binaries_installer.cc

Issue 10825364: Upon execution of the App Host, ask Omaha to install the Chrome Binaries if they are not present on… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More wood behind fewer return statements. Created 8 years, 4 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: 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..6c501b098355f25c2663e41562a199b4e145e7b2
--- /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 "base/win/scoped_com_initializer.h"
+#include "chrome/browser/extensions/app_host/binaries_installer_internal.h"
+#include "google_update/google_update_idl.h"
miket_OOO 2012/08/23 23:51:01 Please alphabetize.
erikwright (departed) 2012/08/31 21:04:48 Done.
+
+using base::win::ScopedBstr;
+using base::win::ScopedComPtr;
+
+namespace app_host {
+
+namespace {
+const int kInstallationPollingIntervalMs = 50;
+} // namespace
miket_OOO 2012/08/23 23:51:01 You can leave out the closing comment in short cas
+
+// Attempts to install the Chrome Binaries using the IGoogleUpdate3 interface.
+// Blocks until the installation process completes, without message pumping.
+HRESULT InstallBinaries() {
+ base::win::ScopedCOMInitializer initialize_com;
+
+ HRESULT hr = S_OK;
+ if (!initialize_com.succeeded()) {
+ LOG(ERROR) << "COM initialization failed";
+ hr = E_FAIL;
+ }
miket_OOO 2012/08/23 23:51:01 Since you're not early-returning on failure, I exp
erikwright (departed) 2012/08/31 21:04:48 Other reviewer's (robertshield) preference to mini
+
+ 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)) {
miket_OOO 2012/08/23 23:51:01 Is this guaranteed to return true eventually? If n
erikwright (departed) 2012/08/31 21:04:48 Yes, the assumption is that Omaha has appropriate
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
+ kInstallationPollingIntervalMs));
+ }
+ }
+
+ return hr;
+}
+
+} // namespace app_host

Powered by Google App Engine
This is Rietveld 408576698