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

Unified Diff: remoting/host/plugin/daemon_installer_win.cc

Issue 10532099: Switching to IDispatch::Invoke when calling Omaha interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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: remoting/host/plugin/daemon_installer_win.cc
diff --git a/remoting/host/plugin/daemon_installer_win.cc b/remoting/host/plugin/daemon_installer_win.cc
index b5023144cffa5ca7dd1555f93c64e61d7564d4fb..a78420bf66f0aaa0173ffcb810b92be8e4cd5782 100644
--- a/remoting/host/plugin/daemon_installer_win.cc
+++ b/remoting/host/plugin/daemon_installer_win.cc
@@ -19,6 +19,8 @@
#include "base/win/scoped_bstr.h"
#include "base/win/scoped_comptr.h"
#include "base/win/scoped_handle.h"
+#include "base/win/scoped_variant.h"
+#include "remoting/base/dispatch_win.h"
namespace omaha {
#include "google_update/google_update_idl.h"
@@ -28,6 +30,7 @@ namespace omaha {
using base::win::ScopedBstr;
using base::win::ScopedComPtr;
+using base::win::ScopedVariant;
namespace {
@@ -63,7 +66,7 @@ namespace remoting {
// per-machine Omaha instance.
class DaemonComInstallerWin : public DaemonInstallerWin {
public:
- DaemonComInstallerWin(const ScopedComPtr<omaha::IGoogleUpdate3Web>& update3,
+ DaemonComInstallerWin(const ScopedComPtr<IDispatch>& update3,
const CompletionCallback& done);
// DaemonInstallerWin implementation.
@@ -75,9 +78,9 @@ class DaemonComInstallerWin : public DaemonInstallerWin {
void PollInstallationStatus();
// Omaha interfaces.
- ScopedComPtr<omaha::IAppWeb> app_;
- ScopedComPtr<omaha::IAppBundleWeb> bundle_;
- ScopedComPtr<omaha::IGoogleUpdate3Web> update3_;
+ ScopedVariant app_;
+ ScopedVariant bundle_;
+ ScopedComPtr<IDispatch> update3_;
base::Timer polling_timer_;
};
@@ -106,7 +109,7 @@ class DaemonCommandLineInstallerWin
};
DaemonComInstallerWin::DaemonComInstallerWin(
- const ScopedComPtr<omaha::IGoogleUpdate3Web>& update3,
+ const ScopedComPtr<IDispatch>& update3,
const CompletionCallback& done)
: DaemonInstallerWin(done),
update3_(update3),
@@ -121,52 +124,50 @@ DaemonComInstallerWin::DaemonComInstallerWin(
void DaemonComInstallerWin::Install() {
// Create an app bundle.
- ScopedComPtr<IDispatch> dispatch;
- HRESULT hr = update3_->createAppBundleWeb(dispatch.Receive());
+ HRESULT hr = dispatch::Invoke(update3_.get(), L"createAppBundleWeb",
+ DISPATCH_METHOD, bundle_.Receive());
if (FAILED(hr)) {
Done(hr);
return;
}
-
- hr = dispatch.QueryInterface(omaha::IID_IAppBundleWeb, bundle_.ReceiveVoid());
- if (FAILED(hr)) {
- Done(hr);
+ if (bundle_.type() != VT_DISPATCH) {
+ Done(DISP_E_TYPEMISMATCH);
return;
}
- hr = bundle_->initialize();
+ hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"initialize", DISPATCH_METHOD,
+ NULL);
if (FAILED(hr)) {
Done(hr);
return;
}
// Add Chromoting Host to the bundle.
- ScopedBstr appid(kHostOmahaAppid);
- ScopedBstr empty(kOmahaEmpty);
- ScopedBstr language(kOmahaLanguage);
- hr = bundle_->createApp(appid, empty, language, empty);
+ ScopedVariant appid(kHostOmahaAppid);
+ ScopedVariant empty(kOmahaEmpty);
+ ScopedVariant language(kOmahaLanguage);
+ hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"createApp", DISPATCH_METHOD,
+ appid, empty, language, empty, NULL);
if (FAILED(hr)) {
Done(hr);
return;
}
- hr = bundle_->checkForUpdate();
+ hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"checkForUpdate",
+ DISPATCH_METHOD, NULL);
if (FAILED(hr)) {
Done(hr);
return;
}
- dispatch.Release();
- hr = bundle_->get_appWeb(0, dispatch.Receive());
+ hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"appWeb",
+ DISPATCH_PROPERTYGET, ScopedVariant(0), app_.Receive());
if (FAILED(hr)) {
Done(hr);
return;
}
-
- hr = dispatch.QueryInterface(omaha::IID_IAppWeb,
- app_.ReceiveVoid());
- if (FAILED(hr)) {
- Done(hr);
+ if (app_.type() != VT_DISPATCH) {
+ Done(DISP_E_TYPEMISMATCH);
return;
}
@@ -179,30 +180,32 @@ void DaemonComInstallerWin::PollInstallationStatus() {
// N.B. The object underlying the ICurrentState interface has static data that
// does not get updated as the server state changes. To get the most "current"
// state, the currentState property needs to be queried again.
- ScopedComPtr<IDispatch> dispatch;
- HRESULT hr = app_->get_currentState(dispatch.Receive());
+ ScopedVariant current_state;
+ HRESULT hr = dispatch::Invoke(V_DISPATCH(&app_), L"currentState",
+ DISPATCH_PROPERTYGET, current_state.Receive());
if (FAILED(hr)) {
Done(hr);
return;
}
-
- ScopedComPtr<omaha::ICurrentState> current_state;
- hr = dispatch.QueryInterface(omaha::IID_ICurrentState,
- current_state.ReceiveVoid());
- if (FAILED(hr)) {
- Done(hr);
+ if (current_state.type() != VT_DISPATCH) {
+ Done(DISP_E_TYPEMISMATCH);
return;
}
- LONG state;
- hr = current_state->get_stateValue(&state);
+ ScopedVariant state;
+ hr = dispatch::Invoke(V_DISPATCH(&current_state), L"stateValue",
+ DISPATCH_PROPERTYGET, state.Receive());
if (FAILED(hr)) {
Done(hr);
return;
}
+ if (state.type() != VT_I4) {
+ Done(DISP_E_TYPEMISMATCH);
+ return;
+ }
// Perform state-specific actions.
- switch (state) {
+ switch (V_I4(&state)) {
case omaha::STATE_INIT:
case omaha::STATE_WAITING_TO_CHECK_FOR_UPDATE:
case omaha::STATE_CHECKING_FOR_UPDATE:
@@ -215,7 +218,8 @@ void DaemonComInstallerWin::PollInstallationStatus() {
break;
case omaha::STATE_UPDATE_AVAILABLE:
- hr = bundle_->download();
+ hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"download",
+ DISPATCH_METHOD, NULL);
if (FAILED(hr)) {
Done(hr);
return;
@@ -226,7 +230,8 @@ void DaemonComInstallerWin::PollInstallationStatus() {
case omaha::STATE_EXTRACTING:
case omaha::STATE_APPLYING_DIFFERENTIAL_PATCH:
case omaha::STATE_READY_TO_INSTALL:
- hr = bundle_->install();
+ hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"install",
+ DISPATCH_METHOD, NULL);
if (FAILED(hr)) {
Done(hr);
return;
@@ -240,17 +245,23 @@ void DaemonComInstallerWin::PollInstallationStatus() {
return;
case omaha::STATE_ERROR: {
- HRESULT error_code;
- hr = current_state->get_errorCode(&error_code);
+ ScopedVariant error_code;
+ hr = dispatch::Invoke(V_DISPATCH(&current_state), L"errorCode",
+ DISPATCH_PROPERTYGET, error_code.Receive());
if (FAILED(hr)) {
- error_code = hr;
+ Done(hr);
+ return;
+ }
+ if (error_code.type() != VT_UI4) {
+ Done(DISP_E_TYPEMISMATCH);
+ return;
}
- Done(error_code);
+ Done(V_UI4(&error_code));
return;
}
default:
- LOG(ERROR) << "Unknown bundle state: " << state << ".";
+ LOG(ERROR) << "Unknown bundle state: " << V_I4(&state) << ".";
Done(E_FAIL);
return;
}
@@ -339,11 +350,11 @@ scoped_ptr<DaemonInstallerWin> DaemonInstallerWin::Create(
bind_options.hwnd = GetTopLevelWindow(window_handle);
bind_options.dwClassContext = CLSCTX_LOCAL_SERVER;
- ScopedComPtr<omaha::IGoogleUpdate3Web> update3;
+ ScopedComPtr<IDispatch> update3;
HRESULT result = ::CoGetObject(
kOmahaElevationMoniker,
&bind_options,
- omaha::IID_IGoogleUpdate3Web,
+ IID_IDispatch,
update3.ReceiveVoid());
if (SUCCEEDED(result)) {
// The machine instance of Omaha is available and we successfully passed

Powered by Google App Engine
This is Rietveld 408576698