| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #ifndef DartService_h |
| 6 #define DartService_h |
| 7 |
| 8 #include <dart_api.h> |
| 9 #include <dart_native_api.h> |
| 10 |
| 11 namespace WebCore { |
| 12 |
| 13 class DartServiceInternal; |
| 14 class Document; |
| 15 |
| 16 class DartServiceRequest { |
| 17 public: |
| 18 DartServiceRequest(const char* request); |
| 19 virtual ~DartServiceRequest(); |
| 20 |
| 21 // Override this method and it will be called when |
| 22 // the response has been received from the VM service. |
| 23 virtual void ResponseReady(const char* response) = 0; |
| 24 |
| 25 char* GetRequestString() { return m_request; } |
| 26 private: |
| 27 char* m_request; |
| 28 }; |
| 29 |
| 30 class DartService { |
| 31 public: |
| 32 // Returns false if service could not be started. |
| 33 static bool Start(Document*); |
| 34 static bool Stop(); |
| 35 |
| 36 // Error message if startup failed. |
| 37 static const char* GetErrorMessage(); |
| 38 |
| 39 static Dart_Port port(); |
| 40 static Dart_Port GetRequestPort() { return m_requestPort; } |
| 41 static bool IsRunning(); |
| 42 |
| 43 static bool SendIsolateStartupMessage(); |
| 44 static bool SendIsolateShutdownMessage(); |
| 45 static void MakeServiceRequest(DartServiceRequest*); |
| 46 static void VmServiceShutdownCallback(void* callbackData); |
| 47 |
| 48 private: |
| 49 static Dart_Handle GetSource(const char* name); |
| 50 static Dart_Handle LoadScript(const char* name); |
| 51 static Dart_Handle LoadSources(Dart_Handle library, const char** names); |
| 52 static Dart_Handle LoadSource(Dart_Handle library, const char* name); |
| 53 static Dart_Handle LoadResources(Dart_Handle library); |
| 54 static Dart_Handle LoadResource(Dart_Handle library, const char* name, const
char* prefix); |
| 55 static Dart_Handle LibraryTagHandler(Dart_LibraryTag, Dart_Handle library, D
art_Handle url); |
| 56 static Dart_NativeFunction NativeResolver(Dart_Handle name, int numArguments
); |
| 57 static Dart_Isolate m_isolate; |
| 58 static Dart_Port m_port; |
| 59 static Dart_Port m_requestPort; |
| 60 static const char* m_errorMsg; |
| 61 friend class DartServiceInternal; |
| 62 }; |
| 63 |
| 64 } |
| 65 |
| 66 #endif // DartService_h |
| OLD | NEW |