diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 03:46:05 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 03:46:05 +0000 |
commit | ce0e7246e92f2da8e6b865dd51ae626f9867ca4f (patch) | |
tree | 8181f26fbe349c35ff37a9ae837603c3f11be7f8 /chrome/installer/util/wmi.cc | |
parent | 21e74460f5b7cfe6f622557b20d40eecf3b8e98b (diff) | |
download | chromium_src-ce0e7246e92f2da8e6b865dd51ae626f9867ca4f.zip chromium_src-ce0e7246e92f2da8e6b865dd51ae626f9867ca4f.tar.gz chromium_src-ce0e7246e92f2da8e6b865dd51ae626f9867ca4f.tar.bz2 |
Move the windows-specific scoped_* stuff from base to base/win and in the base::win namespace.
This keeps old headers that forward to the new versions and have using declarations that allow the existing code to compile. I fixed all the callers in base to use the new ones, and also the other files I happened to touch.
This splits out the stuff from scoped_handle into a few separate files. I just deleted ScopedFindFile since it was only used in one place and it wasn't even really helping there.
I removed StackBstr which was a #define and used the "regular" ScopedBstr in the 7 places that used it. This is an optimization to avoid an extra allocation, but none of the callers are remotely performance critical.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3781009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62843 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/wmi.cc')
-rw-r--r-- | chrome/installer/util/wmi.cc | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/chrome/installer/util/wmi.cc b/chrome/installer/util/wmi.cc index 957ec99..fca2076 100644 --- a/chrome/installer/util/wmi.cc +++ b/chrome/installer/util/wmi.cc @@ -7,8 +7,8 @@ #include <windows.h> #include "base/basictypes.h" -#include "base/scoped_bstr_win.h" -#include "base/scoped_comptr_win.h" +#include "base/win/scoped_bstr.h" +#include "base/win/scoped_comptr.h" #pragma comment(lib, "wbemuuid.lib") @@ -37,15 +37,16 @@ class VariantHelper : public VARIANT { bool WMI::CreateLocalConnection(bool set_blanket, IWbemServices** wmi_services) { - ScopedComPtr<IWbemLocator> wmi_locator; + base::win::ScopedComPtr<IWbemLocator> wmi_locator; HRESULT hr = wmi_locator.CreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER); if (FAILED(hr)) return false; - ScopedComPtr<IWbemServices> wmi_services_r; - hr = wmi_locator->ConnectServer(StackBstr(L"ROOT\\CIMV2"), NULL, NULL, 0, - NULL, 0, 0, wmi_services_r.Receive()); + base::win::ScopedComPtr<IWbemServices> wmi_services_r; + hr = wmi_locator->ConnectServer(base::win::ScopedBstr(L"ROOT\\CIMV2"), + NULL, NULL, 0, NULL, 0, 0, + wmi_services_r.Receive()); if (FAILED(hr)) return false; @@ -72,16 +73,16 @@ bool WMI::CreateClassMethodObject(IWbemServices* wmi_services, IWbemClassObject** class_instance) { // We attempt to instantiate a COM object that represents a WMI object plus // a method rolled into one entity. - ScopedBstr b_class_name(class_name.c_str()); - ScopedBstr b_method_name(method_name.c_str()); - ScopedComPtr<IWbemClassObject> class_object; + base::win::ScopedBstr b_class_name(class_name.c_str()); + base::win::ScopedBstr b_method_name(method_name.c_str()); + base::win::ScopedComPtr<IWbemClassObject> class_object; HRESULT hr; hr = wmi_services->GetObject(b_class_name, 0, NULL, class_object.Receive(), NULL); if (FAILED(hr)) return false; - ScopedComPtr<IWbemClassObject> params_def; + base::win::ScopedComPtr<IWbemClassObject> params_def; hr = class_object->GetMethod(b_method_name, 0, params_def.Receive(), NULL); if (FAILED(hr)) return false; @@ -108,13 +109,13 @@ bool SetParameter(IWbemClassObject* class_method, // http://msdn2.microsoft.com/en-us/library/aa389388(VS.85).aspx bool WMIProcess::Launch(const std::wstring& command_line, int* process_id) { - ScopedComPtr<IWbemServices> wmi_local; + base::win::ScopedComPtr<IWbemServices> wmi_local; if (!WMI::CreateLocalConnection(true, wmi_local.Receive())) return false; const wchar_t class_name[] = L"Win32_Process"; const wchar_t method_name[] = L"Create"; - ScopedComPtr<IWbemClassObject> process_create; + base::win::ScopedComPtr<IWbemClassObject> process_create; if (!WMI::CreateClassMethodObject(wmi_local, class_name, method_name, process_create.Receive())) return false; @@ -125,11 +126,11 @@ bool WMIProcess::Launch(const std::wstring& command_line, int* process_id) { if (!SetParameter(process_create, L"CommandLine", &b_command_line)) return false; - ScopedComPtr<IWbemClassObject> out_params; - HRESULT hr = wmi_local->ExecMethod(StackBstr(class_name), - StackBstr(method_name), 0, NULL, - process_create, out_params.Receive(), - NULL); + base::win::ScopedComPtr<IWbemClassObject> out_params; + HRESULT hr = wmi_local->ExecMethod(base::win::ScopedBstr(class_name), + base::win::ScopedBstr(method_name), + 0, NULL, process_create, + out_params.Receive(), NULL); if (FAILED(hr)) return false; |