2013-07-22 15:39:03 +00:00
|
|
|
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef VM_SERVICE_H_
|
|
|
|
#define VM_SERVICE_H_
|
|
|
|
|
|
|
|
#include "include/dart_api.h"
|
|
|
|
|
2013-12-17 21:11:18 +00:00
|
|
|
#include "vm/allocation.h"
|
|
|
|
|
2013-07-22 15:39:03 +00:00
|
|
|
namespace dart {
|
|
|
|
|
2014-06-30 22:46:27 +00:00
|
|
|
class DebuggerEvent;
|
2014-02-18 22:38:11 +00:00
|
|
|
class EmbedderServiceHandler;
|
2013-07-22 15:39:03 +00:00
|
|
|
class Instance;
|
|
|
|
class Isolate;
|
2014-02-18 22:38:11 +00:00
|
|
|
class JSONStream;
|
2014-07-03 12:56:02 +00:00
|
|
|
class Array;
|
2014-01-15 20:45:39 +00:00
|
|
|
class RawInstance;
|
2014-06-30 22:46:27 +00:00
|
|
|
class String;
|
2013-07-22 15:39:03 +00:00
|
|
|
|
|
|
|
class Service : public AllStatic {
|
|
|
|
public:
|
2014-01-15 20:45:39 +00:00
|
|
|
// Handles a message which is not directed to an isolate.
|
|
|
|
static void HandleRootMessage(const Instance& message);
|
|
|
|
|
|
|
|
// Handles a message which is directed to a particular isolate.
|
2014-07-03 12:56:02 +00:00
|
|
|
static void HandleIsolateMessage(Isolate* isolate, const Array& message);
|
2014-01-15 20:45:39 +00:00
|
|
|
|
2014-01-14 22:34:43 +00:00
|
|
|
static Isolate* GetServiceIsolate(void* callback_data);
|
|
|
|
static bool SendIsolateStartupMessage();
|
|
|
|
static bool SendIsolateShutdownMessage();
|
2014-06-30 22:46:27 +00:00
|
|
|
|
|
|
|
static bool IsRunning() {
|
|
|
|
return port_ != ILLEGAL_PORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetEventMask(uint32_t mask);
|
|
|
|
|
|
|
|
// Is the service interested in debugger events?
|
|
|
|
static bool NeedsDebuggerEvents() {
|
|
|
|
return IsRunning() && ((event_mask_ & kEventFamilyDebugMask) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleDebuggerEvent(DebuggerEvent* event);
|
2014-02-18 22:38:11 +00:00
|
|
|
|
|
|
|
static void RegisterIsolateEmbedderCallback(
|
|
|
|
const char* name,
|
|
|
|
Dart_ServiceRequestCallback callback,
|
|
|
|
void* user_data);
|
|
|
|
|
|
|
|
static void RegisterRootEmbedderCallback(
|
|
|
|
const char* name,
|
|
|
|
Dart_ServiceRequestCallback callback,
|
|
|
|
void* user_data);
|
|
|
|
|
2014-03-20 21:00:10 +00:00
|
|
|
static bool IsServiceIsolate(Isolate* isolate) {
|
|
|
|
return isolate == service_isolate_;
|
|
|
|
}
|
|
|
|
|
2014-02-18 22:38:11 +00:00
|
|
|
private:
|
2014-06-30 22:46:27 +00:00
|
|
|
// These must be kept in sync with service/constants.dart
|
|
|
|
static const int kEventFamilyDebug = 0;
|
|
|
|
static const uint32_t kEventFamilyDebugMask = (1 << kEventFamilyDebug);
|
|
|
|
|
2014-02-18 22:38:11 +00:00
|
|
|
static void EmbedderHandleMessage(EmbedderServiceHandler* handler,
|
|
|
|
JSONStream* js);
|
|
|
|
static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name);
|
|
|
|
static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name);
|
2014-06-30 22:46:27 +00:00
|
|
|
static Dart_Handle GetSource(const char* name);
|
|
|
|
static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library,
|
|
|
|
Dart_Handle url);
|
|
|
|
static void SendEvent(intptr_t eventId, const String& eventMessage);
|
|
|
|
|
|
|
|
static EmbedderServiceHandler* isolate_service_handler_head_;
|
2014-02-18 22:38:11 +00:00
|
|
|
static EmbedderServiceHandler* root_service_handler_head_;
|
2014-06-30 22:46:27 +00:00
|
|
|
|
2014-01-14 22:34:43 +00:00
|
|
|
static Isolate* service_isolate_;
|
2014-07-15 16:33:56 +00:00
|
|
|
static Dart_LibraryTagHandler embedder_provided_handler_;
|
2014-01-14 22:34:43 +00:00
|
|
|
static Dart_Port port_;
|
2014-06-30 22:46:27 +00:00
|
|
|
static uint32_t event_mask_;
|
2013-07-22 15:39:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dart
|
|
|
|
|
|
|
|
#endif // VM_SERVICE_H_
|