OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_H_ | |
6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_H_ | |
7 | |
8 #include "base/time/time.h" | |
9 #include "google_apis/gcm/base/gcm_export.h" | |
10 #include "google_apis/gcm/engine/connection_handler.h" | |
11 | |
12 namespace mcs_proto { | |
13 class LoginRequest; | |
14 } | |
15 | |
16 namespace gcm { | |
17 | |
18 // Factory for creating a ConnectionHandler and maintaining its connection. | |
19 // The factory retains ownership of the ConnectionHandler and will enforce | |
20 // backoff policies when attempting connections. | |
21 class GCM_EXPORT ConnectionFactory { | |
22 public: | |
23 ConnectionFactory(); | |
24 virtual ~ConnectionFactory(); | |
25 | |
26 // Create a new uninitialized connection handler. Should only be called once. | |
27 // The factory will retain ownership of the connection handler. | |
28 // |read_callback| will be invoked with the contents of any received protobuf | |
29 // message. | |
30 // |write_callback| will be invoked anytime a message has been successfully | |
31 // sent. Note: this just means the data was sent to the wire, not that the | |
32 // other end received it. | |
33 virtual ConnectionHandler* BuildConnectionHandler( | |
34 const ConnectionHandler::ProtoReceivedCallback& read_callback, | |
akalin
2013/11/21 04:13:09
having two callbacks passed in together indicates
Nicolas Zea
2013/11/22 05:39:18
Yeah, given that I don't expect this to be reused
| |
35 const ConnectionHandler::ProtoSentCallback& write_callback) = 0; | |
36 | |
37 // Opens a new connection for use by the locally owned connection handler | |
38 // (created via BuildConnectionHandler), and initiates login handshake using | |
39 // |login_request|. Upon completion of the handshake, |read_callback| | |
40 // will be invoked with a valid mcs_proto::LoginResponse. | |
41 // Note: BuildConnectionHandler must have already been invoked. | |
42 virtual void Connect(const mcs_proto::LoginRequest& login_request) = 0; | |
43 | |
44 // Whether or not the MCS endpoint is currently reachable with an active | |
45 // connection. | |
46 virtual bool IsEndpointReachable() const = 0; | |
47 | |
48 // If in backoff, the time at which the next retry will be made. Otherwise, | |
49 // a null time, indicating either no attempt to connect has been made or no | |
50 // backoff is in progress. | |
51 virtual base::TimeTicks NextRetryAttempt() const = 0; | |
52 }; | |
53 | |
54 } // namespace gcm | |
55 | |
56 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_H_ | |
OLD | NEW |