38 #endif // !ION_PRODUCTION
47 static const int kRemoteThreads = 8;
48 static const char kRootPage[] =
52 " <title>Ion Remote</title>\n"
53 " <link rel=\"stylesheet\" href=\"/ion/css/style.css\">\n"
54 " <script type=\"text/javascript\">\n"
55 " window.location = \"/ion/settings/#^\"\n"
61 class IonRootHandler :
public HttpServer::RequestHandler {
63 IonRootHandler() : RequestHandler(
"/ion") {}
64 ~IonRootHandler()
override {}
66 const std::string HandleRequest(
const std::string& path_in,
68 std::string* content_type)
override {
69 const std::string path = path_in.empty() ?
"index.html" : path_in;
70 if (path ==
"index.html") {
73 const std::string& data =
82 class RootHandler :
public HttpServer::RequestHandler {
84 RootHandler() : RequestHandler(
"/") {}
85 ~RootHandler()
override {}
87 const std::string HandleRequest(
const std::string& path_in,
89 std::string* content_type)
override {
90 if (path_in.empty() || path_in ==
"index.html") {
91 *content_type =
"text/html";
99 static void RegisterAssetsForRemoteServer() {
100 IonRemoteGetUri::RegisterAssets();
101 IonRemoteRoot::RegisterAssets();
106 static const int kRemoteThreads = 0;
108 #endif // !ION_PRODUCTION
121 int port) :
HttpServer(port, kRemoteThreads) {
126 node_graph_handler_->SetFrame(frame);
148 void RemoteServer::Init(
int port) {
152 static const char kHeaderHtml[] =
153 "<div class=\"ion_header\">\n"
154 "<span><a href=\"/ion/resources/\">OpenGL resources</a></span>\n"
155 "<span><a href=\"/ion/settings/#^\">Settings</a></span>\n"
156 "<span><a href=\"/ion/shaders/shader_editor\">Shader editor</a></span>\n"
157 "<span><a href=\"/ion/nodegraph\">Node graph display</a></span>\n"
158 "<span><a href=\"/ion/tracing\">OpenGL tracing</a></span>\n"
159 "<span><a href=\"/ion/profile\">Run-time profile "
160 "diagram</a></span></div>\n";
166 LOG(
ERROR) <<
"*** ION: Unable to start Remote server.";
179 auto iter = handler_map.find(
"/ion/nodegraph");
180 if (iter != handler_map.end()) {
189 auto iter = handler_map.find(
"/ion/nodegraph");
190 if (iter != handler_map.end()) {
bool IsInvalidReference(const T &value)
IsInvalidReference() returns true if a passed const reference of type T has an address of InvalidRefe...
CallTraceHandler serves a snapshot of the current call trace.
HandlerMap GetHandlers() const
Returns the handlers registered with this server.
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
std::map< std::string, RequestHandlerPtr > HandlerMap
ShaderHandler serves files related to shaders, their dependencies, and the shader editor...
ResourceHandler serves files related to OpenGL resources.
static const std::string & GetFileData(const std::string &filename)
Returns the data of the passed filename if the manager contains it.
SettingHandler serves files related to Settings, including an interface for viewing and modifying the...
base::ReferentPtr< RequestHandler >::Type RequestHandlerPtr
Copyright 2016 Google Inc.
ION_REGISTER_ASSETS(IonRemoteGetUri)
Copyright 2016 Google Inc.
void RegisterHandler(const RequestHandlerPtr &handler)
Registers the passed handler at the path returned by handler->GetBasePath().
bool RemoveNode(const gfx::NodePtr &node) const
Removes a Node from the NodeGraphHandler.
NodeGraphHandler serves files to display Ion node graphs as text or HTML using the gfxutils::Printer ...
void Reset(T *new_shared)
Changes the pointer to point to the given shared, which may be NULL.
bool IsRunning() const
Returns whether the server is running.
RemoteServer(int port)
Starts a RemoteServer on the passed port.
#define ION_STATIC_ONCE(function)
Executes a given static void() or T() function exactly once.
std::map< std::string, std::string > QueryMap
kLongTerm is used for objects that have persistent lifetimes, such as managers.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
void AddNode(const gfx::NodePtr &node) const
Adds a Node to the NodeGraphHandler which allows Remote to inspect it in the web interface.
void SetHeaderHtml(const std::string &str)
TracingHandler serves files related to OpenGL tracing.