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

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

Issue 317723004: [GCM] Add ConnectionListener support, and hook up to debug page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GOOGLE_APIS_GCM_ENGINE_FAKE_CONNECTION_FACTORY_H_ 5 #ifndef GOOGLE_APIS_GCM_ENGINE_FAKE_CONNECTION_FACTORY_H_
6 #define GOOGLE_APIS_GCM_ENGINE_FAKE_CONNECTION_FACTORY_H_ 6 #define GOOGLE_APIS_GCM_ENGINE_FAKE_CONNECTION_FACTORY_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "google_apis/gcm/engine/connection_factory.h" 9 #include "google_apis/gcm/engine/connection_factory.h"
10 10
11 namespace gcm { 11 namespace gcm {
12 12
13 class FakeConnectionHandler; 13 class FakeConnectionHandler;
14 14
15 // A connection factory that mocks out real connections, using a fake connection 15 // A connection factory that mocks out real connections, using a fake connection
16 // handler instead. 16 // handler instead.
17 class FakeConnectionFactory : public ConnectionFactory { 17 class FakeConnectionFactory : public ConnectionFactory {
18 public: 18 public:
19 FakeConnectionFactory(); 19 FakeConnectionFactory();
20 virtual ~FakeConnectionFactory(); 20 virtual ~FakeConnectionFactory();
21 21
22 // ConnectionFactory implementation. 22 // ConnectionFactory implementation.
23 virtual void Initialize( 23 virtual void Initialize(
24 const BuildLoginRequestCallback& request_builder, 24 const BuildLoginRequestCallback& request_builder,
25 const ConnectionHandler::ProtoReceivedCallback& read_callback, 25 const ConnectionHandler::ProtoReceivedCallback& read_callback,
26 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; 26 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE;
27 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; 27 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE;
28 virtual void Connect() OVERRIDE; 28 virtual void Connect() OVERRIDE;
29 virtual bool IsEndpointReachable() const OVERRIDE; 29 virtual bool IsEndpointReachable() const OVERRIDE;
30 virtual std::string GetConnectionStateString() const OVERRIDE;
30 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; 31 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE;
31 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE; 32 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE;
33 virtual void SetConnectionListener(ConnectionListener* listener) OVERRIDE;
32 34
33 // Whether a connection reset has been triggered and is yet to run. 35 // Whether a connection reset has been triggered and is yet to run.
34 bool reconnect_pending() const { return reconnect_pending_; } 36 bool reconnect_pending() const { return reconnect_pending_; }
35 37
36 // Whether connection resets should be handled immediately or delayed until 38 // Whether connection resets should be handled immediately or delayed until
37 // release. 39 // release.
38 void set_delay_reconnect(bool should_delay) { 40 void set_delay_reconnect(bool should_delay) {
39 delay_reconnect_ = should_delay; 41 delay_reconnect_ = should_delay;
40 } 42 }
41 43
42 private: 44 private:
43 scoped_ptr<FakeConnectionHandler> connection_handler_; 45 scoped_ptr<FakeConnectionHandler> connection_handler_;
44 46
45 BuildLoginRequestCallback request_builder_; 47 BuildLoginRequestCallback request_builder_;
46 48
47 // Logic for handling connection resets. 49 // Logic for handling connection resets.
48 bool reconnect_pending_; 50 bool reconnect_pending_;
49 bool delay_reconnect_; 51 bool delay_reconnect_;
50 52
51 DISALLOW_COPY_AND_ASSIGN(FakeConnectionFactory); 53 DISALLOW_COPY_AND_ASSIGN(FakeConnectionFactory);
52 }; 54 };
53 55
54 } // namespace gcm 56 } // namespace gcm
55 57
56 #endif // GOOGLE_APIS_GCM_ENGINE_FAKE_CONNECTION_FACTORY_H_ 58 #endif // GOOGLE_APIS_GCM_ENGINE_FAKE_CONNECTION_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698