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 "google_apis/gcm/base/gcm_export.h" | |
9 #include "google_apis/gcm/engine/connection_handler.h" | |
10 | |
11 namespace mcs_proto { | |
12 class LoginRequest; | |
13 } | |
14 | |
15 namespace gcm { | |
16 | |
17 // Factory for creating a ConnectionHandler and maintaing its connection. | |
akalin
2013/11/02 00:15:43
maintaing -> maintaining
Nicolas Zea
2013/11/15 23:37:35
Done.
| |
18 // The factory retains ownership of the ConnectionHandler and will enforce | |
19 // backoff policies when attempting connections. | |
20 class GCM_EXPORT ConnectionFactory { | |
21 public: | |
22 ConnectionFactory(); | |
23 virtual ~ConnectionFactory(); | |
24 | |
25 // Create a new uninitialized connection handler. Should only be called once. | |
26 // The factory will retain ownership of the connection handler. | |
27 // |read_callback| will be invoked with the contents of any received protobuf | |
28 // message. | |
29 // |write_callback| will be invoked anytime a message has been successfully | |
30 // sent. Note: this just means the data was sent to the wire, not that the | |
31 // other end received it. | |
32 virtual ConnectionHandler* BuildConnectionHandler( | |
33 const ConnectionHandler::ProtoReceivedCallback& read_callback, | |
34 const ConnectionHandler::ProtoSentCallback& write_callback) = 0; | |
35 | |
36 // Opens a new connection for use by the locally owned connection handler | |
37 // (created via BuildConnectionHandler), and initiates login handshake using | |
38 // |login_request|. Upon completion of the handshake, |read_callback| | |
39 // will be invoked with a valid mcs_proto::LoginResponse. | |
40 // Note: BuildConnectionHandler must have already been invoked. | |
41 virtual void Connect(const mcs_proto::LoginRequest& login_request) = 0; | |
42 | |
43 // Whether or not the MCS endpoint is currently reachable with an active | |
44 // connection. | |
45 virtual bool IsEndpointReachable() const = 0; | |
46 }; | |
47 | |
48 } // namespace gcm | |
49 | |
50 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_H_ | |
OLD | NEW |