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

Unified Diff: remoting/host/gnubby_advertiser.h

Issue 138753005: Add gnubby authentication to remoting host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months 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
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_

Powered by Google App Engine
This is Rietveld 408576698