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

Side by Side Diff: google_apis/gcm/engine/connection_event_tracker.h

Issue 2481873002: Added ClientEvent proto and structure for storing events in the factory. (Closed)
Patch Set: Added ConnectionEventTracker to manage all the events. Created 4 years 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 2016 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_EVENT_TRACKER_H_
6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_EVENT_TRACKER_H_
7
8 #include <deque>
9
10 #include "google_apis/gcm/base/gcm_export.h"
11 #include "google_apis/gcm/protocol/mcs.pb.h"
12 #include "net/base/net_errors.h"
13 #include "net/base/network_change_notifier.h"
14
15 namespace mcs_proto {
16 class LoginRequest;
17 }
18
19 namespace gcm {
20
21 class GCM_EXPORT ConnectionEventTracker {
22 public:
23 // TODO(harkness): Pass in the storage information.
24 ConnectionEventTracker();
25 ~ConnectionEventTracker();
26
27 // Start recording a new connection attempt. This should never be called if
28 // a connection attempt is already ongoing.
29 void StartConnectionAttempt();
30
31 // Ends the record for a connection attempt and moves it to the completed
32 // connections list.
33 void EndConnectionAttempt();
34
35 // Record that the existing connection attempt has succeeded. Note that this
36 // doesn't mean the connection is necessarily valid. It could still fail with
37 // an authentication error.
38 void ConnectionAttemptSucceeded();
39
40 // Records that the connection succeeded but then failed to login.
41 void ConnectionLoginFailed();
42
43 // Record that the existing connection attempt has failed.
44 void ConnectionAttemptFailed(int error);
45
46 // Records the current type of network connection.
Peter Beverloo 2016/12/02 15:19:13 micro nit: // To be called when the network conn
harkness 2016/12/05 15:39:00 Removing entirely as Nicolas referred me to a meth
47 void OnNetworkChanged(
Nicolas Zea 2016/12/01 18:51:49 nit: Only simple accessors should be inlined (and
harkness 2016/12/05 15:39:00 Removing entirely.
48 net::NetworkChangeNotifier::ConnectionType network_type) {
49 network_type_ = network_type;
50 }
51
52 // Write any previous connection information to the login request.
Peter Beverloo 2016/12/02 15:19:13 nit: ... information to the |*login_request|. a
harkness 2016/12/05 15:39:00 Done.
53 void WriteToLoginRequest(mcs_proto::LoginRequest* request);
54
55 private:
56 // Storage for all the events which have completed.
57 std::deque<mcs_proto::ClientEvent> completed_events_;
58
59 // Current connection attempt.
60 mcs_proto::ClientEvent current_event_;
61
62 // The type of network connection when last updated.
63 net::NetworkChangeNotifier::ConnectionType network_type_ =
64 net::NetworkChangeNotifier::CONNECTION_NONE;
65 };
Peter Beverloo 2016/12/02 15:19:13 DISALLOW_COPY_AND_ASSIGN
harkness 2016/12/05 15:39:00 Done.
66
67 } // namespace gcm
68
69 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_EVENT_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698