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

#include "xwalk/extensions/common/xwalk_external_extension.h"

#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/values.h"
#include "xwalk/extensions/common/xwalk_external_adapter.h"

namespace xwalk {
namespace extensions {

XWalkExternalExtension::XWalkExternalExtension(const base::FilePath& path)
    : xw_extension_(0),
      created_instance_callback_(NULL),
      destroyed_instance_callback_(NULL),
      shutdown_callback_(NULL),
      handle_msg_callback_(NULL),
      handle_sync_msg_callback_(NULL),
      initialized_(false),
      library_path_(path) {
}

XWalkExternalExtension::~XWalkExternalExtension() {
  if (!initialized_)
    return;

  if (shutdown_callback_)
    shutdown_callback_(xw_extension_);
  XWalkExternalAdapter::GetInstance()->UnregisterExtension(this);
}

bool XWalkExternalExtension::Initialize() {
  if (initialized_)
    return true;

  base::NativeLibraryLoadError error;
  base::ScopedNativeLibrary library(
      base::LoadNativeLibrary(library_path_, &error));<commit_msg>Fix issue in coverity : Uninitialized pointer field in XWalkExternalExtension.<commit_after>// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "xwalk/extensions/common/xwalk_external_extension.h"

#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/values.h"
#include "xwalk/extensions/common/xwalk_external_adapter.h"

namespace xwalk {
namespace extensions {

XWalkExternalExtension::XWalkExternalExtension(const base::FilePath& path)
    : xw_extension_(0),
      created_instance_callback_(NULL),
      destroyed_instance_callback_(NULL),
      shutdown_callback_(NULL),
      handle_msg_callback_(NULL),
      handle_sync_msg_callback_(NULL),
      handle_binary_msg_callback_(NULL),
      initialized_(false),
      library_path_(path) {
}

XWalkExternalExtension::~XWalkExternalExtension() {
  if (!initialized_)
    return;

  if (shutdown_callback_)
    shutdown_callback_(xw_extension_);
  XWalkExternalAdapter::GetInstance()->UnregisterExtension(this);
}

bool XWalkExternalExtension::Initialize() {
  if (initialized_)
    return true;

  base::NativeLibraryLoadError error;
  base::ScopedNativeLibrary library(
      base::LoadNativeLibrary(library_path_, &error));
{'fraction_non_alphanumeric': 0.10646802325581395, 'fraction_numerical': 0.003633720930232558, 'mean_word_length': 5.432242990654205, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2358180', 'n_tokens_mistral': 815, 'n_tokens_neox': 815, 'n_words': 170}