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

Unified Diff: chrome/browser/history/history_publisher_win.cc

Issue 10991052: Miscellaneous tiny cleanups done while converting files to use ScopedCOMInitializer, pulled out sep… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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/history/history_publisher_win.cc
===================================================================
--- chrome/browser/history/history_publisher_win.cc (revision 158860)
+++ chrome/browser/history/history_publisher_win.cc (working copy)
@@ -20,36 +20,22 @@
namespace {
-// Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id
-// in |name| and returns the object in |indexer|. Returns false if the
-// operation fails.
-bool CoCreateIndexerFromName(const wchar_t* name,
- IChromeHistoryIndexer** indexer) {
- CLSID clsid;
- HRESULT hr = CLSIDFromString(const_cast<wchar_t*>(name), &clsid);
- if (FAILED(hr))
- return false;
- hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC,
- __uuidof(IChromeHistoryIndexer),
- reinterpret_cast<void**>(indexer));
- if (FAILED(hr))
- return false;
- return true;
-}
-
// Instantiates the registered indexers from the registry |root| + |path| key
// and adds them to the |indexers| list.
-void AddRegisteredIndexers(HKEY root, const wchar_t* path,
+void AddRegisteredIndexers(
+ HKEY root,
+ const wchar_t* path,
std::vector< base::win::ScopedComPtr<IChromeHistoryIndexer> >* indexers) {
- IChromeHistoryIndexer* indexer;
- base::win::RegistryKeyIterator r_iter(root, path);
- while (r_iter.Valid()) {
- if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) {
- indexers->push_back(
- base::win::ScopedComPtr<IChromeHistoryIndexer>(indexer));
- indexer->Release();
+ for (base::win::RegistryKeyIterator r_iter(root, path); r_iter.Valid();
+ ++r_iter) {
+ CLSID clsid;
+ if (FAILED(CLSIDFromString(const_cast<wchar_t*>(r_iter.Name()), &clsid)))
+ continue;
+ base::win::ScopedComPtr<IChromeHistoryIndexer> indexer;
+ if (SUCCEEDED(indexer.CreateInstance(clsid, NULL, CLSCTX_INPROC))) {
+ indexers->push_back(indexer);
+ indexer.Release();
}
- ++r_iter;
}
}

Powered by Google App Engine
This is Rietveld 408576698