d554f4fbfe
Service - Remove support for old-style service requests. - Drop 'arguments' from JsonStream and ServiceRequestHandler. - Json-rpc inspired renaming: command->method, options->params all over. - Implement getFlagList, setFlag, getObjectByAddress. - Add helpers PrintMissingParamError and PrintInvalidParamError to make our error messages more regular. - Update tests. - Service_SetSource removed for now. John will resurrect. Observatory - Drop all Deprecated 'get' functions. We now use json rpc for everything. - Drop 'link' and 'relativeLink' from ServiceObject -- they were ui-specific and they are no longer meaningful anyways. Use 'id' instead. - New pages: VMPage, FlagsPage, InspectPage, ErrorPage. All urls used by Observatory are now 'new school' and have a proper prefix. ErrorPage is the new catch-all. - Pages now use a Uri instead of a url String. This lets them grab query parameters more easily. - SimplePage replaces IsolateSuffixPage. - We now use gotoLink() or makeLink() to make our navigation links. gotoLink gets some optional parameters to make it easier to construct links to ServiceObjects. - Rework mouse clicks on the heap map to use getObjectByAddress. - Remove the breakpoint_list. It wasn't working. I'll add it back later. - Silence logging of getIsolateMetric/getVMMetric. R=johnmccutchan@google.com Review URL: https://codereview.chromium.org//897193002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43514 260f80e4-7a28-3924-810f-c04153c831b5
127 lines
3.9 KiB
C++
127 lines
3.9 KiB
C++
// 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"
|
|
|
|
#include "vm/allocation.h"
|
|
#include "vm/os_thread.h"
|
|
|
|
namespace dart {
|
|
|
|
class Array;
|
|
class DebuggerEvent;
|
|
class EmbedderServiceHandler;
|
|
class GCEvent;
|
|
class Instance;
|
|
class Isolate;
|
|
class JSONStream;
|
|
class Object;
|
|
class RawInstance;
|
|
class String;
|
|
|
|
class Service : public AllStatic {
|
|
public:
|
|
static const char* kIsolateName;
|
|
static bool IsServiceIsolateName(const char* name);
|
|
|
|
// 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.
|
|
static void HandleIsolateMessage(Isolate* isolate, const Array& message);
|
|
|
|
static Isolate* GetServiceIsolate(void* callback_data);
|
|
static bool SendIsolateStartupMessage();
|
|
static bool SendIsolateShutdownMessage();
|
|
|
|
static bool IsRunning();
|
|
static void SetServicePort(Dart_Port port);
|
|
static void SetServiceIsolate(Isolate* isolate);
|
|
static bool HasServiceIsolate();
|
|
static bool IsServiceIsolate(Isolate* isolate);
|
|
|
|
static Dart_Port WaitForLoadPort();
|
|
static Dart_Port LoadPort();
|
|
static void SetLoadPort(Dart_Port port);
|
|
|
|
static void SetEventMask(uint32_t mask);
|
|
|
|
// Is the service interested in debugger events?
|
|
static bool NeedsDebuggerEvents() {
|
|
return IsRunning() && ((event_mask_ & kEventFamilyDebugMask) != 0);
|
|
}
|
|
// Is the service interested in garbage collection events?
|
|
static bool NeedsGCEvents() {
|
|
return IsRunning() && ((event_mask_ & kEventFamilyGCMask) != 0);
|
|
}
|
|
|
|
static void HandleDebuggerEvent(DebuggerEvent* event);
|
|
static void HandleGCEvent(GCEvent* event);
|
|
|
|
static void RegisterIsolateEmbedderCallback(
|
|
const char* name,
|
|
Dart_ServiceRequestCallback callback,
|
|
void* user_data);
|
|
|
|
static void RegisterRootEmbedderCallback(
|
|
const char* name,
|
|
Dart_ServiceRequestCallback callback,
|
|
void* user_data);
|
|
|
|
static void SendEchoEvent(Isolate* isolate, const char* text);
|
|
static void SendGraphEvent(Isolate* isolate);
|
|
|
|
static void MaybeInjectVMServiceLibrary(Isolate* isolate);
|
|
|
|
static void RunService();
|
|
|
|
static void FinishedInitializing();
|
|
|
|
static Dart_IsolateCreateCallback create_callback() {
|
|
return create_callback_;
|
|
}
|
|
|
|
private:
|
|
// These must be kept in sync with service/constants.dart
|
|
static const int kEventFamilyDebug = 0;
|
|
static const int kEventFamilyGC = 1;
|
|
static const uint32_t kEventFamilyDebugMask = (1 << kEventFamilyDebug);
|
|
static const uint32_t kEventFamilyGCMask = (1 << kEventFamilyGC);
|
|
|
|
static void EmbedderHandleMessage(EmbedderServiceHandler* handler,
|
|
JSONStream* js);
|
|
|
|
static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name);
|
|
static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name);
|
|
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 Object& eventMessage);
|
|
// Does not take ownership of 'data'.
|
|
static void SendEvent(intptr_t eventId,
|
|
const String& meta,
|
|
const uint8_t* data,
|
|
intptr_t size);
|
|
|
|
static EmbedderServiceHandler* isolate_service_handler_head_;
|
|
static EmbedderServiceHandler* root_service_handler_head_;
|
|
|
|
|
|
static Dart_IsolateCreateCallback create_callback_;
|
|
static Monitor* monitor_;
|
|
static bool initializing_;
|
|
static Isolate* service_isolate_;
|
|
static Dart_Port service_port_;
|
|
static Dart_Port load_port_;
|
|
static uint32_t event_mask_;
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // VM_SERVICE_H_
|