1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_RUNTIME_DART_VM_H_ 6 #define FLUTTER_RUNTIME_DART_VM_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "flutter/common/settings.h" 12 #include "flutter/fml/build_config.h" 13 #include "flutter/fml/closure.h" 14 #include "flutter/fml/macros.h" 15 #include "flutter/fml/memory/ref_counted.h" 16 #include "flutter/fml/memory/ref_ptr.h" 17 #include "flutter/fml/memory/weak_ptr.h" 18 #include "flutter/fml/message_loop.h" 19 #include "flutter/lib/ui/isolate_name_server/isolate_name_server.h" 20 #include "flutter/runtime/dart_isolate.h" 21 #include "flutter/runtime/dart_snapshot.h" 22 #include "flutter/runtime/dart_vm_data.h" 23 #include "flutter/runtime/service_protocol.h" 24 #include "flutter/runtime/skia_concurrent_executor.h" 25 #include "third_party/dart/runtime/include/dart_api.h" 26 27 namespace flutter { 28 29 class DartVM { 30 public: 31 ~DartVM(); 32 33 static bool IsRunningPrecompiledCode(); 34 35 static size_t GetVMLaunchCount(); 36 37 const Settings& GetSettings() const; 38 39 std::shared_ptr<const DartVMData> GetVMData() const; 40 41 std::shared_ptr<ServiceProtocol> GetServiceProtocol() const; 42 43 std::shared_ptr<IsolateNameServer> GetIsolateNameServer() const; 44 45 std::shared_ptr<fml::ConcurrentTaskRunner> GetConcurrentWorkerTaskRunner() 46 const; 47 48 private: 49 const Settings settings_; 50 std::shared_ptr<fml::ConcurrentMessageLoop> concurrent_message_loop_; 51 SkiaConcurrentExecutor skia_concurrent_executor_; 52 std::shared_ptr<const DartVMData> vm_data_; 53 const std::shared_ptr<IsolateNameServer> isolate_name_server_; 54 const std::shared_ptr<ServiceProtocol> service_protocol_; 55 56 friend class DartVMRef; 57 friend class DartIsolate; 58 59 static std::shared_ptr<DartVM> Create( 60 Settings settings, 61 fml::RefPtr<DartSnapshot> vm_snapshot, 62 fml::RefPtr<DartSnapshot> isolate_snapshot, 63 fml::RefPtr<DartSnapshot> shared_snapshot, 64 std::shared_ptr<IsolateNameServer> isolate_name_server); 65 66 DartVM(std::shared_ptr<const DartVMData> data, 67 std::shared_ptr<IsolateNameServer> isolate_name_server); 68 69 FML_DISALLOW_COPY_AND_ASSIGN(DartVM); 70 }; 71 72 } // namespace flutter 73 74 #endif // FLUTTER_RUNTIME_DART_VM_H_ 75