| OLD | NEW |
| (Empty) |
| 1 // Copyright 2007-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 #include "omaha/net/winhttp_vtable.h" | |
| 17 | |
| 18 namespace omaha { | |
| 19 | |
| 20 bool WinHttpVTable::Load() { | |
| 21 if (IsLoaded()) { | |
| 22 return true; | |
| 23 } | |
| 24 Clear(); | |
| 25 library_ = ::LoadLibrary(_T("winhttp")); | |
| 26 if (!library_) { | |
| 27 library_ = ::LoadLibrary(_T("winhttp5")); | |
| 28 if (!library_) { | |
| 29 return false; | |
| 30 } | |
| 31 } | |
| 32 bool is_valid = | |
| 33 GPA("WinHttpAddRequestHeaders", &WinHttpAddRequestHeaders_pointer) && | |
| 34 GPA("WinHttpCheckPlatform", &WinHttpCheckPlatform_pointer) && | |
| 35 GPA("WinHttpCloseHandle", &WinHttpCloseHandle_pointer) && | |
| 36 GPA("WinHttpConnect", &WinHttpConnect_pointer) && | |
| 37 GPA("WinHttpCrackUrl", &WinHttpCrackUrl_pointer) && | |
| 38 GPA("WinHttpCreateUrl", &WinHttpCreateUrl_pointer) && | |
| 39 GPA("WinHttpDetectAutoProxyConfigUrl", &WinHttpDetectAutoProxyConfigUrl_poi
nter) && // NOLINT | |
| 40 GPA("WinHttpGetIEProxyConfigForCurrentUser", &WinHttpGetIEProxyConfigForCur
rentUser_pointer) && // NOLINT | |
| 41 GPA("WinHttpGetDefaultProxyConfiguration", &WinHttpGetDefaultProxyConfigura
tion_pointer) && // NOLINT | |
| 42 GPA("WinHttpGetProxyForUrl", &WinHttpGetProxyForUrl_pointer) && | |
| 43 GPA("WinHttpOpen", &WinHttpOpen_pointer) && | |
| 44 GPA("WinHttpOpenRequest", &WinHttpOpenRequest_pointer) && | |
| 45 GPA("WinHttpQueryAuthSchemes", &WinHttpQueryAuthSchemes_pointer) && | |
| 46 GPA("WinHttpQueryDataAvailable", &WinHttpQueryDataAvailable_pointer) &
& // NOLINT | |
| 47 GPA("WinHttpQueryHeaders", &WinHttpQueryHeaders_pointer) && | |
| 48 GPA("WinHttpQueryOption", &WinHttpQueryOption_pointer) && | |
| 49 GPA("WinHttpReadData", &WinHttpReadData_pointer) && | |
| 50 GPA("WinHttpReceiveResponse", &WinHttpReceiveResponse_pointer) && | |
| 51 GPA("WinHttpSendRequest", &WinHttpSendRequest_pointer) && | |
| 52 GPA("WinHttpSetDefaultProxyConfiguration", &WinHttpSetDefaultProxyConfigura
tion_pointer) && // NOLINT | |
| 53 GPA("WinHttpSetCredentials", &WinHttpSetCredentials_pointer) && | |
| 54 GPA("WinHttpSetOption", &WinHttpSetOption_pointer) && | |
| 55 GPA("WinHttpSetStatusCallback", &WinHttpSetStatusCallback_pointer) && | |
| 56 GPA("WinHttpSetTimeouts", &WinHttpSetTimeouts_pointer) && | |
| 57 GPA("WinHttpWriteData", &WinHttpWriteData_pointer); | |
| 58 | |
| 59 if (!is_valid) { | |
| 60 Unload(); | |
| 61 } | |
| 62 return is_valid; | |
| 63 } | |
| 64 | |
| 65 void WinHttpVTable::Unload() { | |
| 66 if (library_) { | |
| 67 ::FreeLibrary(library_); | |
| 68 library_ = NULL; | |
| 69 } | |
| 70 Clear(); | |
| 71 } | |
| 72 | |
| 73 } // namespace omaha | |
| 74 | |
| OLD | NEW |