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

Side by Side Diff: chrome/browser/metrics/antivirus_metrics_provider_win.cc

Issue 2870263002: Rename ScopedComPtr::Receive to ScopedComPtr::GetAddressOf (Closed)
Patch Set: Rebase to 2a6f440 Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h" 5 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h"
6 6
7 #include <iwscapi.h> 7 #include <iwscapi.h>
8 #include <objbase.h> 8 #include <objbase.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <wbemidl.h> 10 #include <wbemidl.h>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 base::win::ScopedComPtr<IWbemLocator> wmi_locator; 341 base::win::ScopedComPtr<IWbemLocator> wmi_locator;
342 HRESULT hr = wmi_locator.CreateInstance(CLSID_WbemLocator, nullptr, 342 HRESULT hr = wmi_locator.CreateInstance(CLSID_WbemLocator, nullptr,
343 CLSCTX_INPROC_SERVER); 343 CLSCTX_INPROC_SERVER);
344 if (FAILED(hr)) 344 if (FAILED(hr))
345 return RESULT_FAILED_TO_CREATE_INSTANCE; 345 return RESULT_FAILED_TO_CREATE_INSTANCE;
346 346
347 base::win::ScopedComPtr<IWbemServices> wmi_services; 347 base::win::ScopedComPtr<IWbemServices> wmi_services;
348 hr = wmi_locator->ConnectServer( 348 hr = wmi_locator->ConnectServer(
349 base::win::ScopedBstr(L"ROOT\\SecurityCenter2"), nullptr, nullptr, 349 base::win::ScopedBstr(L"ROOT\\SecurityCenter2"), nullptr, nullptr,
350 nullptr, 0, nullptr, nullptr, wmi_services.Receive()); 350 nullptr, 0, nullptr, nullptr, wmi_services.GetAddressOf());
351 if (FAILED(hr)) 351 if (FAILED(hr))
352 return RESULT_FAILED_TO_CONNECT_TO_WMI; 352 return RESULT_FAILED_TO_CONNECT_TO_WMI;
353 353
354 hr = ::CoSetProxyBlanket(wmi_services.Get(), RPC_C_AUTHN_WINNT, 354 hr = ::CoSetProxyBlanket(wmi_services.Get(), RPC_C_AUTHN_WINNT,
355 RPC_C_AUTHZ_NONE, nullptr, RPC_C_AUTHN_LEVEL_CALL, 355 RPC_C_AUTHZ_NONE, nullptr, RPC_C_AUTHN_LEVEL_CALL,
356 RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, EOAC_NONE); 356 RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, EOAC_NONE);
357 if (FAILED(hr)) 357 if (FAILED(hr))
358 return RESULT_FAILED_TO_SET_SECURITY_BLANKET; 358 return RESULT_FAILED_TO_SET_SECURITY_BLANKET;
359 359
360 // This interface is available on Windows Vista and above, and is officially 360 // This interface is available on Windows Vista and above, and is officially
361 // undocumented. 361 // undocumented.
362 base::win::ScopedBstr query_language(L"WQL"); 362 base::win::ScopedBstr query_language(L"WQL");
363 base::win::ScopedBstr query(L"SELECT * FROM AntiVirusProduct"); 363 base::win::ScopedBstr query(L"SELECT * FROM AntiVirusProduct");
364 base::win::ScopedComPtr<IEnumWbemClassObject> enumerator; 364 base::win::ScopedComPtr<IEnumWbemClassObject> enumerator;
365 365
366 hr = wmi_services->ExecQuery( 366 hr = wmi_services->ExecQuery(
367 query_language, query, 367 query_language, query,
368 WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr, 368 WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr,
369 enumerator.Receive()); 369 enumerator.GetAddressOf());
370 if (FAILED(hr)) 370 if (FAILED(hr))
371 return RESULT_FAILED_TO_EXEC_WMI_QUERY; 371 return RESULT_FAILED_TO_EXEC_WMI_QUERY;
372 372
373 // Iterate over the results of the WMI query. Each result will be an 373 // Iterate over the results of the WMI query. Each result will be an
374 // AntiVirusProduct instance. 374 // AntiVirusProduct instance.
375 while (true) { 375 while (true) {
376 base::win::ScopedComPtr<IWbemClassObject> class_object; 376 base::win::ScopedComPtr<IWbemClassObject> class_object;
377 ULONG items_returned = 0; 377 ULONG items_returned = 0;
378 hr = enumerator->Next(WBEM_INFINITE, 1, class_object.Receive(), 378 hr = enumerator->Next(WBEM_INFINITE, 1, class_object.GetAddressOf(),
379 &items_returned); 379 &items_returned);
380 if (FAILED(hr)) 380 if (FAILED(hr))
381 return RESULT_FAILED_TO_ITERATE_RESULTS; 381 return RESULT_FAILED_TO_ITERATE_RESULTS;
382 382
383 if (hr == WBEM_S_FALSE || items_returned == 0) 383 if (hr == WBEM_S_FALSE || items_returned == 0)
384 break; 384 break;
385 385
386 AvProduct av_product; 386 AvProduct av_product;
387 av_product.set_product_state( 387 av_product.set_product_state(
388 metrics::SystemProfileProto::AntiVirusState:: 388 metrics::SystemProfileProto::AntiVirusState::
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 std::string product_name("Trusteer Endpoint Protection"); 499 std::string product_name("Trusteer Endpoint Protection");
500 if (ShouldReportFullNames()) { 500 if (ShouldReportFullNames()) {
501 av_product.set_product_name(product_name); 501 av_product.set_product_name(product_name);
502 av_product.set_product_version(product_version); 502 av_product.set_product_version(product_version);
503 } 503 }
504 av_product.set_product_name_hash(metrics::HashName(product_name)); 504 av_product.set_product_name_hash(metrics::HashName(product_name));
505 av_product.set_product_version_hash(metrics::HashName(product_version)); 505 av_product.set_product_version_hash(metrics::HashName(product_version));
506 506
507 products->push_back(av_product); 507 products->push_back(av_product);
508 } 508 }
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/win/mtp_device_operations_util.cc ('k') | chrome/browser/platform_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698