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

Side by Side Diff: components/update_client/background_downloader_win.cc

Issue 2887243002: Remove ScopedComPtr::CreateInstance() (Closed)
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/update_client/background_downloader_win.h" 5 #include "components/update_client/background_downloader_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <objbase.h> 9 #include <objbase.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // How often the jobs which were started but not completed for any reason 125 // How often the jobs which were started but not completed for any reason
126 // are cleaned up. Reasons for jobs to be left behind include browser restarts, 126 // are cleaned up. Reasons for jobs to be left behind include browser restarts,
127 // system restarts, etc. Also, the check to purge stale jobs only happens 127 // system restarts, etc. Also, the check to purge stale jobs only happens
128 // at most once a day. If the job clean up code is not running, the BITS 128 // at most once a day. If the job clean up code is not running, the BITS
129 // default policy is to cancel jobs after 90 days of inactivity. 129 // default policy is to cancel jobs after 90 days of inactivity.
130 const int kPurgeStaleJobsAfterDays = 7; 130 const int kPurgeStaleJobsAfterDays = 7;
131 const int kPurgeStaleJobsIntervalBetweenChecksDays = 1; 131 const int kPurgeStaleJobsIntervalBetweenChecksDays = 1;
132 132
133 // Retrieves the singleton instance of GIT for this process. 133 // Retrieves the singleton instance of GIT for this process.
134 HRESULT GetGit(ScopedComPtr<IGlobalInterfaceTable>* git) { 134 HRESULT GetGit(ScopedComPtr<IGlobalInterfaceTable>* git) {
135 return git->CreateInstance(CLSID_StdGlobalInterfaceTable, NULL, 135 return ::CoCreateInstance(CLSID_StdGlobalInterfaceTable, NULL,
136 CLSCTX_INPROC_SERVER); 136 CLSCTX_INPROC_SERVER,
137 IID_PPV_ARGS(git->GetAddressOf()));
137 } 138 }
138 139
139 // Retrieves an interface pointer from the process GIT for a given |cookie|. 140 // Retrieves an interface pointer from the process GIT for a given |cookie|.
140 HRESULT GetInterfaceFromGit(IGlobalInterfaceTable* git, 141 HRESULT GetInterfaceFromGit(IGlobalInterfaceTable* git,
141 DWORD cookie, 142 DWORD cookie,
142 REFIID riid, 143 REFIID riid,
143 void** ppv) { 144 void** ppv) {
144 return git->GetInterfaceFromGlobal(cookie, riid, ppv); 145 return git->GetInterfaceFromGlobal(cookie, riid, ppv);
145 } 146 }
146 147
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 remote_name_.compare(name) == 0) 360 remote_name_.compare(name) == 0)
360 return true; 361 return true;
361 } 362 }
362 363
363 return false; 364 return false;
364 } 365 }
365 366
366 // Creates an instance of the BITS manager. 367 // Creates an instance of the BITS manager.
367 HRESULT CreateBitsManager(IBackgroundCopyManager** bits_manager) { 368 HRESULT CreateBitsManager(IBackgroundCopyManager** bits_manager) {
368 ScopedComPtr<IBackgroundCopyManager> object; 369 ScopedComPtr<IBackgroundCopyManager> object;
369 HRESULT hr = object.CreateInstance(__uuidof(BackgroundCopyManager)); 370 HRESULT hr = ::CoCreateInstance(__uuidof(BackgroundCopyManager), nullptr,
371 CLSCTX_ALL, IID_PPV_ARGS(&object));
370 if (FAILED(hr)) { 372 if (FAILED(hr)) {
371 return hr; 373 return hr;
372 } 374 }
373 *bits_manager = object.Detach(); 375 *bits_manager = object.Detach();
374 return S_OK; 376 return S_OK;
375 } 377 }
376 378
377 void CleanupJobFiles(IBackgroundCopyJob* job) { 379 void CleanupJobFiles(IBackgroundCopyJob* job) {
378 std::vector<ScopedComPtr<IBackgroundCopyFile>> files; 380 std::vector<ScopedComPtr<IBackgroundCopyFile>> files;
379 if (FAILED(GetFilesInJob(job, &files))) 381 if (FAILED(GetFilesInJob(job, &files)))
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 879
878 for (auto cookie : cookies) { 880 for (auto cookie : cookies) {
879 // TODO(sorin): check the result of the call, see crbug.com/644857. 881 // TODO(sorin): check the result of the call, see crbug.com/644857.
880 git->RevokeInterfaceFromGlobal(cookie); 882 git->RevokeInterfaceFromGlobal(cookie);
881 } 883 }
882 884
883 return S_OK; 885 return S_OK;
884 } 886 }
885 887
886 } // namespace update_client 888 } // namespace update_client
OLDNEW
« no previous file with comments | « components/storage_monitor/portable_device_watcher_win.cc ('k') | content/common/quarantine/quarantine_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698