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_SNAPSHOT_H_ 6 #define FLUTTER_RUNTIME_DART_SNAPSHOT_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "flutter/common/settings.h" 12 #include "flutter/fml/macros.h" 13 #include "flutter/fml/memory/ref_counted.h" 14 15 namespace flutter { 16 17 class DartSnapshot : public fml::RefCountedThreadSafe<DartSnapshot> { 18 public: 19 static const char* kVMDataSymbol; 20 static const char* kVMInstructionsSymbol; 21 static const char* kIsolateDataSymbol; 22 static const char* kIsolateInstructionsSymbol; 23 24 static fml::RefPtr<DartSnapshot> VMSnapshotFromSettings( 25 const Settings& settings); 26 27 static fml::RefPtr<DartSnapshot> IsolateSnapshotFromSettings( 28 const Settings& settings); 29 30 static fml::RefPtr<DartSnapshot> Empty(); 31 32 bool IsValid() const; 33 34 bool IsValidForAOT() const; 35 36 const uint8_t* GetDataMapping() const; 37 38 const uint8_t* GetInstructionsMapping() const; 39 40 private: 41 std::shared_ptr<const fml::Mapping> data_; 42 std::shared_ptr<const fml::Mapping> instructions_; 43 44 DartSnapshot(std::shared_ptr<const fml::Mapping> data, 45 std::shared_ptr<const fml::Mapping> instructions); 46 47 ~DartSnapshot(); 48 49 FML_FRIEND_REF_COUNTED_THREAD_SAFE(DartSnapshot); 50 FML_FRIEND_MAKE_REF_COUNTED(DartSnapshot); 51 FML_DISALLOW_COPY_AND_ASSIGN(DartSnapshot); 52 }; 53 54 } // namespace flutter 55 56 #endif // FLUTTER_RUNTIME_DART_SNAPSHOT_H_ 57