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

Unified Diff: chrome/installer/setup/setup_main.cc

Issue 11050009: Use ScopedCOMInitializer in more places. While this doesn't always simplify code, it does mean we … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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/installer/setup/setup_main.cc
===================================================================
--- chrome/installer/setup/setup_main.cc (revision 159813)
+++ chrome/installer/setup/setup_main.cc (working copy)
@@ -21,6 +21,7 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "base/win/registry.h"
+#include "base/win/scoped_com_initializer.h"
#include "base/win/scoped_comptr.h"
#include "base/win/scoped_handle.h"
#include "base/win/win_util.h"
@@ -1317,26 +1318,6 @@
return true;
}
-// Class to manage COM initialization and uninitialization
-class AutoCom {
- public:
- AutoCom() : initialized_(false) { }
- ~AutoCom() {
- if (initialized_) CoUninitialize();
- }
- bool Init(bool system_install) {
- if (CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) != S_OK) {
- LOG(ERROR) << "COM initialization failed.";
- return false;
- }
- initialized_ = true;
- return true;
- }
-
- private:
- bool initialized_;
-};
-
// Returns the Custom information for the client identified by the exe path
// passed in. This information is used for crash reporting.
google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) {
@@ -1444,8 +1425,8 @@
}
// Initialize COM for use later.
- AutoCom auto_com;
- if (!auto_com.Init(system_install)) {
+ base::win::ScopedCOMInitializer com_initializer;
+ if (!com_initializer.succeeded()) {
installer_state.WriteInstallerResult(
installer::OS_ERROR, IDS_INSTALL_OS_ERROR_BASE, NULL);
return installer::OS_ERROR;

Powered by Google App Engine
This is Rietveld 408576698