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"
|
2015-01-29 18:31:27 +00:00
|
|
|
#include "vm/os_thread.h"
|
2013-12-17 21:11:18 +00:00
|
|
|
|
2013-07-22 15:39:03 +00:00
|
|
|
namespace dart {
|
|
|
|
|
2014-08-18 15:35:03 +00:00
|
|
|
class Array;
|
2014-02-18 22:38:11 +00:00
|
|
|
class EmbedderServiceHandler;
|
2014-08-18 15:35:03 +00:00
|
|
|
class GCEvent;
|
2013-07-22 15:39:03 +00:00
|
|
|
class Instance;
|
|
|
|
class Isolate;
|
2014-02-18 22:38:11 +00:00
|
|
|
class JSONStream;
|
2014-08-18 15:35:03 +00:00
|
|
|
class Object;
|
2014-01-15 20:45:39 +00:00
|
|
|
class RawInstance;
|
2015-03-05 19:02:42 +00:00
|
|
|
class ServiceEvent;
|
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.
|
2015-02-12 19:10:55 +00:00
|
|
|
static void HandleRootMessage(const Array& message);
|
2014-01-15 20:45:39 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2015-03-05 19:02:42 +00:00
|
|
|
static bool NeedsEvents();
|
2014-06-30 22:46:27 +00:00
|
|
|
|
2015-03-05 19:02:42 +00:00
|
|
|
static void HandleEvent(ServiceEvent* 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);
|
|
|
|
|
2015-02-03 23:17:05 +00:00
|
|
|
static void SendEchoEvent(Isolate* isolate, const char* text);
|
2014-12-02 19:33:09 +00:00
|
|
|
static void SendGraphEvent(Isolate* isolate);
|
2015-05-08 22:18:43 +00:00
|
|
|
static void SendInspectEvent(Isolate* isolate, const Object& inspectee);
|
2014-08-18 15:35:03 +00:00
|
|
|
|
2014-02-18 22:38:11 +00:00
|
|
|
private:
|
2015-02-12 19:10:55 +00:00
|
|
|
static void InvokeMethod(Isolate* isolate, const Array& message);
|
|
|
|
|
2014-02-18 22:38:11 +00:00
|
|
|
static void EmbedderHandleMessage(EmbedderServiceHandler* handler,
|
|
|
|
JSONStream* js);
|
2015-01-29 18:31:27 +00:00
|
|
|
|
2014-02-18 22:38:11 +00:00
|
|
|
static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name);
|
|
|
|
static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name);
|
2015-01-29 18:31:27 +00:00
|
|
|
|
2015-04-09 21:08:38 +00:00
|
|
|
static void SendEvent(intptr_t eventType,
|
2015-03-10 00:07:45 +00:00
|
|
|
const Object& eventMessage);
|
2014-08-18 15:35:03 +00:00
|
|
|
// Does not take ownership of 'data'.
|
2015-04-09 21:08:38 +00:00
|
|
|
static void SendEvent(const String& meta,
|
2014-08-18 15:35:03 +00:00
|
|
|
const uint8_t* data,
|
|
|
|
intptr_t size);
|
2014-06-30 22:46:27 +00:00
|
|
|
|
|
|
|
static EmbedderServiceHandler* isolate_service_handler_head_;
|
2014-02-18 22:38:11 +00:00
|
|
|
static EmbedderServiceHandler* root_service_handler_head_;
|
2013-07-22 15:39:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dart
|
|
|
|
|
|
|
|
#endif // VM_SERVICE_H_
|