Chinmay Garde eec74e5c92
Rename the blink namespace to flutter. (#8517)
Some components in the Flutter engine were derived from the forked blink codebase. While the forked components have either been removed or rewritten, the use of the blink namespace has mostly (and inconsistently) remained. This renames the blink namesapce to flutter for consistency. There are no functional changes in this patch.
2019-04-09 12:44:42 -07:00

81 lines
2.4 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_RUNTIME_DART_VM_H_
#define FLUTTER_RUNTIME_DART_VM_H_
#include <memory>
#include <string>
#include "flutter/common/settings.h"
#include "flutter/fml/build_config.h"
#include "flutter/fml/closure.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/memory/ref_ptr.h"
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/lib/ui/isolate_name_server/isolate_name_server.h"
#include "flutter/runtime/dart_isolate.h"
#include "flutter/runtime/dart_snapshot.h"
#include "flutter/runtime/dart_vm_data.h"
#include "flutter/runtime/service_protocol.h"
#include "third_party/dart/runtime/include/dart_api.h"
namespace flutter {
class DartVM {
public:
~DartVM();
static bool IsRunningPrecompiledCode();
static size_t GetVMLaunchCount();
const Settings& GetSettings() const;
std::shared_ptr<const DartVMData> GetVMData() const;
// This accessor is racy and only meant to the used in tests where there is a
// consistent threading mode.
size_t GetIsolateCount() const;
std::shared_ptr<ServiceProtocol> GetServiceProtocol() const;
std::shared_ptr<IsolateNameServer> GetIsolateNameServer() const;
void ShutdownAllIsolates();
private:
const Settings settings_;
std::shared_ptr<const DartVMData> vm_data_;
const std::shared_ptr<IsolateNameServer> isolate_name_server_;
const std::shared_ptr<ServiceProtocol> service_protocol_;
mutable std::mutex active_isolates_mutex_;
std::set<std::shared_ptr<DartIsolate>> active_isolates_
FML_GUARDED_BY(active_isolates_mutex_);
friend class DartVMRef;
friend class DartIsolate;
static std::shared_ptr<DartVM> Create(
Settings settings,
fml::RefPtr<DartSnapshot> vm_snapshot,
fml::RefPtr<DartSnapshot> isolate_snapshot,
fml::RefPtr<DartSnapshot> shared_snapshot,
std::shared_ptr<IsolateNameServer> isolate_name_server);
DartVM(std::shared_ptr<const DartVMData> data,
std::shared_ptr<IsolateNameServer> isolate_name_server);
void RegisterActiveIsolate(std::shared_ptr<DartIsolate> isolate);
void UnregisterActiveIsolate(std::shared_ptr<DartIsolate> isolate);
FML_DISALLOW_COPY_AND_ASSIGN(DartVM);
};
} // namespace flutter
#endif // FLUTTER_RUNTIME_DART_VM_H_