Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/install_static/install_details.h" | |
| 6 | |
| 7 #include <assert.h> | |
| 8 | |
| 9 #include <type_traits> | |
| 10 | |
| 11 #include "chrome/install_static/install_modes.h" | |
| 12 #include "chrome/install_static/install_util.h" | |
| 13 #include "chrome_elf/nt_registry/nt_registry.h" | |
| 14 | |
| 15 namespace install_static { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 // This module's instance. | |
| 
 
robertshield
2016/10/17 05:27:23
Comment here that this is intentionally leaked at
 
grt (UTC plus 2)
2016/10/24 11:17:51
Done.
 
 | |
| 20 InstallDetails* g_module_details = nullptr; | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 std::wstring InstallDetails::GetClientStateKeyPath(bool binaries) const { | |
| 25 return binaries && multi_install() | |
| 26 ? GetBinariesClientStateKeyPath() | |
| 27 : install_static::GetClientStateKeyPath(app_guid()); | |
| 28 } | |
| 29 | |
| 30 std::wstring InstallDetails::GetClientStateMediumKeyPath(bool binaries) const { | |
| 31 return binaries && multi_install() | |
| 32 ? GetBinariesClientStateMediumKeyPath() | |
| 33 : install_static::GetClientStateMediumKeyPath(app_guid()); | |
| 34 } | |
| 35 | |
| 36 // static | |
| 37 const InstallDetails& InstallDetails::Get() { | |
| 38 assert(g_module_details); | |
| 39 return *g_module_details; | |
| 40 } | |
| 41 | |
| 42 // static | |
| 43 void InstallDetails::SetForProcess( | |
| 44 std::unique_ptr<PrimaryInstallDetails> details) { | |
| 45 assert(!details || !g_module_details); | |
| 46 // Intentionally leaked at shutdown. | |
| 47 g_module_details = details.release(); | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 intptr_t InstallDetails::GetPayload() { | |
| 52 assert(g_module_details); | |
| 53 static_assert(std::is_pod<Payload>::value, "Payload must be a POD-struct"); | |
| 54 static_assert(std::is_pod<InstallConstants>::value, | |
| 55 "InstallConstants must be a POD-struct"); | |
| 56 return reinterpret_cast<intptr_t>(g_module_details->payload_); | |
| 57 } | |
| 58 | |
| 59 // static | |
| 60 void InstallDetails::ImportFromModule(const wchar_t* module_name, | |
| 61 const char* export_name) { | |
| 62 assert(!g_module_details); | |
| 63 using GetInstallDetailsPayloadFunction = intptr_t(__cdecl*)(); | |
| 64 GetInstallDetailsPayloadFunction payload_getter = | |
| 65 reinterpret_cast<GetInstallDetailsPayloadFunction>( | |
| 66 ::GetProcAddress(::GetModuleHandle(module_name), export_name)); | |
| 67 assert(payload_getter); | |
| 68 // Intentionally leaked at shutdown. | |
| 69 g_module_details = | |
| 70 new InstallDetails(reinterpret_cast<Payload*>(payload_getter())); | |
| 71 } | |
| 72 | |
| 73 } // namespace install_static | |
| OLD | NEW |