Add UMAs to measure Android tab state transition
[chromium-blink-merge.git] / jingle / notifier / communicator / login_settings.cc
blob3f1d3dd4893c6155a99e6ba991c4d2b43289fe04
1 // Copyright (c) 2012 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.
5 #include <string>
7 #include "jingle/notifier/communicator/login_settings.h"
9 #include "base/logging.h"
10 #include "jingle/notifier/base/server_information.h"
11 #include "net/cert/cert_verifier.h"
12 #include "webrtc/base/common.h"
13 #include "webrtc/base/socketaddress.h"
15 namespace notifier {
17 LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings,
18 const scoped_refptr<net::URLRequestContextGetter>&
19 request_context_getter,
20 const ServerList& default_servers,
21 bool try_ssltcp_first,
22 const std::string& auth_mechanism)
23 : user_settings_(user_settings),
24 request_context_getter_(request_context_getter),
25 default_servers_(default_servers),
26 try_ssltcp_first_(try_ssltcp_first),
27 auth_mechanism_(auth_mechanism) {
28 DCHECK_GT(default_servers_.size(), 0u);
31 LoginSettings::~LoginSettings() {}
33 void LoginSettings::set_user_settings(
34 const buzz::XmppClientSettings& user_settings) {
35 user_settings_ = user_settings;
38 ServerList LoginSettings::GetServers() const {
39 return GetServersForTime(base::Time::Now());
42 namespace {
44 // How long a redirect is valid for.
45 const int kRedirectExpirationTimeMinutes = 5;
47 } // namespace
49 void LoginSettings::SetRedirectServer(
50 const ServerInformation& redirect_server) {
51 redirect_server_ = redirect_server;
52 redirect_expiration_ =
53 base::Time::Now() +
54 base::TimeDelta::FromMinutes(kRedirectExpirationTimeMinutes);
57 ServerList LoginSettings::GetServersForTimeForTest(base::Time now) const {
58 return GetServersForTime(now);
61 base::Time LoginSettings::GetRedirectExpirationForTest() const {
62 return redirect_expiration_;
65 ServerList LoginSettings::GetServersForTime(base::Time now) const {
66 return
67 (now < redirect_expiration_) ?
68 ServerList(1, redirect_server_) :
69 default_servers_;
72 } // namespace notifier