xpcom/components/nsNativeModuleLoader.h
author Ehsan Akhgari <ehsan@mozilla.com>
Fri, 24 Apr 2015 15:12:50 -0400
changeset 267826 9ef3b7efaaa734430bcb9e5b612dcc14a56bd60c
parent 259646 a20c7910a82fa2df2f3398c1108d102bac9128b0
child 269788 2328731ef45354daf50eb21607a3c781ab79bc7c
permissions -rw-r--r--
Bug 892973 - Add support for the YouCompleteMe vim plugin. r=gps, a=NPOTB

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsNativeModuleLoader_h__
#define nsNativeModuleLoader_h__

#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "prlink.h"

namespace mozilla {
class FileLocation;
}

class nsNativeModuleLoader final
{
public:
  const mozilla::Module* LoadModule(mozilla::FileLocation& aFile);

  nsresult Init();

  void UnloadLibraries();

private:
  struct NativeLoadData
  {
    NativeLoadData() : mModule(nullptr), mLibrary(nullptr) {}

    const mozilla::Module* mModule;
    PRLibrary* mLibrary;
  };

  static PLDHashOperator
  ReleaserFunc(nsIHashable* aHashedFile, NativeLoadData& aLoadData, void*);

  static PLDHashOperator
  UnloaderFunc(nsIHashable* aHashedFile, NativeLoadData& aLoadData, void*);

  nsDataHashtable<nsHashableHashKey, NativeLoadData> mLibraries;
};

#endif /* nsNativeModuleLoader_h__ */