| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef REMOTING_HOST_HOST_STATUS_SERVICE_H_ | 
|  | 6 #define REMOTING_HOST_HOST_STATUS_SERVICE_H_ | 
|  | 7 | 
|  | 8 #include <string> | 
|  | 9 | 
|  | 10 #include "base/memory/scoped_ptr.h" | 
|  | 11 #include "remoting/host/websocket_listener.h" | 
|  | 12 | 
|  | 13 namespace base { | 
|  | 14 class DictionaryValue; | 
|  | 15 }  // namespace remoting | 
|  | 16 | 
|  | 17 namespace remoting { | 
|  | 18 | 
|  | 19 // HostStatusService implements a WebSocket server for the remoting web app to | 
|  | 20 // use to query the current status of the host. | 
|  | 21 class HostStatusService { | 
|  | 22  public: | 
|  | 23   HostStatusService(); | 
|  | 24   ~HostStatusService(); | 
|  | 25 | 
|  | 26   // Must be called whenever state of the host changes. | 
|  | 27   void SetHostIsUp(const std::string& host_id); | 
|  | 28   void SetHostIsDown(); | 
|  | 29 | 
|  | 30  private: | 
|  | 31   class Connection; | 
|  | 32   friend class Connection; | 
|  | 33 | 
|  | 34   // Returns true if |origin| is one of the remoting extension URLs. | 
|  | 35   static bool IsAllowedOrigin(const std::string& origin); | 
|  | 36 | 
|  | 37   // Callback from WebsocketListener. | 
|  | 38   void OnNewConnection(scoped_ptr<WebSocketConnection> connection); | 
|  | 39 | 
|  | 40   // Called from Connection instances when |connection| is closed and the | 
|  | 41   // Connection object should be destroyed. | 
|  | 42   void OnConnectionClosed(Connection* connection); | 
|  | 43 | 
|  | 44   // Creates a status message that should be sent as a response to an incoming | 
|  | 45   // getHostState message. | 
|  | 46   scoped_ptr<base::DictionaryValue> GetStatusMessage(); | 
|  | 47 | 
|  | 48   WebSocketListener websocket_listener_; | 
|  | 49   std::set<Connection*> connections_; | 
|  | 50 | 
|  | 51   // Host name we expect in incoming connections, e.g. "localhost:12810". | 
|  | 52   std::string service_host_name_; | 
|  | 53 | 
|  | 54   // Current state of the host to provide to clients. | 
|  | 55   bool started_; | 
|  | 56   std::string host_id_; | 
|  | 57 | 
|  | 58   DISALLOW_COPY_AND_ASSIGN(HostStatusService); | 
|  | 59 }; | 
|  | 60 | 
|  | 61 }  // namespace remoting | 
|  | 62 | 
|  | 63 #endif  // REMOTING_HOST_HOST_STATUS_SERVICE_H_ | 
| OLD | NEW | 
|---|