| 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/base/omaha_version.h" | |
| 17 #include "omaha/base/app_util.h" | |
| 18 #include "omaha/base/debug.h" | |
| 19 #include "omaha/base/file_ver.h" | |
| 20 #include "omaha/base/logging.h" | |
| 21 #include "omaha/base/utils.h" | |
| 22 | |
| 23 namespace { | |
| 24 | |
| 25 // The version string is not visible outside this module and it is only | |
| 26 // accessible through the omaha::GetVersionString accessor. | |
| 27 CString version_string; | |
| 28 | |
| 29 ULONGLONG omaha_version = 0; | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 33 namespace omaha { | |
| 34 | |
| 35 // In both GetVersion* methods, we assert only that InitializeVersion* was | |
| 36 // already called and not that they weren't called twice, which is OK. | |
| 37 // There is no detection that the version_ variables aren't accessed before | |
| 38 // being initialized because this would require accessor methods to enforce and | |
| 39 // lead to bloat. | |
| 40 | |
| 41 const TCHAR* GetVersionString() { | |
| 42 ASSERT1(!version_string.IsEmpty()); | |
| 43 return version_string; | |
| 44 } | |
| 45 | |
| 46 ULONGLONG GetVersion() { | |
| 47 ASSERT1(!version_string.IsEmpty()); | |
| 48 return omaha_version; | |
| 49 } | |
| 50 | |
| 51 void InitializeVersionFromModule(HINSTANCE instance) { | |
| 52 ULONGLONG module_version = app_util::GetVersionFromModule(instance); | |
| 53 | |
| 54 InitializeVersion(module_version); | |
| 55 } | |
| 56 | |
| 57 void InitializeVersion(ULONGLONG version) { | |
| 58 omaha_version = version; | |
| 59 | |
| 60 version_string = StringFromVersion(omaha_version); | |
| 61 } | |
| 62 | |
| 63 } // namespace omaha | |
| OLD | NEW |