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

Side by Side Diff: blimp/net/client_connection_manager.h

Issue 2632803002: Remove all blimp network code. (Closed)
Patch Set: merge from origin/master for good measure Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 BLIMP_NET_CLIENT_CONNECTION_MANAGER_H_
6 #define BLIMP_NET_CLIENT_CONNECTION_MANAGER_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "blimp/net/blimp_net_export.h"
15 #include "blimp/net/connection_error_observer.h"
16
17 namespace blimp {
18
19 class BlimpConnection;
20 class BlimpTransport;
21 class ConnectionHandler;
22
23 // Coordinates the channel creation and authentication workflows for
24 // outgoing (Client) network connections.
25 //
26 // TODO(haibinlu): cope with network changes that may potentially affect the
27 // endpoint that we're trying to connect to.
28 class BLIMP_NET_EXPORT ClientConnectionManager
29 : public ConnectionErrorObserver {
30 public:
31 // Caller is responsible for ensuring that |connection_handler|
32 // outlives |this|.
33 explicit ClientConnectionManager(ConnectionHandler* connection_handler);
34
35 ~ClientConnectionManager() override;
36
37 // Adds a transport. All transports are expected to be added before invoking
38 // |Connect|.
39 void AddTransport(std::unique_ptr<BlimpTransport> transport);
40
41 // Attempts to create a connection using any of the BlimpTransports in
42 // |transports_|.
43 // This will result in the handler being called back at-most-once.
44 //
45 // This is also a placeholder for automatic reconnection logic for common
46 // cases such as network switches, online/offline changes.
47 void Connect();
48
49 // Sets the client auth token to use in the authentication message.
50 void set_client_auth_token(const std::string& client_auth_token) {
51 client_auth_token_ = client_auth_token;
52 }
53
54 private:
55 // Tries to connect using the BlimpTransport specified at |transport_index|.
56 void Connect(int transport_index);
57
58 // Callback invoked by transports_[transport_index] to indicate that it has a
59 // connection ready to be authenticated or there is an error.
60 void OnConnectResult(int transport_index, int result);
61
62 // Sends authentication message to the engine via |connection|.
63 void SendAuthenticationMessage(std::unique_ptr<BlimpConnection> connection);
64
65 // Invoked after the authentication message is sent to |connection|.
66 // The result of the write operation is passed via |result|.
67 void OnAuthenticationMessageSent(std::unique_ptr<BlimpConnection> connection,
68 int result);
69
70 // ConnectionErrorObserver implementation.
71 void OnConnectionError(int error) override;
72
73 std::string client_auth_token_;
74 ConnectionHandler* connection_handler_;
75 std::vector<std::unique_ptr<BlimpTransport>> transports_;
76 base::WeakPtrFactory<ClientConnectionManager> weak_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(ClientConnectionManager);
79 };
80
81 } // namespace blimp
82
83 #endif // BLIMP_NET_CLIENT_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « blimp/net/browser_connection_handler_unittest.cc ('k') | blimp/net/client_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698