Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Unified Diff: remoting/host/host_status_service.h

Issue 11362267: Add status service for remoting host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/host/host_status_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/host_status_service.h
diff --git a/remoting/host/host_status_service.h b/remoting/host/host_status_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..f2d9a233e0f33cf9652a00485e512f450325489a
--- /dev/null
+++ b/remoting/host/host_status_service.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_HOST_STATUS_SERVICE_H_
+#define REMOTING_HOST_HOST_STATUS_SERVICE_H_
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "remoting/host/websocket_listener.h"
+
+namespace base {
+class DictionaryValue;
+} // namespace remoting
+
+namespace remoting {
+
+// HostStatusService implements WebSocket server that communicates with the
+// remoting web app and lets it get current status of the host.
Wez 2012/11/20 05:55:53 nit: "HostStatusService implements a WebSocket ser
Sergey Ulanov 2012/11/22 00:29:35 Done.
+class HostStatusService {
+ public:
+ HostStatusService();
+ ~HostStatusService();
+
+ // Must be called whenever state of the host changes.
+ void SetHostIsUp(const std::string& host_id);
+ void SetHostIsDown();
+
+ private:
+ class Connection;
+ friend class Connection;
+
+ // A helper to validate origin of an incoming connection.
+ static bool IsAllowedOrigin(const std::string& origin);
+
+ // Callback from WebsocketListener.
+ void OnNewConnection(scoped_ptr<WebsocketConnection> connection);
+
+ // Called from Connection instances when |connection| is closed and the
+ // Connection object should be destroyed.
+ void OnConnectionClosed(Connection* connection);
+
+ // Creates a status message that should be sent as a response to an incoming
+ // getHostState message.
+ scoped_ptr<base::DictionaryValue> GetStatusMessage();
+
+ WebsocketListener websocket_listener_;
+ std::set<Connection*> connections_;
+
+ // Host name we expect in incoming connections, e.g. "localhost:12810".
+ std::string service_host_name_;
+
+ // Current state of the host to provide to clients.
+ bool started_;
+ std::string host_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostStatusService);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_HOST_STATUS_SERVICE_H_
« no previous file with comments | « no previous file | remoting/host/host_status_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698