<commit_before>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/installer/util/self_reg_work_item.h"

#include "base/logging.h"
#include "chrome/installer/util/logging_installer.h"

// Default registration export names.
const char kDefaultRegistrationEntryPoint[] = "DllRegisterServer";
const char kDefaultUnregistrationEntryPoint[] = "DllUnregisterServer";

// User-level registration export names.
const char kUserRegistrationEntryPoint[] = "DllRegisterUserServer";
const char kUserUnregistrationEntryPoint[] = "DllUnregisterUserServer";

SelfRegWorkItem::SelfRegWorkItem(const std::wstring& dll_path,
                                 bool do_register,
                                 bool user_level_registration)
    : do_register_(do_register), dll_path_(dll_path),
      user_level_registration_(user_level_registration) {
}

SelfRegWorkItem::~SelfRegWorkItem() {
}

bool SelfRegWorkItem::RegisterDll(bool do_register) {
  HMODULE dll_module = ::LoadLibraryEx(dll_path_.c_str(), NULL,
                                       LOAD_WITH_ALTERED_SEARCH_PATH);
  bool success = false;
  if (NULL != dll_module) {
    PROC register_server_func = NULL;
    if (do_register) {
      register_server_func = ::GetProcAddress(dll_module,
          user_level_registration_ ? kUserRegistrationEntryPoint :
                                     kDefaultRegistrationEntryPoint);
    } else {
      register_server_func = ::GetProcAddress(dll_module,
          user_level_registration_ ? kUserUnregistrationEntryPoint :
                                     kDefaultUnregistrationEntryPoint);
    }

    if (NULL != register_server_func) {
      success = SUCCEEDED(register_server_func());
      if (!success) {
        LOG(ERROR) << "Failed to " << (do_register ? "register" : "unregister")
                   << " DLL at " << dll_path_.c_str();
      }
    }
    ::FreeLibrary(dll_module);
  }
  return success;
}<commit_msg>Add some verbose logging when registering COM components.<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/installer/util/self_reg_work_item.h"

#include "base/logging.h"
#include "chrome/installer/util/logging_installer.h"

// Default registration export names.
const char kDefaultRegistrationEntryPoint[] = "DllRegisterServer";
const char kDefaultUnregistrationEntryPoint[] = "DllUnregisterServer";

// User-level registration export names.
const char kUserRegistrationEntryPoint[] = "DllRegisterUserServer";
const char kUserUnregistrationEntryPoint[] = "DllUnregisterUserServer";

SelfRegWorkItem::SelfRegWorkItem(const std::wstring& dll_path,
                                 bool do_register,
                                 bool user_level_registration)
    : do_register_(do_register), dll_path_(dll_path),
      user_level_registration_(user_level_registration) {
}

SelfRegWorkItem::~SelfRegWorkItem() {
}

bool SelfRegWorkItem::RegisterDll(bool do_register) {
  VLOG(1) << "COM " << (do_register ? "registration of " : "unregistration of ")
      << dll_path_;

  HMODULE dll_module = ::LoadLibraryEx(dll_path_.c_str(), NULL,
                                       LOAD_WITH_ALTERED_SEARCH_PATH);
  bool success = false;
  if (NULL != dll_module) {
    PROC register_server_func = NULL;
    if (do_register) {
      register_server_func = ::GetProcAddress(dll_module,
          user_level_registration_ ? kUserRegistrationEntryPoint :
                                     kDefaultRegistrationEntryPoint);
    } else {
      register_server_func = ::GetProcAddress(dll_module,
          user_level_registration_ ? kUserUnregistrationEntryPoint :
                                     kDefaultUnregistrationEntryPoint);
    }

    if (NULL != register_server_func) {
      success = SUCCEEDED(register_server_func());
      if (!success) {
        LOG(ERROR) << "Failed to " << (do_register ? "register" : "unregister")
                   << " DLL at " << dll_path_.c_str();
      }
    }
    ::FreeLibrary(dll_module);
  } else {
    LOG(WARNING) << "Failed to load: " << dll_path_;
  }
  return success;
}
{'fraction_non_alphanumeric': 0.0962517353077279, 'fraction_numerical': 0.0020823692734844978, 'mean_word_length': 3.074458058435438, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4430181', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1215, 'n_words': 259}