OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/installer/setup/setup_main.h" | 5 #include "chrome/installer/setup/setup_main.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <msi.h> | 8 #include <msi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 #include <stddef.h> | 11 #include <stddef.h> |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/file_version_info.h" | 18 #include "base/file_version_info.h" |
19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
21 #include "base/files/scoped_temp_dir.h" | 21 #include "base/files/scoped_temp_dir.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/metrics/histogram_base.h" | |
25 #include "base/metrics/histogram_persistence.h" | |
26 #include "base/metrics/persistent_memory_allocator.h" | |
24 #include "base/path_service.h" | 27 #include "base/path_service.h" |
25 #include "base/process/launch.h" | 28 #include "base/process/launch.h" |
26 #include "base/process/memory.h" | 29 #include "base/process/memory.h" |
27 #include "base/strings/string16.h" | 30 #include "base/strings/string16.h" |
28 #include "base/strings/string_number_conversions.h" | 31 #include "base/strings/string_number_conversions.h" |
29 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
30 #include "base/strings/stringprintf.h" | 33 #include "base/strings/stringprintf.h" |
31 #include "base/strings/utf_string_conversions.h" | 34 #include "base/strings/utf_string_conversions.h" |
32 #include "base/values.h" | 35 #include "base/values.h" |
33 #include "base/version.h" | 36 #include "base/version.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
62 #include "chrome/installer/util/installer_state.h" | 65 #include "chrome/installer/util/installer_state.h" |
63 #include "chrome/installer/util/installer_util_strings.h" | 66 #include "chrome/installer/util/installer_util_strings.h" |
64 #include "chrome/installer/util/l10n_string_util.h" | 67 #include "chrome/installer/util/l10n_string_util.h" |
65 #include "chrome/installer/util/logging_installer.h" | 68 #include "chrome/installer/util/logging_installer.h" |
66 #include "chrome/installer/util/lzma_util.h" | 69 #include "chrome/installer/util/lzma_util.h" |
67 #include "chrome/installer/util/master_preferences.h" | 70 #include "chrome/installer/util/master_preferences.h" |
68 #include "chrome/installer/util/master_preferences_constants.h" | 71 #include "chrome/installer/util/master_preferences_constants.h" |
69 #include "chrome/installer/util/self_cleaning_temp_dir.h" | 72 #include "chrome/installer/util/self_cleaning_temp_dir.h" |
70 #include "chrome/installer/util/shell_util.h" | 73 #include "chrome/installer/util/shell_util.h" |
71 #include "chrome/installer/util/user_experiment.h" | 74 #include "chrome/installer/util/user_experiment.h" |
75 #include "chrome/installer/util/util_constants.h" | |
72 | 76 |
73 #if defined(GOOGLE_CHROME_BUILD) | 77 #if defined(GOOGLE_CHROME_BUILD) |
74 #include "chrome/installer/util/updating_app_registration_data.h" | 78 #include "chrome/installer/util/updating_app_registration_data.h" |
75 #endif | 79 #endif |
76 | 80 |
77 using installer::InstallerState; | 81 using installer::InstallerState; |
78 using installer::InstallationState; | 82 using installer::InstallationState; |
79 using installer::InstallationValidator; | 83 using installer::InstallationValidator; |
80 using installer::MasterPreferences; | 84 using installer::MasterPreferences; |
81 using installer::Product; | 85 using installer::Product; |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1614 } // namespace installer | 1618 } // namespace installer |
1615 | 1619 |
1616 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, | 1620 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, |
1617 wchar_t* command_line, int show_command) { | 1621 wchar_t* command_line, int show_command) { |
1618 // Check to see if the CPU is supported before doing anything else. There's | 1622 // Check to see if the CPU is supported before doing anything else. There's |
1619 // very little than can safely be accomplished if the CPU isn't supported | 1623 // very little than can safely be accomplished if the CPU isn't supported |
1620 // since dependent libraries (e.g., base) may use invalid instructions. | 1624 // since dependent libraries (e.g., base) may use invalid instructions. |
1621 if (!installer::IsProcessorSupported()) | 1625 if (!installer::IsProcessorSupported()) |
1622 return installer::CPU_NOT_SUPPORTED; | 1626 return installer::CPU_NOT_SUPPORTED; |
1623 | 1627 |
1628 // Create a persistent space for any histograms that can be reported later | |
grt (UTC plus 2)
2016/02/04 15:36:42
how about creating an installer_metrics.{cc,h} pai
bcwhite
2016/02/04 21:51:13
Done.
| |
1629 // by the Chrome process. The "id" is a timestamp so that Chrome can tell | |
grt (UTC plus 2)
2016/02/04 15:36:42
nit: The comment on line 1795 refers to the browse
bcwhite
2016/02/04 21:51:13
Done.
| |
1630 // if it has already reported these metrics. No name is given so no internal | |
1631 // histograms are created or managed; such would be pointless because they | |
1632 // would have to be created on the heap and thus never be persisted for | |
1633 // reporting. | |
1634 uint64_t allocator_id = base::Time::Now().ToTimeT(); | |
1635 base::SetPersistentHistogramMemoryAllocator( | |
1636 new base::LocalPersistentMemoryAllocator(1 << 20, // 1 MiB | |
1637 allocator_id, | |
1638 std::string())); | |
1639 | |
1640 // Now that histograms have a persistent place to be stored, the allocator | |
1641 // itself can create histograms within that space. | |
1642 base::GetPersistentHistogramMemoryAllocator() | |
1643 ->CreateTrackingHistograms(installer::kSetupHistogramAllocatorName); | |
1644 | |
1624 // The exit manager is in charge of calling the dtors of singletons. | 1645 // The exit manager is in charge of calling the dtors of singletons. |
1625 base::AtExitManager exit_manager; | 1646 base::AtExitManager exit_manager; |
1626 base::CommandLine::Init(0, NULL); | 1647 base::CommandLine::Init(0, NULL); |
1627 | 1648 |
1628 // install_util uses chrome paths. | 1649 // install_util uses chrome paths. |
1629 chrome::RegisterPathProvider(); | 1650 chrome::RegisterPathProvider(); |
1630 | 1651 |
1631 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); | 1652 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); |
1632 installer::InitInstallerLogging(prefs); | 1653 installer::InitInstallerLogging(prefs); |
1633 | 1654 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1763 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will | 1784 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will |
1764 // rollback the action. If we're uninstalling we want to avoid this, so always | 1785 // rollback the action. If we're uninstalling we want to avoid this, so always |
1765 // report success, squashing any more informative return codes. | 1786 // report success, squashing any more informative return codes. |
1766 if (!(installer_state.is_msi() && is_uninstall)) { | 1787 if (!(installer_state.is_msi() && is_uninstall)) { |
1767 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1788 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1768 // to pass through, since this is only returned on uninstall which is | 1789 // to pass through, since this is only returned on uninstall which is |
1769 // never invoked directly by Google Update. | 1790 // never invoked directly by Google Update. |
1770 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1791 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1771 } | 1792 } |
1772 | 1793 |
1794 // Save all the persistent histograms to a single file on disk for reading | |
grt (UTC plus 2)
2016/02/04 15:36:42
using a single file means that we'll get only a ra
bcwhite
2016/02/04 21:51:13
All things are possible... for a cost. Metrics ar
grt (UTC plus 2)
2016/02/08 18:09:18
Okay. Getting some data is better than none, so I'
bcwhite
2016/02/09 21:08:45
I've got some ideas on how to extend this but it n
grt (UTC plus 2)
2016/02/10 16:01:53
For a system-level install, setup.exe and chrome.e
| |
1795 // by the browser so it can be reported. For atomicity, first write to a | |
1796 // temporary file and then rename it. The ImportantFileWriter would be good | |
1797 // for this except it supports only std::string for its data. | |
1798 base::FilePath file_path = installer_state.target_path().AppendASCII( | |
1799 installer::kSetupHistogramAllocatorName).AddExtension(L".pma"); | |
1800 base::FilePath tmp_file_path; | |
1801 base::DeleteFile(file_path, false); | |
1802 if (base::CreateTemporaryFileInDir(file_path.DirName(), &tmp_file_path)) { | |
1803 base::File histograms(tmp_file_path, | |
1804 base::File::FLAG_OPEN | base::File::FLAG_WRITE); | |
1805 if (histograms.IsValid()) { | |
1806 base::PersistentMemoryAllocator* alloc = | |
1807 base::GetPersistentHistogramMemoryAllocator(); | |
1808 int used = static_cast<int>(alloc->used()); | |
1809 if (histograms.Write(0, static_cast<const char*>(alloc->data()), | |
1810 used) == used && | |
1811 histograms.Flush()) { | |
1812 histograms.Close(); | |
1813 if (base::ReplaceFile(tmp_file_path, file_path, nullptr)) { | |
grt (UTC plus 2)
2016/02/04 15:36:42
this will fail so long as chrome.exe has the |file
bcwhite
2016/02/04 21:51:13
Basically part of the multiple-runs problem. File
grt (UTC plus 2)
2016/02/08 18:09:18
Right now that window is pretty big (~30m), right?
bcwhite
2016/02/09 21:08:45
Yes. Either I'll pre-read it into an alternate me
| |
1814 VLOG(1) << "Persistent histograms saved in file: " | |
1815 << file_path.AsUTF8Unsafe(); | |
1816 } | |
1817 } | |
1818 } | |
1819 } | |
1820 base::DeleteFile(tmp_file_path, false); | |
1821 | |
1773 VLOG(1) << "Installation complete, returning: " << return_code; | 1822 VLOG(1) << "Installation complete, returning: " << return_code; |
1774 | 1823 |
1775 return return_code; | 1824 return return_code; |
1776 } | 1825 } |
OLD | NEW |