OLD | NEW |
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 git->CreateInstance(CLSID_StdGlobalInterfaceTable, NULL, |
136 CLSCTX_INPROC_SERVER); | 136 CLSCTX_INPROC_SERVER); |
137 } | 137 } |
138 | 138 |
139 // Retrieves an interface pointer from the process GIT for a given |cookie|. | 139 // Retrieves an interface pointer from the process GIT for a given |cookie|. |
140 template <typename T> | 140 HRESULT GetInterfaceFromGit(IGlobalInterfaceTable* git, |
141 HRESULT GetInterfaceFromGit(const ScopedComPtr<IGlobalInterfaceTable>& git, | |
142 DWORD cookie, | 141 DWORD cookie, |
143 ScopedComPtr<T>* p) { | 142 REFIID riid, |
144 return git->GetInterfaceFromGlobal(cookie, IID_PPV_ARGS(p)); | 143 void** ppv) { |
| 144 return git->GetInterfaceFromGlobal(cookie, riid, ppv); |
145 } | 145 } |
146 | 146 |
147 // Registers an interface pointer in GIT and returns its corresponding |cookie|. | 147 // Registers an interface pointer in GIT and returns its corresponding |cookie|. |
148 template <typename T> | 148 template <typename T> |
149 HRESULT RegisterInterfaceInGit(const ScopedComPtr<IGlobalInterfaceTable>& git, | 149 HRESULT RegisterInterfaceInGit(const ScopedComPtr<IGlobalInterfaceTable>& git, |
150 const ScopedComPtr<T>& p, | 150 const ScopedComPtr<T>& p, |
151 DWORD* cookie) { | 151 DWORD* cookie) { |
152 return git->RegisterInterfaceInGlobal(p.Get(), __uuidof(T), cookie); | 152 return git->RegisterInterfaceInGlobal(p.Get(), __uuidof(T), cookie); |
153 } | 153 } |
154 | 154 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 836 |
837 HRESULT BackgroundDownloader::UpdateInterfacePointers() { | 837 HRESULT BackgroundDownloader::UpdateInterfacePointers() { |
838 DCHECK(task_runner()->RunsTasksOnCurrentThread()); | 838 DCHECK(task_runner()->RunsTasksOnCurrentThread()); |
839 | 839 |
840 ScopedComPtr<IGlobalInterfaceTable> git; | 840 ScopedComPtr<IGlobalInterfaceTable> git; |
841 HRESULT hr = GetGit(&git); | 841 HRESULT hr = GetGit(&git); |
842 if (FAILED(hr)) | 842 if (FAILED(hr)) |
843 return hr; | 843 return hr; |
844 | 844 |
845 bits_manager_ = nullptr; | 845 bits_manager_ = nullptr; |
846 hr = GetInterfaceFromGit(git, git_cookie_bits_manager_, &bits_manager_); | 846 hr = GetInterfaceFromGit(git.Get(), git_cookie_bits_manager_, |
| 847 IID_PPV_ARGS(&bits_manager_)); |
847 if (FAILED(hr)) | 848 if (FAILED(hr)) |
848 return hr; | 849 return hr; |
849 | 850 |
850 job_ = nullptr; | 851 job_ = nullptr; |
851 hr = GetInterfaceFromGit(git, git_cookie_job_, &job_); | 852 hr = GetInterfaceFromGit(git.Get(), git_cookie_job_, IID_PPV_ARGS(&job_)); |
852 if (FAILED(hr)) | 853 if (FAILED(hr)) |
853 return hr; | 854 return hr; |
854 | 855 |
855 return S_OK; | 856 return S_OK; |
856 } | 857 } |
857 | 858 |
858 void BackgroundDownloader::ResetInterfacePointers() { | 859 void BackgroundDownloader::ResetInterfacePointers() { |
859 job_ = nullptr; | 860 job_ = nullptr; |
860 bits_manager_ = nullptr; | 861 bits_manager_ = nullptr; |
861 } | 862 } |
(...skipping 14 matching lines...) Expand all Loading... |
876 | 877 |
877 for (auto cookie : cookies) { | 878 for (auto cookie : cookies) { |
878 // TODO(sorin): check the result of the call, see crbug.com/644857. | 879 // TODO(sorin): check the result of the call, see crbug.com/644857. |
879 git->RevokeInterfaceFromGlobal(cookie); | 880 git->RevokeInterfaceFromGlobal(cookie); |
880 } | 881 } |
881 | 882 |
882 return S_OK; | 883 return S_OK; |
883 } | 884 } |
884 | 885 |
885 } // namespace update_client | 886 } // namespace update_client |
OLD | NEW |