flutter_flutter/engine/src/flutter/fml/native_library.h
Chris Bracken 2586db3b22 Clean up C++ includes (flutter/engine#21127)
Cleans up header order/grouping for consistency: associated header, C/C++ system/standard library headers, library headers, platform-specific #includes.

Adds <cstring> where strlen, memcpy are being used: there are a bunch of places we use them transitively.

Applies linter-required cleanups. Disables linter on one file due to included RapidJson header. See https://github.com/flutter/flutter/issues/65676

This patch does not cover flutter/shell/platform/darwin. There's a separate, slightly more intensive cleanup for those in progress.
2020-09-11 21:18:35 -07:00

56 lines
1.3 KiB
C++

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FML_NATIVE_LIBRARY_H_
#define FLUTTER_FML_NATIVE_LIBRARY_H_
#include "flutter/fml/build_config.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/memory/ref_ptr.h"
#if defined(OS_WIN)
#include <windows.h>
#endif // defined(OS_WIN)
namespace fml {
class NativeLibrary : public fml::RefCountedThreadSafe<NativeLibrary> {
public:
#if OS_WIN
using Handle = HMODULE;
#else // OS_WIN
using Handle = void*;
#endif // OS_WIN
static fml::RefPtr<NativeLibrary> Create(const char* path);
static fml::RefPtr<NativeLibrary> CreateWithHandle(
Handle handle,
bool close_handle_when_done);
static fml::RefPtr<NativeLibrary> CreateForCurrentProcess();
const uint8_t* ResolveSymbol(const char* symbol);
private:
Handle handle_ = nullptr;
bool close_handle_ = true;
NativeLibrary(const char* path);
NativeLibrary(Handle handle, bool close_handle);
~NativeLibrary();
Handle GetHandle() const;
FML_DISALLOW_COPY_AND_ASSIGN(NativeLibrary);
FML_FRIEND_REF_COUNTED_THREAD_SAFE(NativeLibrary);
FML_FRIEND_MAKE_REF_COUNTED(NativeLibrary);
};
} // namespace fml
#endif // FLUTTER_FML_NATIVE_LIBRARY_H_