2015-02-12 19:10:55 +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.
|
|
|
|
|
2016-10-26 07:26:03 +00:00
|
|
|
#ifndef RUNTIME_VM_SERVICE_ISOLATE_H_
|
|
|
|
#define RUNTIME_VM_SERVICE_ISOLATE_H_
|
2015-02-12 19:10:55 +00:00
|
|
|
|
|
|
|
#include "include/dart_api.h"
|
|
|
|
|
|
|
|
#include "vm/allocation.h"
|
|
|
|
#include "vm/os_thread.h"
|
|
|
|
|
|
|
|
namespace dart {
|
|
|
|
|
2019-01-11 20:47:10 +00:00
|
|
|
class Isolate;
|
2016-06-10 19:33:50 +00:00
|
|
|
class ObjectPointerVisitor;
|
2016-10-31 19:32:23 +00:00
|
|
|
class SendPort;
|
2016-06-10 19:33:50 +00:00
|
|
|
|
2015-02-12 19:10:55 +00:00
|
|
|
class ServiceIsolate : public AllStatic {
|
|
|
|
public:
|
|
|
|
static const char* kName;
|
|
|
|
static bool NameEquals(const char* name);
|
|
|
|
|
|
|
|
static bool Exists();
|
|
|
|
static bool IsRunning();
|
2016-05-17 19:19:06 +00:00
|
|
|
static bool IsServiceIsolate(const Isolate* isolate);
|
|
|
|
static bool IsServiceIsolateDescendant(const Isolate* isolate);
|
2015-02-12 19:10:55 +00:00
|
|
|
static Dart_Port Port();
|
|
|
|
|
|
|
|
static Dart_Port WaitForLoadPort();
|
|
|
|
static Dart_Port LoadPort();
|
|
|
|
|
2018-07-25 12:06:55 +00:00
|
|
|
// Returns `true` if the request was sucessfully sent. If it was, the
|
|
|
|
// [reply_port] will receive a Dart_TypedData_kUint8 response json.
|
|
|
|
static bool SendServiceRpc(uint8_t* request_json,
|
|
|
|
intptr_t request_json_length,
|
|
|
|
Dart_Port reply_port);
|
|
|
|
|
2015-02-12 19:10:55 +00:00
|
|
|
static void Run();
|
|
|
|
static bool SendIsolateStartupMessage();
|
|
|
|
static bool SendIsolateShutdownMessage();
|
2015-03-25 15:50:19 +00:00
|
|
|
static void SendServiceExitMessage();
|
|
|
|
static void Shutdown();
|
2015-02-12 19:10:55 +00:00
|
|
|
|
2015-10-06 16:16:39 +00:00
|
|
|
static void BootVmServiceLibrary();
|
|
|
|
|
2016-10-31 19:32:23 +00:00
|
|
|
static void RequestServerInfo(const SendPort& sp);
|
|
|
|
static void ControlWebServer(const SendPort& sp, bool enable);
|
|
|
|
|
2016-01-29 15:43:21 +00:00
|
|
|
static void SetServerAddress(const char* address);
|
|
|
|
|
|
|
|
// Returns the server's web address or NULL if none is running.
|
2016-11-08 21:54:47 +00:00
|
|
|
static const char* server_address() { return server_address_; }
|
2016-01-29 15:43:21 +00:00
|
|
|
|
2016-06-10 19:33:50 +00:00
|
|
|
static void VisitObjectPointers(ObjectPointerVisitor* visitor);
|
|
|
|
|
2015-09-15 19:49:52 +00:00
|
|
|
private:
|
|
|
|
static void KillServiceIsolate();
|
|
|
|
|
2015-02-12 19:10:55 +00:00
|
|
|
protected:
|
|
|
|
static void SetServicePort(Dart_Port port);
|
|
|
|
static void SetServiceIsolate(Isolate* isolate);
|
|
|
|
static void SetLoadPort(Dart_Port port);
|
2015-03-25 15:50:19 +00:00
|
|
|
static void FinishedExiting();
|
2015-02-12 19:10:55 +00:00
|
|
|
static void FinishedInitializing();
|
2019-04-10 22:55:20 +00:00
|
|
|
static void InitializingFailed();
|
2015-10-06 14:58:14 +00:00
|
|
|
static void MaybeMakeServiceIsolate(Isolate* isolate);
|
2019-07-08 23:49:05 +00:00
|
|
|
static Dart_IsolateGroupCreateCallback create_group_callback() {
|
|
|
|
return create_group_callback_;
|
2015-02-12 19:10:55 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 23:49:05 +00:00
|
|
|
static Dart_IsolateGroupCreateCallback create_group_callback_;
|
2015-02-12 19:10:55 +00:00
|
|
|
static Monitor* monitor_;
|
2019-04-10 22:55:20 +00:00
|
|
|
enum State {
|
|
|
|
kStopped,
|
|
|
|
kStarting,
|
|
|
|
kStarted,
|
|
|
|
kStopping,
|
|
|
|
};
|
|
|
|
static State state_;
|
2015-02-12 19:10:55 +00:00
|
|
|
static Isolate* isolate_;
|
|
|
|
static Dart_Port port_;
|
|
|
|
static Dart_Port load_port_;
|
2015-04-01 20:23:42 +00:00
|
|
|
static Dart_Port origin_;
|
2016-01-29 15:43:21 +00:00
|
|
|
static char* server_address_;
|
2015-02-12 19:10:55 +00:00
|
|
|
|
|
|
|
friend class Dart;
|
2018-08-16 22:01:42 +00:00
|
|
|
friend class Isolate;
|
2015-02-12 19:10:55 +00:00
|
|
|
friend class RunServiceTask;
|
|
|
|
friend class ServiceIsolateNatives;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dart
|
|
|
|
|
2016-10-26 07:26:03 +00:00
|
|
|
#endif // RUNTIME_VM_SERVICE_ISOLATE_H_
|