Index: remoting/host/gnubby_advertiser.h |
diff --git a/remoting/host/gnubby_advertiser.h b/remoting/host/gnubby_advertiser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fbf57b620bd8279663e823c77e1767830f07c63c |
--- /dev/null |
+++ b/remoting/host/gnubby_advertiser.h |
@@ -0,0 +1,73 @@ |
+// Copyright 2014 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_GNUBBY_ADVERTISER_H_ |
+#define REMOTING_HOST_GNUBBY_ADVERTISER_H_ |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/single_thread_task_runner.h" |
+#include "net/base/io_buffer.h" |
+#include "net/socket/client_socket_factory.h" |
+#include "net/socket/stream_socket.h" |
+ |
+namespace remoting { |
+ |
+// Class that advertises to the local gnubbyd that a port on the localhost will |
+// accept gnubbyd requests. |
+ |
+class GnubbyAdvertiser : public base::RefCountedThreadSafe<GnubbyAdvertiser> { |
+ public: |
+ GnubbyAdvertiser( |
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
+ net::ClientSocketFactory* client_socket_factory); |
+ |
+ // Advertise a port to the local gnubbyd. The instance reference count is |
+ // incremented so that callers do not have to maintain a reference until all |
+ // of the callbacks are complete. |
+ void Advertise(int proxy_port); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<GnubbyAdvertiser>; |
+ |
+ virtual ~GnubbyAdvertiser(); |
+ |
+ // Close the gnubbyd socket. |
+ void Close(int result); |
+ |
+ // Called when connection is made to gnubbyd socket. |
+ void OnConnect(int result); |
+ |
+ // Write advertiser information to gnubbyd. |
+ void Write(); |
+ |
+ // Called when data was written to the gnubbyd socket. |
+ void OnWrite(int result); |
+ |
+ // Read response to advertiser information. |
+ void Read(); |
+ |
+ // Called when data was read from the gnubbyd socket. |
+ void OnRead(int result); |
+ |
+ // Task runner used by this class. |
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
+ |
+ // Factory to create socket to advertise with gnubbyd. |
+ net::ClientSocketFactory* client_socket_factory_; |
+ |
+ // Socket used to communicate with local gnubbyd. |
+ scoped_ptr<net::StreamSocket> socket_; |
+ |
+ // Port to be advertised. |
+ int proxy_port_; |
+ |
+ // Input I/O buffer for socket reads. |
+ scoped_refptr<net::IOBufferWithSize> in_buffer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GnubbyAdvertiser); |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_GNUBBY_ADVERTISER_H_ |