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#include "google_apis/gcm/engine/fake_connection_factory.h" 6 7#include "google_apis/gcm/engine/fake_connection_handler.h" 8#include "google_apis/gcm/protocol/mcs.pb.h" 9#include "net/socket/stream_socket.h" 10 11namespace gcm { 12 13FakeConnectionFactory::FakeConnectionFactory() 14 : reconnect_pending_(false), 15 delay_reconnect_(false) { 16} 17 18FakeConnectionFactory::~FakeConnectionFactory() { 19} 20 21void FakeConnectionFactory::Initialize( 22 const BuildLoginRequestCallback& request_builder, 23 const ConnectionHandler::ProtoReceivedCallback& read_callback, 24 const ConnectionHandler::ProtoSentCallback& write_callback) { 25 request_builder_ = request_builder; 26 connection_handler_.reset(new FakeConnectionHandler(read_callback, 27 write_callback)); 28} 29 30ConnectionHandler* FakeConnectionFactory::GetConnectionHandler() const { 31 return connection_handler_.get(); 32} 33 34void FakeConnectionFactory::Connect() { 35 mcs_proto::LoginRequest login_request; 36 request_builder_.Run(&login_request); 37 connection_handler_->Init(login_request, NULL); 38} 39 40bool FakeConnectionFactory::IsEndpointReachable() const { 41 return connection_handler_.get() && connection_handler_->CanSendMessage(); 42} 43 44std::string FakeConnectionFactory::GetConnectionStateString() const { 45 return ""; 46} 47 48base::TimeTicks FakeConnectionFactory::NextRetryAttempt() const { 49 return base::TimeTicks(); 50} 51 52void FakeConnectionFactory::SignalConnectionReset( 53 ConnectionResetReason reason) { 54 if (!delay_reconnect_) 55 Connect(); 56 else 57 reconnect_pending_ = true; 58} 59 60void FakeConnectionFactory::SetConnectionListener( 61 ConnectionListener* listener) { 62} 63 64} // namespace gcm 65