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

Side by Side Diff: jingle/notifier/listener/mediator_thread_impl.cc

Issue 5958001: The MediatorThread worker thread needs to have a CertVerifier... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix typos in xmpp_connection_unittest.cc Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "jingle/notifier/listener/mediator_thread_impl.h" 5 #include "jingle/notifier/listener/mediator_thread_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "jingle/notifier/base/task_pump.h" 9 #include "jingle/notifier/base/task_pump.h"
10 #include "jingle/notifier/communicator/connection_options.h" 10 #include "jingle/notifier/communicator/connection_options.h"
11 #include "jingle/notifier/communicator/const_communicator.h" 11 #include "jingle/notifier/communicator/const_communicator.h"
12 #include "jingle/notifier/communicator/xmpp_connection_generator.h" 12 #include "jingle/notifier/communicator/xmpp_connection_generator.h"
13 #include "jingle/notifier/listener/listen_task.h" 13 #include "jingle/notifier/listener/listen_task.h"
14 #include "jingle/notifier/listener/send_update_task.h" 14 #include "jingle/notifier/listener/send_update_task.h"
15 #include "jingle/notifier/listener/subscribe_task.h" 15 #include "jingle/notifier/listener/subscribe_task.h"
16 #include "net/base/cert_verifier.h"
16 #include "net/base/host_port_pair.h" 17 #include "net/base/host_port_pair.h"
17 #include "net/base/host_resolver.h" 18 #include "net/base/host_resolver.h"
18 #include "talk/xmpp/xmppclientsettings.h" 19 #include "talk/xmpp/xmppclientsettings.h"
19 20
20 namespace notifier { 21 namespace notifier {
21 22
22 MediatorThreadImpl::MediatorThreadImpl(const NotifierOptions& notifier_options) 23 MediatorThreadImpl::MediatorThreadImpl(const NotifierOptions& notifier_options)
23 : observers_(new ObserverListThreadSafe<Observer>()), 24 : observers_(new ObserverListThreadSafe<Observer>()),
24 parent_message_loop_(MessageLoop::current()), 25 parent_message_loop_(MessageLoop::current()),
25 notifier_options_(notifier_options), 26 notifier_options_(notifier_options),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 void MediatorThreadImpl::DoLogin( 113 void MediatorThreadImpl::DoLogin(
113 const buzz::XmppClientSettings& settings) { 114 const buzz::XmppClientSettings& settings) {
114 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); 115 DCHECK_EQ(MessageLoop::current(), worker_message_loop());
115 VLOG(1) << "P2P: Thread logging into talk network."; 116 VLOG(1) << "P2P: Thread logging into talk network.";
116 117
117 base_task_.reset(); 118 base_task_.reset();
118 119
119 // TODO(akalin): Use an existing HostResolver from somewhere (maybe 120 // TODO(akalin): Use an existing HostResolver from somewhere (maybe
120 // the IOThread one). 121 // the IOThread one).
122 // TODO(wtc): Sharing HostResolver and CertVerifier with the IO Thread won't
123 // work because HostResolver and CertVerifier are single-threaded.
121 host_resolver_.reset( 124 host_resolver_.reset(
122 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 125 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
123 NULL, NULL)); 126 NULL, NULL));
127 cert_verifier_.reset(new net::CertVerifier);
124 128
125 notifier::ServerInformation server_list[2]; 129 notifier::ServerInformation server_list[2];
126 int server_list_count = 0; 130 int server_list_count = 0;
127 131
128 // Override the default servers with a test notification server if one was 132 // Override the default servers with a test notification server if one was
129 // provided. 133 // provided.
130 if(!notifier_options_.xmpp_host_port.host().empty()) { 134 if (!notifier_options_.xmpp_host_port.host().empty()) {
131 server_list[0].server = notifier_options_.xmpp_host_port; 135 server_list[0].server = notifier_options_.xmpp_host_port;
132 server_list[0].special_port_magic = false; 136 server_list[0].special_port_magic = false;
133 server_list_count = 1; 137 server_list_count = 1;
134 } else { 138 } else {
135 // The default servers know how to serve over port 443 (that's the magic). 139 // The default servers know how to serve over port 443 (that's the magic).
136 server_list[0].server = net::HostPortPair("talk.google.com", 140 server_list[0].server = net::HostPortPair("talk.google.com",
137 notifier::kDefaultXmppPort); 141 notifier::kDefaultXmppPort);
138 server_list[0].special_port_magic = true; 142 server_list[0].special_port_magic = true;
139 server_list[1].server = net::HostPortPair("talkx.l.google.com", 143 server_list[1].server = net::HostPortPair("talkx.l.google.com",
140 notifier::kDefaultXmppPort); 144 notifier::kDefaultXmppPort);
141 server_list[1].special_port_magic = true; 145 server_list[1].special_port_magic = true;
142 server_list_count = 2; 146 server_list_count = 2;
143 } 147 }
144 148
145 // Autodetect proxy is on by default. 149 // Autodetect proxy is on by default.
146 notifier::ConnectionOptions options; 150 notifier::ConnectionOptions options;
147 151
148 login_.reset(new notifier::Login(this, 152 login_.reset(new notifier::Login(this,
149 settings, 153 settings,
150 options, 154 options,
151 host_resolver_.get(), 155 host_resolver_.get(),
156 cert_verifier_.get(),
152 server_list, 157 server_list,
153 server_list_count, 158 server_list_count,
154 notifier_options_.try_ssltcp_first)); 159 notifier_options_.try_ssltcp_first));
155 login_->StartConnection(); 160 login_->StartConnection();
156 } 161 }
157 162
158 void MediatorThreadImpl::DoDisconnect() { 163 void MediatorThreadImpl::DoDisconnect() {
159 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); 164 DCHECK_EQ(MessageLoop::current(), worker_message_loop());
160 VLOG(1) << "P2P: Thread logging out of talk network."; 165 VLOG(1) << "P2P: Thread logging out of talk network.";
161 login_.reset(); 166 login_.reset();
167 cert_verifier_.reset();
162 host_resolver_.reset(); 168 host_resolver_.reset();
163 base_task_.reset(); 169 base_task_.reset();
164 } 170 }
165 171
166 void MediatorThreadImpl::DoSubscribeForUpdates( 172 void MediatorThreadImpl::DoSubscribeForUpdates(
167 const std::vector<std::string>& subscribed_services_list) { 173 const std::vector<std::string>& subscribed_services_list) {
168 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); 174 DCHECK_EQ(MessageLoop::current(), worker_message_loop());
169 if (!base_task_.get()) { 175 if (!base_task_.get()) {
170 return; 176 return;
171 } 177 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 base_task_.reset(); 235 base_task_.reset();
230 observers_->Notify(&Observer::OnConnectionStateChange, false); 236 observers_->Notify(&Observer::OnConnectionStateChange, false);
231 } 237 }
232 238
233 void MediatorThreadImpl::OnSubscriptionStateChange(bool success) { 239 void MediatorThreadImpl::OnSubscriptionStateChange(bool success) {
234 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); 240 DCHECK_EQ(MessageLoop::current(), worker_message_loop());
235 observers_->Notify(&Observer::OnSubscriptionStateChange, success); 241 observers_->Notify(&Observer::OnSubscriptionStateChange, success);
236 } 242 }
237 243
238 } // namespace notifier 244 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698