Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7202)

Unified Diff: chrome/installer/setup/setup_util.cc

Issue 2507753002: Install the chrome event log provider together with the browser. (Closed)
Patch Set: Fix wrong append call. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/setup_util.cc
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc
index 233287bf519375396cf4082baa66791711886c63..2dde73a89d2a7917b8d9bde7613b7a33451a1757 100644
--- a/chrome/installer/setup/setup_util.cc
+++ b/chrome/installer/setup/setup_util.cc
@@ -11,6 +11,8 @@
#include <algorithm>
#include <iterator>
+#include <limits>
+#include <memory>
#include <set>
#include <string>
@@ -36,6 +38,7 @@
#include "chrome/installer/setup/user_hive_visitor.h"
#include "chrome/installer/util/app_registration_data.h"
#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/master_preferences_constants.h"
@@ -47,6 +50,10 @@ namespace installer {
namespace {
+// Event log provider registry location and value names.
+constexpr wchar_t kEventLogProviderRegPath[] =
+ L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\chrome";
+
// Returns true if product |type| cam be meaningfully installed without the
// --multi-install flag.
bool SupportsSingleInstall(BrowserDistribution::Type type) {
@@ -660,6 +667,51 @@ void RecordUnPackMetrics(UnPackStatus unpack_status,
->Add(status);
}
+void RegisterEventLogProvider(const base::FilePath& install_directory) {
grt (UTC plus 2) 2016/11/22 10:41:25 nit: either rename |install_directory| to |version
pastarmovj 2016/11/23 14:27:26 Done.
+ VLOG(1) << "Registering Chrome's event log provider at "
+ << kEventLogProviderRegPath;
+
+ std::unique_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
+
+ work_item_list->AddCreateRegKeyWorkItem(
+ HKEY_LOCAL_MACHINE, kEventLogProviderRegPath, WorkItem::kWow64Default);
+ // Speicifes the number of event categories defined in the dll.
+ work_item_list->AddSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, kEventLogProviderRegPath, WorkItem::kWow64Default,
+ L"CategoryCount", static_cast<DWORD>(1), true);
+ // Specifies the event type emitted by this event source.
+ work_item_list->AddSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, kEventLogProviderRegPath, WorkItem::kWow64Default,
+ L"TypesSupported",
+ static_cast<DWORD>(EVENTLOG_ERROR_TYPE | EVENTLOG_INFORMATION_TYPE |
+ EVENTLOG_WARNING_TYPE),
+ true);
+
+ base::FilePath provider(install_directory);
grt (UTC plus 2) 2016/11/22 10:41:25 nit: base::FilePath provider( install_dir
pastarmovj 2016/11/23 14:27:26 Done.
+ provider = provider.Append(FILE_PATH_LITERAL("eventlog_provider.dll"));
+
+ static const wchar_t* file_keys[] = {
grt (UTC plus 2) 2016/11/22 10:41:25 nit: static constexpr const wchar_t* kFileKeys[] =
pastarmovj 2016/11/23 14:27:26 Done.
+ L"CategoryMessageFile", L"EventMessageFile", L"ParameterMessageFile",
+ };
+ for (const wchar_t* file_key : file_keys) {
+ work_item_list->AddSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, kEventLogProviderRegPath, WorkItem::kWow64Default,
+ file_key, provider.value(), true);
+ }
+
+ // if the operation fails we log the error but still continue because none of
+ // these are critical for the proper operation of the browser.
+ if (!work_item_list->Do()) {
+ work_item_list->Rollback();
+ LOG(ERROR) << "Could not register Chrome's event log provider.";
grt (UTC plus 2) 2016/11/22 10:41:25 WorkitemList will emit a log message very similar
pastarmovj 2016/11/23 14:27:25 Done.
+ }
+}
+
+void DeRegisterEventLogProvider() {
+ InstallUtil::DeleteRegistryKey(HKEY_LOCAL_MACHINE, kEventLogProviderRegPath,
+ WorkItem::kWow64Default);
+}
+
ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
: is_enabled_(false) {
HANDLE temp_handle;

Powered by Google App Engine
This is Rietveld 408576698