Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "net/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 int DoResolveHost(); | 163 int DoResolveHost(); |
| 164 int DoResolveHostComplete(int rv); | 164 int DoResolveHostComplete(int rv); |
| 165 int DoLoadServerInfo(); | 165 int DoLoadServerInfo(); |
| 166 int DoLoadServerInfoComplete(int rv); | 166 int DoLoadServerInfoComplete(int rv); |
| 167 int DoConnect(); | 167 int DoConnect(); |
| 168 int DoResumeConnect(); | 168 int DoResumeConnect(); |
| 169 int DoConnectComplete(int rv); | 169 int DoConnectComplete(int rv); |
| 170 | 170 |
| 171 void OnIOComplete(int rv); | 171 void OnIOComplete(int rv); |
| 172 | 172 |
| 173 void RunAuxilaryJob(); | |
| 174 | |
| 175 void CancelWaitForDataReadyPendingCallback(); | |
| 176 | |
| 177 void CancelJob(); | |
| 178 | |
| 173 void CancelWaitForDataReadyCallback(); | 179 void CancelWaitForDataReadyCallback(); |
| 174 | 180 |
| 175 CompletionCallback callback() { | 181 CompletionCallback callback() { return callback_; } |
| 176 return callback_; | |
| 177 } | |
| 178 | 182 |
| 179 const QuicServerId server_id() const { | 183 const QuicServerId server_id() const { return server_id_; } |
| 180 return server_id_; | 184 |
| 181 } | 185 QuicSession* session() { return session_; } |
| 186 | |
| 187 bool is_cancelled() const { return is_cancelled_; } | |
| 188 | |
| 189 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } | |
| 182 | 190 |
| 183 private: | 191 private: |
| 184 enum IoState { | 192 enum IoState { |
| 185 STATE_NONE, | 193 STATE_NONE, |
| 186 STATE_RESOLVE_HOST, | 194 STATE_RESOLVE_HOST, |
| 187 STATE_RESOLVE_HOST_COMPLETE, | 195 STATE_RESOLVE_HOST_COMPLETE, |
| 188 STATE_LOAD_SERVER_INFO, | 196 STATE_LOAD_SERVER_INFO, |
| 189 STATE_LOAD_SERVER_INFO_COMPLETE, | 197 STATE_LOAD_SERVER_INFO_COMPLETE, |
| 190 STATE_CONNECT, | 198 STATE_CONNECT, |
| 191 STATE_RESUME_CONNECT, | 199 STATE_RESUME_CONNECT, |
| 192 STATE_CONNECT_COMPLETE, | 200 STATE_CONNECT_COMPLETE, |
| 201 STATE_CANCELLED, | |
| 193 }; | 202 }; |
| 194 IoState io_state_; | 203 IoState io_state_; |
| 195 | 204 |
| 196 QuicStreamFactory* factory_; | 205 QuicStreamFactory* factory_; |
| 197 SingleRequestHostResolver host_resolver_; | 206 SingleRequestHostResolver host_resolver_; |
| 198 QuicServerId server_id_; | 207 QuicServerId server_id_; |
| 208 base::StringPiece method_; | |
|
Ryan Hamilton
2015/02/05 20:30:28
instead of doing this, let's change the Job() cons
ramant (doing other things)
2015/02/06 00:59:41
Done.
| |
| 199 bool is_post_; | 209 bool is_post_; |
| 200 bool was_alternate_protocol_recently_broken_; | 210 bool was_alternate_protocol_recently_broken_; |
| 201 scoped_ptr<QuicServerInfo> server_info_; | 211 scoped_ptr<QuicServerInfo> server_info_; |
| 212 bool is_cancelled_; | |
| 213 bool started_another_job_; | |
| 202 const BoundNetLog net_log_; | 214 const BoundNetLog net_log_; |
| 203 QuicClientSession* session_; | 215 QuicClientSession* session_; |
| 204 CompletionCallback callback_; | 216 CompletionCallback callback_; |
| 205 AddressList address_list_; | 217 AddressList address_list_; |
| 206 base::TimeTicks disk_cache_load_start_time_; | 218 base::TimeTicks disk_cache_load_start_time_; |
| 207 base::TimeTicks dns_resolution_start_time_; | 219 base::TimeTicks dns_resolution_start_time_; |
| 208 base::WeakPtrFactory<Job> weak_factory_; | 220 base::WeakPtrFactory<Job> weak_factory_; |
| 209 DISALLOW_COPY_AND_ASSIGN(Job); | 221 DISALLOW_COPY_AND_ASSIGN(Job); |
| 210 }; | 222 }; |
| 211 | 223 |
| 212 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, | 224 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, |
| 213 HostResolver* host_resolver, | 225 HostResolver* host_resolver, |
| 214 const HostPortPair& host_port_pair, | 226 const HostPortPair& host_port_pair, |
| 215 bool is_https, | 227 bool is_https, |
| 216 bool was_alternate_protocol_recently_broken, | 228 bool was_alternate_protocol_recently_broken, |
| 217 PrivacyMode privacy_mode, | 229 PrivacyMode privacy_mode, |
| 218 base::StringPiece method, | 230 base::StringPiece method, |
| 219 QuicServerInfo* server_info, | 231 QuicServerInfo* server_info, |
| 220 const BoundNetLog& net_log) | 232 const BoundNetLog& net_log) |
| 221 : io_state_(STATE_RESOLVE_HOST), | 233 : io_state_(STATE_RESOLVE_HOST), |
| 222 factory_(factory), | 234 factory_(factory), |
| 223 host_resolver_(host_resolver), | 235 host_resolver_(host_resolver), |
| 224 server_id_(host_port_pair, is_https, privacy_mode), | 236 server_id_(host_port_pair, is_https, privacy_mode), |
| 237 method_(method), | |
| 225 is_post_(method == "POST"), | 238 is_post_(method == "POST"), |
| 226 was_alternate_protocol_recently_broken_( | 239 was_alternate_protocol_recently_broken_( |
| 227 was_alternate_protocol_recently_broken), | 240 was_alternate_protocol_recently_broken), |
| 228 server_info_(server_info), | 241 server_info_(server_info), |
| 242 is_cancelled_(false), | |
| 243 started_another_job_(false), | |
| 229 net_log_(net_log), | 244 net_log_(net_log), |
| 230 session_(nullptr), | 245 session_(nullptr), |
| 231 weak_factory_(this) {} | 246 weak_factory_(this) { |
| 247 } | |
| 232 | 248 |
| 233 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, | 249 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, |
| 234 HostResolver* host_resolver, | 250 HostResolver* host_resolver, |
| 235 QuicClientSession* session, | 251 QuicClientSession* session, |
| 236 QuicServerId server_id) | 252 QuicServerId server_id) |
| 237 : io_state_(STATE_RESUME_CONNECT), | 253 : io_state_(STATE_RESUME_CONNECT), |
| 238 factory_(factory), | 254 factory_(factory), |
| 239 host_resolver_(host_resolver), // unused | 255 host_resolver_(host_resolver), // unused |
| 240 server_id_(server_id), | 256 server_id_(server_id), |
| 241 is_post_(false), // unused | 257 method_("Get"), // unused |
| 258 is_post_(false), // unused | |
| 242 was_alternate_protocol_recently_broken_(false), // unused | 259 was_alternate_protocol_recently_broken_(false), // unused |
| 243 net_log_(session->net_log()), // unused | 260 net_log_(session->net_log()), // unused |
| 244 session_(session), | 261 session_(session), |
| 245 weak_factory_(this) {} | 262 weak_factory_(this) { |
| 263 } | |
| 246 | 264 |
| 247 QuicStreamFactory::Job::~Job() { | 265 QuicStreamFactory::Job::~Job() { |
| 248 } | 266 } |
| 249 | 267 |
| 250 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { | 268 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { |
| 251 int rv = DoLoop(OK); | 269 int rv = DoLoop(OK); |
| 252 if (rv == ERR_IO_PENDING) | 270 if (rv == ERR_IO_PENDING) |
| 253 callback_ = callback; | 271 callback_ = callback; |
| 254 | 272 |
| 255 return rv > 0 ? OK : rv; | 273 return rv > 0 ? OK : rv; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 278 CHECK_EQ(OK, rv); | 296 CHECK_EQ(OK, rv); |
| 279 rv = DoConnect(); | 297 rv = DoConnect(); |
| 280 break; | 298 break; |
| 281 case STATE_RESUME_CONNECT: | 299 case STATE_RESUME_CONNECT: |
| 282 CHECK_EQ(OK, rv); | 300 CHECK_EQ(OK, rv); |
| 283 rv = DoResumeConnect(); | 301 rv = DoResumeConnect(); |
| 284 break; | 302 break; |
| 285 case STATE_CONNECT_COMPLETE: | 303 case STATE_CONNECT_COMPLETE: |
| 286 rv = DoConnectComplete(rv); | 304 rv = DoConnectComplete(rv); |
| 287 break; | 305 break; |
| 306 case STATE_CANCELLED: | |
| 307 return OK; // exit the DoLoop. | |
| 288 default: | 308 default: |
| 289 NOTREACHED() << "io_state_: " << io_state_; | 309 NOTREACHED() << "io_state_: " << io_state_; |
| 290 break; | 310 break; |
| 291 } | 311 } |
| 292 } while (io_state_ != STATE_NONE && rv != ERR_IO_PENDING); | 312 } while (io_state_ != STATE_NONE && rv != ERR_IO_PENDING); |
| 293 return rv; | 313 return rv; |
| 294 } | 314 } |
| 295 | 315 |
| 296 void QuicStreamFactory::Job::OnIOComplete(int rv) { | 316 void QuicStreamFactory::Job::OnIOComplete(int rv) { |
| 297 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 317 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 298 tracked_objects::ScopedTracker tracking_profile1( | 318 tracked_objects::ScopedTracker tracking_profile1( |
| 299 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 319 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 300 "422516 QuicStreamFactory::Job::OnIOComplete1")); | 320 "422516 QuicStreamFactory::Job::OnIOComplete1")); |
| 301 | 321 |
| 302 rv = DoLoop(rv); | 322 rv = DoLoop(rv); |
| 303 | 323 |
| 304 tracked_objects::ScopedTracker tracking_profile2( | 324 tracked_objects::ScopedTracker tracking_profile2( |
| 305 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 325 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 306 "422516 QuicStreamFactory::Job::OnIOComplete2")); | 326 "422516 QuicStreamFactory::Job::OnIOComplete2")); |
| 307 | 327 |
| 308 if (rv != ERR_IO_PENDING && !callback_.is_null()) { | 328 if (rv != ERR_IO_PENDING && !callback_.is_null()) { |
| 309 callback_.Run(rv); | 329 callback_.Run(rv); |
| 310 } | 330 } |
| 311 } | 331 } |
| 312 | 332 |
| 333 void QuicStreamFactory::Job::RunAuxilaryJob() { | |
| 334 started_another_job_ = true; | |
|
Ryan Hamilton
2015/02/05 20:30:28
Does started_nother_job_ mean that this job starte
ramant (doing other things)
2015/02/06 00:59:41
Done.
| |
| 335 int rv = Run(base::Bind(&QuicStreamFactory::OnJobComplete, | |
| 336 base::Unretained(factory_), this)); | |
| 337 if (rv == OK) { | |
| 338 factory_->OnJobComplete(this, rv); | |
| 339 } | |
| 340 } | |
| 341 | |
| 342 void QuicStreamFactory::Job::CancelWaitForDataReadyPendingCallback() { | |
| 343 // If we are waiting for WaitForDataReadyCallback, then cancel the pending | |
| 344 // callback. | |
| 345 if (server_info_ && io_state_ == STATE_LOAD_SERVER_INFO_COMPLETE) | |
| 346 server_info_->CancelWaitForDataReadyCallback(); | |
| 347 } | |
| 348 | |
| 349 void QuicStreamFactory::Job::CancelJob() { | |
| 350 DCHECK(!is_cancelled_); | |
| 351 CancelWaitForDataReadyPendingCallback(); | |
| 352 callback_.Reset(); | |
| 353 if (session_) { | |
| 354 session_->connection()->SendConnectionClose( | |
| 355 QUIC_LOAD_SERVER_CONFIG_JOB_CANCELLED); | |
| 356 session_ = nullptr; | |
| 357 } | |
| 358 is_cancelled_ = true; | |
| 359 io_state_ = STATE_CANCELLED; | |
| 360 } | |
| 361 | |
| 313 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { | 362 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { |
| 314 // If we are waiting for WaitForDataReadyCallback, then cancel the callback. | 363 CancelWaitForDataReadyPendingCallback(); |
| 315 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE) | |
| 316 return; | |
| 317 server_info_->CancelWaitForDataReadyCallback(); | |
| 318 OnIOComplete(OK); | 364 OnIOComplete(OK); |
| 319 } | 365 } |
| 320 | 366 |
| 321 int QuicStreamFactory::Job::DoResolveHost() { | 367 int QuicStreamFactory::Job::DoResolveHost() { |
| 322 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 368 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 323 tracked_objects::ScopedTracker tracking_profile( | 369 tracked_objects::ScopedTracker tracking_profile( |
| 324 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 370 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 325 "422516 QuicStreamFactory::Job::DoResolveHost")); | 371 "422516 QuicStreamFactory::Job::DoResolveHost")); |
| 326 | 372 |
| 327 // Start loading the data now, and wait for it after we resolve the host. | 373 // Start loading the data now, and wait for it after we resolve the host. |
| 328 if (server_info_) { | 374 if (server_info_) { |
| 329 server_info_->Start(); | 375 server_info_->Start(); |
| 330 } | 376 } |
| 331 | 377 |
| 332 io_state_ = STATE_RESOLVE_HOST_COMPLETE; | 378 io_state_ = STATE_RESOLVE_HOST_COMPLETE; |
| 333 dns_resolution_start_time_ = base::TimeTicks::Now(); | 379 dns_resolution_start_time_ = base::TimeTicks::Now(); |
| 334 return host_resolver_.Resolve( | 380 return host_resolver_.Resolve( |
| 335 HostResolver::RequestInfo(server_id_.host_port_pair()), | 381 HostResolver::RequestInfo(server_id_.host_port_pair()), DEFAULT_PRIORITY, |
| 336 DEFAULT_PRIORITY, | |
| 337 &address_list_, | 382 &address_list_, |
| 338 base::Bind(&QuicStreamFactory::Job::OnIOComplete, | 383 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), |
| 339 weak_factory_.GetWeakPtr()), | |
| 340 net_log_); | 384 net_log_); |
| 341 } | 385 } |
| 342 | 386 |
| 343 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { | 387 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { |
| 344 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 388 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 345 tracked_objects::ScopedTracker tracking_profile( | 389 tracked_objects::ScopedTracker tracking_profile( |
| 346 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 390 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 347 "422516 QuicStreamFactory::Job::DoResolveHostComplete")); | 391 "422516 QuicStreamFactory::Job::DoResolveHostComplete")); |
| 348 | 392 |
| 349 UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolutionTime", | 393 UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolutionTime", |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 DCHECK_EQ(0, load_server_info_timeout_ms); | 425 DCHECK_EQ(0, load_server_info_timeout_ms); |
| 382 load_server_info_timeout_ms = | 426 load_server_info_timeout_ms = |
| 383 (factory_->load_server_info_timeout_srtt_multiplier_ * | 427 (factory_->load_server_info_timeout_srtt_multiplier_ * |
| 384 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds(server_id_)) / | 428 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds(server_id_)) / |
| 385 1000; | 429 1000; |
| 386 } | 430 } |
| 387 if (load_server_info_timeout_ms > 0) { | 431 if (load_server_info_timeout_ms > 0) { |
| 388 factory_->task_runner_->PostDelayedTask( | 432 factory_->task_runner_->PostDelayedTask( |
| 389 FROM_HERE, | 433 FROM_HERE, |
| 390 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, | 434 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, |
| 391 weak_factory_.GetWeakPtr()), | 435 GetWeakPtr()), |
| 392 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms)); | 436 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms)); |
| 393 } | 437 } |
| 394 | 438 |
| 395 disk_cache_load_start_time_ = base::TimeTicks::Now(); | 439 disk_cache_load_start_time_ = base::TimeTicks::Now(); |
| 396 return server_info_->WaitForDataReady( | 440 int rv = server_info_->WaitForDataReady( |
| 397 base::Bind(&QuicStreamFactory::Job::OnIOComplete, | 441 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); |
| 398 weak_factory_.GetWeakPtr())); | 442 if (rv == ERR_IO_PENDING && factory_->enable_connection_racing()) { |
| 443 // If we are waiting to load server config from the disk cache, then start | |
| 444 // another job. | |
| 445 factory_->CreateAuxilaryJob(server_id_, method_, net_log_); | |
| 446 } | |
| 447 return rv; | |
| 399 } | 448 } |
| 400 | 449 |
| 401 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) { | 450 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) { |
| 402 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 451 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 403 tracked_objects::ScopedTracker tracking_profile( | 452 tracked_objects::ScopedTracker tracking_profile( |
| 404 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 453 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 405 "422516 QuicStreamFactory::Job::DoLoadServerInfoComplete")); | 454 "422516 QuicStreamFactory::Job::DoLoadServerInfoComplete")); |
| 406 | 455 |
| 407 if (server_info_) { | 456 if (server_info_) { |
| 408 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime", | 457 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime", |
| 409 base::TimeTicks::Now() - disk_cache_load_start_time_); | 458 base::TimeTicks::Now() - disk_cache_load_start_time_); |
| 410 } | 459 } |
| 411 | 460 |
| 412 if (rv != OK) { | 461 if (rv != OK) |
| 413 server_info_.reset(); | 462 server_info_.reset(); |
| 414 } | |
| 415 | 463 |
| 416 io_state_ = STATE_CONNECT; | 464 io_state_ = STATE_CONNECT; |
| 417 return OK; | 465 return OK; |
| 418 } | 466 } |
| 419 | 467 |
| 420 int QuicStreamFactory::Job::DoConnect() { | 468 int QuicStreamFactory::Job::DoConnect() { |
| 421 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 469 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 422 tracked_objects::ScopedTracker tracking_profile( | 470 tracked_objects::ScopedTracker tracking_profile( |
| 423 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 471 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 424 "422516 QuicStreamFactory::Job::DoConnect")); | 472 "422516 QuicStreamFactory::Job::DoConnect")); |
| 425 | 473 |
| 426 io_state_ = STATE_CONNECT_COMPLETE; | 474 io_state_ = STATE_CONNECT_COMPLETE; |
| 427 | 475 |
| 476 if (started_another_job_ && | |
| 477 ((server_info_ && server_info_->state().server_config.empty()) || | |
| 478 !factory_->CryptoConfigCacheIsEmpty(server_id_))) { | |
|
Ryan Hamilton
2015/02/05 20:30:28
Instead of tracking this here, would it make more
ramant (doing other things)
2015/02/06 00:59:41
Done.
| |
| 479 // If we have started another job and if we didn't load the server config | |
| 480 // from the disk cache or if we have received a new server config from the | |
| 481 // server, then cancel the current job. | |
| 482 CancelJob(); | |
|
Ryan Hamilton
2015/02/05 20:30:28
Instead of invoking CancelJob() can we simply retu
ramant (doing other things)
2015/02/06 00:59:41
Done.
| |
| 483 return ERR_CONNECTION_CLOSED; | |
| 484 } | |
| 485 | |
| 428 int rv = factory_->CreateSession(server_id_, server_info_.Pass(), | 486 int rv = factory_->CreateSession(server_id_, server_info_.Pass(), |
| 429 address_list_, net_log_, &session_); | 487 address_list_, net_log_, &session_); |
| 430 if (rv != OK) { | 488 if (rv != OK) { |
| 431 DCHECK(rv != ERR_IO_PENDING); | 489 DCHECK(rv != ERR_IO_PENDING); |
| 432 DCHECK(!session_); | 490 DCHECK(!session_); |
| 433 return rv; | 491 return rv; |
| 434 } | 492 } |
| 435 | 493 |
| 436 if (!session_->connection()->connected()) { | 494 if (!session_->connection()->connected()) { |
| 437 return ERR_CONNECTION_CLOSED; | 495 return ERR_CONNECTION_CLOSED; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 config_(InitializeQuicConfig(connection_options)), | 639 config_(InitializeQuicConfig(connection_options)), |
| 582 supported_versions_(supported_versions), | 640 supported_versions_(supported_versions), |
| 583 enable_port_selection_(enable_port_selection), | 641 enable_port_selection_(enable_port_selection), |
| 584 always_require_handshake_confirmation_( | 642 always_require_handshake_confirmation_( |
| 585 always_require_handshake_confirmation), | 643 always_require_handshake_confirmation), |
| 586 disable_connection_pooling_(disable_connection_pooling), | 644 disable_connection_pooling_(disable_connection_pooling), |
| 587 load_server_info_timeout_ms_(load_server_info_timeout), | 645 load_server_info_timeout_ms_(load_server_info_timeout), |
| 588 load_server_info_timeout_srtt_multiplier_( | 646 load_server_info_timeout_srtt_multiplier_( |
| 589 load_server_info_timeout_srtt_multiplier), | 647 load_server_info_timeout_srtt_multiplier), |
| 590 enable_truncated_connection_ids_(enable_truncated_connection_ids), | 648 enable_truncated_connection_ids_(enable_truncated_connection_ids), |
| 649 enable_connection_racing_(false), | |
| 591 port_seed_(random_generator_->RandUint64()), | 650 port_seed_(random_generator_->RandUint64()), |
| 592 check_persisted_supports_quic_(true), | 651 check_persisted_supports_quic_(true), |
| 593 task_runner_(nullptr), | 652 task_runner_(nullptr), |
| 594 weak_factory_(this) { | 653 weak_factory_(this) { |
| 595 DCHECK(transport_security_state_); | 654 DCHECK(transport_security_state_); |
| 596 crypto_config_.set_user_agent_id(user_agent_id); | 655 crypto_config_.set_user_agent_id(user_agent_id); |
| 597 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 656 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| 598 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 657 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 599 crypto_config_.SetProofVerifier( | 658 crypto_config_.SetProofVerifier( |
| 600 new ProofVerifierChromium(cert_verifier, transport_security_state)); | 659 new ProofVerifierChromium(cert_verifier, transport_security_state)); |
| 601 crypto_config_.SetChannelIDSource( | 660 crypto_config_.SetChannelIDSource( |
| 602 new ChannelIDSourceChromium(channel_id_service)); | 661 new ChannelIDSourceChromium(channel_id_service)); |
| 603 base::CPU cpu; | 662 base::CPU cpu; |
| 604 if (cpu.has_aesni() && cpu.has_avx()) | 663 if (cpu.has_aesni() && cpu.has_avx()) |
| 605 crypto_config_.PreferAesGcm(); | 664 crypto_config_.PreferAesGcm(); |
| 606 if (!IsEcdsaSupported()) | 665 if (!IsEcdsaSupported()) |
| 607 crypto_config_.DisableEcdsa(); | 666 crypto_config_.DisableEcdsa(); |
| 608 } | 667 } |
| 609 | 668 |
| 610 QuicStreamFactory::~QuicStreamFactory() { | 669 QuicStreamFactory::~QuicStreamFactory() { |
| 611 CloseAllSessions(ERR_ABORTED); | 670 CloseAllSessions(ERR_ABORTED); |
| 612 while (!all_sessions_.empty()) { | 671 while (!all_sessions_.empty()) { |
| 613 delete all_sessions_.begin()->first; | 672 delete all_sessions_.begin()->first; |
| 614 all_sessions_.erase(all_sessions_.begin()); | 673 all_sessions_.erase(all_sessions_.begin()); |
| 615 } | 674 } |
| 616 STLDeleteValues(&active_jobs_); | 675 while (!active_jobs_.empty()) { |
| 676 const QuicServerId server_id = active_jobs_.begin()->first; | |
| 677 STLDeleteElements(&(active_jobs_[server_id])); | |
| 678 active_jobs_.erase(server_id); | |
| 679 } | |
| 617 } | 680 } |
| 618 | 681 |
| 619 void QuicStreamFactory::set_require_confirmation(bool require_confirmation) { | 682 void QuicStreamFactory::set_require_confirmation(bool require_confirmation) { |
| 620 require_confirmation_ = require_confirmation; | 683 require_confirmation_ = require_confirmation; |
| 621 if (http_server_properties_ && (!(local_address_ == IPEndPoint()))) { | 684 if (http_server_properties_ && (!(local_address_ == IPEndPoint()))) { |
| 622 // TODO(rtenneti): Delete host_port_pair and persist data in globals. | 685 // TODO(rtenneti): Delete host_port_pair and persist data in globals. |
| 623 HostPortPair host_port_pair(kDummyHostname, kDummyPort); | 686 HostPortPair host_port_pair(kDummyHostname, kDummyPort); |
| 624 http_server_properties_->SetSupportsQuic( | 687 http_server_properties_->SetSupportsQuic( |
| 625 host_port_pair, !require_confirmation, | 688 host_port_pair, !require_confirmation, |
| 626 local_address_.ToStringWithoutPort()); | 689 local_address_.ToStringWithoutPort()); |
| 627 } | 690 } |
| 628 } | 691 } |
| 629 | 692 |
| 630 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, | 693 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, |
| 631 bool is_https, | 694 bool is_https, |
| 632 PrivacyMode privacy_mode, | 695 PrivacyMode privacy_mode, |
| 633 base::StringPiece method, | 696 base::StringPiece method, |
| 634 const BoundNetLog& net_log, | 697 const BoundNetLog& net_log, |
| 635 QuicStreamRequest* request) { | 698 QuicStreamRequest* request) { |
| 636 QuicServerId server_id(host_port_pair, is_https, privacy_mode); | 699 QuicServerId server_id(host_port_pair, is_https, privacy_mode); |
| 637 if (HasActiveSession(server_id)) { | 700 if (HasActiveSession(server_id)) { |
| 638 request->set_stream(CreateIfSessionExists(server_id, net_log)); | 701 request->set_stream(CreateIfSessionExists(server_id, net_log)); |
| 639 return OK; | 702 return OK; |
| 640 } | 703 } |
| 641 | 704 |
| 642 if (HasActiveJob(server_id)) { | 705 if (HasActiveJob(server_id)) { |
| 643 Job* job = active_jobs_[server_id]; | 706 active_requests_[request] = server_id; |
| 644 active_requests_[request] = job; | 707 job_requests_map_[server_id].insert(request); |
| 645 job_requests_map_[job].insert(request); | |
| 646 return ERR_IO_PENDING; | 708 return ERR_IO_PENDING; |
| 647 } | 709 } |
| 648 | 710 |
| 711 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ | |
| 712 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. | |
| 713 if (!task_runner_) | |
| 714 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); | |
| 715 | |
| 649 QuicServerInfo* quic_server_info = nullptr; | 716 QuicServerInfo* quic_server_info = nullptr; |
| 650 if (quic_server_info_factory_) { | 717 if (quic_server_info_factory_) { |
| 651 bool load_from_disk_cache = true; | 718 bool load_from_disk_cache = true; |
| 652 if (http_server_properties_) { | 719 if (http_server_properties_) { |
| 653 const AlternateProtocolMap& alternate_protocol_map = | 720 const AlternateProtocolMap& alternate_protocol_map = |
| 654 http_server_properties_->alternate_protocol_map(); | 721 http_server_properties_->alternate_protocol_map(); |
| 655 AlternateProtocolMap::const_iterator it = | 722 AlternateProtocolMap::const_iterator it = |
| 656 alternate_protocol_map.Peek(server_id.host_port_pair()); | 723 alternate_protocol_map.Peek(server_id.host_port_pair()); |
| 657 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) { | 724 if (it == alternate_protocol_map.end() || it->second.protocol != QUIC) { |
| 658 // If there is no entry for QUIC, consider that as a new server and | 725 // If there is no entry for QUIC, consider that as a new server and |
| 659 // don't wait for Cache thread to load the data for that server. | 726 // don't wait for Cache thread to load the data for that server. |
| 660 load_from_disk_cache = false; | 727 load_from_disk_cache = false; |
| 661 } | 728 } |
| 662 } | 729 } |
| 663 if (load_from_disk_cache) { | 730 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) { |
| 664 QuicCryptoClientConfig::CachedState* cached = | 731 quic_server_info = quic_server_info_factory_->GetForServer(server_id); |
| 665 crypto_config_.LookupOrCreate(server_id); | |
| 666 DCHECK(cached); | |
| 667 if (cached->IsEmpty()) { | |
| 668 quic_server_info = quic_server_info_factory_->GetForServer(server_id); | |
| 669 } | |
| 670 } | 732 } |
| 671 } | 733 } |
| 672 // TODO(rtenneti): Initialize task_runner_ in the constructor after | |
| 673 // WebRequestActionWithThreadsTest.* tests are fixed. | |
| 674 if (!task_runner_) | |
| 675 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); | |
| 676 | 734 |
| 677 bool was_alternate_protocol_recently_broken = | |
| 678 http_server_properties_ && | |
| 679 http_server_properties_->WasAlternateProtocolRecentlyBroken( | |
| 680 server_id.host_port_pair()); | |
| 681 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https, | 735 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https, |
| 682 was_alternate_protocol_recently_broken, | 736 WasAlternateProtocolRecentlyBroken(server_id), |
| 683 privacy_mode, method, quic_server_info, net_log)); | 737 privacy_mode, method, quic_server_info, net_log)); |
| 684 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 738 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
| 685 base::Unretained(this), job.get())); | 739 base::Unretained(this), job.get())); |
| 686 | 740 DCHECK(!job->is_cancelled()); |
| 687 if (rv == ERR_IO_PENDING) { | 741 if (rv == ERR_IO_PENDING) { |
| 688 active_requests_[request] = job.get(); | 742 active_requests_[request] = server_id; |
| 689 job_requests_map_[job.get()].insert(request); | 743 job_requests_map_[server_id].insert(request); |
| 690 active_jobs_[server_id] = job.release(); | 744 active_jobs_[server_id].insert(job.release()); |
| 745 return rv; | |
| 691 } | 746 } |
| 692 if (rv == OK) { | 747 if (rv == OK) { |
| 693 DCHECK(HasActiveSession(server_id)); | 748 DCHECK(HasActiveSession(server_id)); |
| 694 request->set_stream(CreateIfSessionExists(server_id, net_log)); | 749 request->set_stream(CreateIfSessionExists(server_id, net_log)); |
| 695 } | 750 } |
| 696 return rv; | 751 return rv; |
| 697 } | 752 } |
| 698 | 753 |
| 754 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id, | |
| 755 base::StringPiece method, | |
| 756 const BoundNetLog& net_log) { | |
| 757 Job* aux_job = new Job(this, host_resolver_, server_id.host_port_pair(), | |
| 758 server_id.is_https(), | |
| 759 WasAlternateProtocolRecentlyBroken(server_id), | |
| 760 server_id.privacy_mode(), method, nullptr, net_log); | |
| 761 active_jobs_[server_id].insert(aux_job); | |
| 762 task_runner_->PostTask(FROM_HERE, | |
| 763 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob, | |
| 764 aux_job->GetWeakPtr())); | |
| 765 } | |
| 766 | |
| 699 bool QuicStreamFactory::OnResolution( | 767 bool QuicStreamFactory::OnResolution( |
| 700 const QuicServerId& server_id, | 768 const QuicServerId& server_id, |
| 701 const AddressList& address_list) { | 769 const AddressList& address_list) { |
| 702 DCHECK(!HasActiveSession(server_id)); | 770 DCHECK(!HasActiveSession(server_id)); |
| 703 if (disable_connection_pooling_) { | 771 if (disable_connection_pooling_) { |
| 704 return false; | 772 return false; |
| 705 } | 773 } |
| 706 for (const IPEndPoint& address : address_list) { | 774 for (const IPEndPoint& address : address_list) { |
| 707 const IpAliasKey ip_alias_key(address, server_id.is_https()); | 775 const IpAliasKey ip_alias_key(address, server_id.is_https()); |
| 708 if (!ContainsKey(ip_aliases_, ip_alias_key)) | 776 if (!ContainsKey(ip_aliases_, ip_alias_key)) |
| 709 continue; | 777 continue; |
| 710 | 778 |
| 711 const SessionSet& sessions = ip_aliases_[ip_alias_key]; | 779 const SessionSet& sessions = ip_aliases_[ip_alias_key]; |
| 712 for (QuicClientSession* session : sessions) { | 780 for (QuicClientSession* session : sessions) { |
| 713 if (!session->CanPool(server_id.host(), server_id.privacy_mode())) | 781 if (!session->CanPool(server_id.host(), server_id.privacy_mode())) |
| 714 continue; | 782 continue; |
| 715 active_sessions_[server_id] = session; | 783 active_sessions_[server_id] = session; |
| 716 session_aliases_[session].insert(server_id); | 784 session_aliases_[session].insert(server_id); |
| 717 return true; | 785 return true; |
| 718 } | 786 } |
| 719 } | 787 } |
| 720 return false; | 788 return false; |
| 721 } | 789 } |
| 722 | 790 |
| 723 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { | 791 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { |
| 792 QuicServerId server_id = job->server_id(); | |
| 793 if (job->is_cancelled()) { | |
| 794 // Verify there is atleast one other job to handle the requests. | |
| 795 DCHECK_LT(1u, active_jobs_[server_id].size()); | |
| 796 return; | |
|
Ryan Hamilton
2015/02/05 20:30:28
Do we need to move this job from active_jobs_?
ramant (doing other things)
2015/02/06 00:59:42
Done.
| |
| 797 } | |
| 724 if (rv == OK) { | 798 if (rv == OK) { |
| 725 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 799 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 726 tracked_objects::ScopedTracker tracking_profile1( | 800 tracked_objects::ScopedTracker tracking_profile1( |
| 727 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 801 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 728 "422516 QuicStreamFactory::OnJobComplete1")); | 802 "422516 QuicStreamFactory::OnJobComplete1")); |
| 729 | 803 |
| 730 if (!always_require_handshake_confirmation_) | 804 if (!always_require_handshake_confirmation_) |
| 731 set_require_confirmation(false); | 805 set_require_confirmation(false); |
| 732 | 806 |
| 733 // Create all the streams, but do not notify them yet. | 807 // Create all the streams, but do not notify them yet. |
| 734 for (RequestSet::iterator it = job_requests_map_[job].begin(); | 808 for (RequestSet::iterator it = job_requests_map_[server_id].begin(); |
| 735 it != job_requests_map_[job].end() ; ++it) { | 809 it != job_requests_map_[server_id].end(); ++it) { |
| 736 DCHECK(HasActiveSession(job->server_id())); | 810 DCHECK(HasActiveSession(server_id)); |
| 737 (*it)->set_stream(CreateIfSessionExists(job->server_id(), | 811 (*it)->set_stream(CreateIfSessionExists(server_id, (*it)->net_log())); |
| 738 (*it)->net_log())); | |
| 739 } | 812 } |
| 740 } | 813 } |
| 741 | 814 |
| 742 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 815 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 743 tracked_objects::ScopedTracker tracking_profile2( | 816 tracked_objects::ScopedTracker tracking_profile2( |
| 744 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 817 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 745 "422516 QuicStreamFactory::OnJobComplete2")); | 818 "422516 QuicStreamFactory::OnJobComplete2")); |
| 746 | 819 |
| 747 while (!job_requests_map_[job].empty()) { | 820 while (!job_requests_map_[server_id].empty()) { |
| 748 RequestSet::iterator it = job_requests_map_[job].begin(); | 821 RequestSet::iterator it = job_requests_map_[server_id].begin(); |
| 749 QuicStreamRequest* request = *it; | 822 QuicStreamRequest* request = *it; |
| 750 job_requests_map_[job].erase(it); | 823 job_requests_map_[server_id].erase(it); |
| 751 active_requests_.erase(request); | 824 active_requests_.erase(request); |
| 752 // Even though we're invoking callbacks here, we don't need to worry | 825 // Even though we're invoking callbacks here, we don't need to worry |
| 753 // about |this| being deleted, because the factory is owned by the | 826 // about |this| being deleted, because the factory is owned by the |
| 754 // profile which can not be deleted via callbacks. | 827 // profile which can not be deleted via callbacks. |
| 755 request->OnRequestComplete(rv); | 828 request->OnRequestComplete(rv); |
| 756 } | 829 } |
| 757 | 830 |
| 758 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 831 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 759 tracked_objects::ScopedTracker tracking_profile3( | 832 tracked_objects::ScopedTracker tracking_profile3( |
| 760 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 833 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 761 "422516 QuicStreamFactory::OnJobComplete3")); | 834 "422516 QuicStreamFactory::OnJobComplete3")); |
| 762 | 835 |
| 763 active_jobs_.erase(job->server_id()); | 836 for (Job* other_job : active_jobs_[server_id]) { |
| 764 job_requests_map_.erase(job); | 837 if (other_job == job || other_job->is_cancelled()) |
| 765 delete job; | 838 continue; |
| 766 return; | 839 other_job->CancelJob(); |
| 840 } | |
| 841 | |
| 842 STLDeleteElements(&(active_jobs_[server_id])); | |
| 843 active_jobs_.erase(server_id); | |
| 844 job_requests_map_.erase(server_id); | |
| 767 } | 845 } |
| 768 | 846 |
| 769 // Returns a newly created QuicHttpStream owned by the caller, if a | 847 // Returns a newly created QuicHttpStream owned by the caller, if a |
| 770 // matching session already exists. Returns nullptr otherwise. | 848 // matching session already exists. Returns nullptr otherwise. |
| 771 scoped_ptr<QuicHttpStream> QuicStreamFactory::CreateIfSessionExists( | 849 scoped_ptr<QuicHttpStream> QuicStreamFactory::CreateIfSessionExists( |
| 772 const QuicServerId& server_id, | 850 const QuicServerId& server_id, |
| 773 const BoundNetLog& net_log) { | 851 const BoundNetLog& net_log) { |
| 774 if (!HasActiveSession(server_id)) { | 852 if (!HasActiveSession(server_id)) { |
| 775 DVLOG(1) << "No active session"; | 853 DVLOG(1) << "No active session"; |
| 776 return scoped_ptr<QuicHttpStream>(); | 854 return scoped_ptr<QuicHttpStream>(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 | 913 |
| 836 const IpAliasKey ip_alias_key(session->connection()->peer_address(), | 914 const IpAliasKey ip_alias_key(session->connection()->peer_address(), |
| 837 aliases.begin()->is_https()); | 915 aliases.begin()->is_https()); |
| 838 ip_aliases_[ip_alias_key].erase(session); | 916 ip_aliases_[ip_alias_key].erase(session); |
| 839 if (ip_aliases_[ip_alias_key].empty()) { | 917 if (ip_aliases_[ip_alias_key].empty()) { |
| 840 ip_aliases_.erase(ip_alias_key); | 918 ip_aliases_.erase(ip_alias_key); |
| 841 } | 919 } |
| 842 QuicServerId server_id = *aliases.begin(); | 920 QuicServerId server_id = *aliases.begin(); |
| 843 session_aliases_.erase(session); | 921 session_aliases_.erase(session); |
| 844 Job* job = new Job(this, host_resolver_, session, server_id); | 922 Job* job = new Job(this, host_resolver_, session, server_id); |
| 845 active_jobs_[server_id] = job; | 923 active_jobs_[server_id].insert(job); |
| 846 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 924 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
| 847 base::Unretained(this), job)); | 925 base::Unretained(this), job)); |
| 848 DCHECK_EQ(ERR_IO_PENDING, rv); | 926 DCHECK_EQ(ERR_IO_PENDING, rv); |
| 849 } | 927 } |
| 850 | 928 |
| 851 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { | 929 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { |
| 852 DCHECK(ContainsKey(active_requests_, request)); | 930 DCHECK(ContainsKey(active_requests_, request)); |
| 853 Job* job = active_requests_[request]; | 931 QuicServerId server_id = active_requests_[request]; |
| 854 job_requests_map_[job].erase(request); | 932 job_requests_map_[server_id].erase(request); |
| 855 active_requests_.erase(request); | 933 active_requests_.erase(request); |
| 856 } | 934 } |
| 857 | 935 |
| 858 void QuicStreamFactory::CloseAllSessions(int error) { | 936 void QuicStreamFactory::CloseAllSessions(int error) { |
| 859 while (!active_sessions_.empty()) { | 937 while (!active_sessions_.empty()) { |
| 860 size_t initial_size = active_sessions_.size(); | 938 size_t initial_size = active_sessions_.size(); |
| 861 active_sessions_.begin()->second->CloseSessionOnError(error); | 939 active_sessions_.begin()->second->CloseSessionOnError(error); |
| 862 DCHECK_NE(initial_size, active_sessions_.size()); | 940 DCHECK_NE(initial_size, active_sessions_.size()); |
| 863 } | 941 } |
| 864 while (!all_sessions_.empty()) { | 942 while (!all_sessions_.empty()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 // kind of change it is, we have to flush the socket | 992 // kind of change it is, we have to flush the socket |
| 915 // pools to be safe. | 993 // pools to be safe. |
| 916 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); | 994 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); |
| 917 } | 995 } |
| 918 | 996 |
| 919 bool QuicStreamFactory::HasActiveSession( | 997 bool QuicStreamFactory::HasActiveSession( |
| 920 const QuicServerId& server_id) const { | 998 const QuicServerId& server_id) const { |
| 921 return ContainsKey(active_sessions_, server_id); | 999 return ContainsKey(active_sessions_, server_id); |
| 922 } | 1000 } |
| 923 | 1001 |
| 1002 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { | |
| 1003 return ContainsKey(active_jobs_, key); | |
| 1004 } | |
| 1005 | |
| 924 int QuicStreamFactory::CreateSession( | 1006 int QuicStreamFactory::CreateSession( |
| 925 const QuicServerId& server_id, | 1007 const QuicServerId& server_id, |
| 926 scoped_ptr<QuicServerInfo> server_info, | 1008 scoped_ptr<QuicServerInfo> server_info, |
| 927 const AddressList& address_list, | 1009 const AddressList& address_list, |
| 928 const BoundNetLog& net_log, | 1010 const BoundNetLog& net_log, |
| 929 QuicClientSession** session) { | 1011 QuicClientSession** session) { |
| 930 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1012 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 931 tracked_objects::ScopedTracker tracking_profile1( | 1013 tracked_objects::ScopedTracker tracking_profile1( |
| 932 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1014 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 933 "422516 QuicStreamFactory::CreateSession1")); | 1015 "422516 QuicStreamFactory::CreateSession1")); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession", | 1212 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession", |
| 1131 closed_during_initialize); | 1213 closed_during_initialize); |
| 1132 if (closed_during_initialize) { | 1214 if (closed_during_initialize) { |
| 1133 DLOG(DFATAL) << "Session closed during initialize"; | 1215 DLOG(DFATAL) << "Session closed during initialize"; |
| 1134 *session = nullptr; | 1216 *session = nullptr; |
| 1135 return ERR_CONNECTION_CLOSED; | 1217 return ERR_CONNECTION_CLOSED; |
| 1136 } | 1218 } |
| 1137 return OK; | 1219 return OK; |
| 1138 } | 1220 } |
| 1139 | 1221 |
| 1140 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { | |
| 1141 return ContainsKey(active_jobs_, key); | |
| 1142 } | |
| 1143 | |
| 1144 void QuicStreamFactory::ActivateSession( | 1222 void QuicStreamFactory::ActivateSession( |
| 1145 const QuicServerId& server_id, | 1223 const QuicServerId& server_id, |
| 1146 QuicClientSession* session) { | 1224 QuicClientSession* session) { |
| 1147 DCHECK(!HasActiveSession(server_id)); | 1225 DCHECK(!HasActiveSession(server_id)); |
| 1148 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); | 1226 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); |
| 1149 active_sessions_[server_id] = session; | 1227 active_sessions_[server_id] = session; |
| 1150 session_aliases_[session].insert(server_id); | 1228 session_aliases_[session].insert(server_id); |
| 1151 const IpAliasKey ip_alias_key(session->connection()->peer_address(), | 1229 const IpAliasKey ip_alias_key(session->connection()->peer_address(), |
| 1152 server_id.is_https()); | 1230 server_id.is_https()); |
| 1153 DCHECK(!ContainsKey(ip_aliases_[ip_alias_key], session)); | 1231 DCHECK(!ContainsKey(ip_aliases_[ip_alias_key], session)); |
| 1154 ip_aliases_[ip_alias_key].insert(session); | 1232 ip_aliases_[ip_alias_key].insert(session); |
| 1155 } | 1233 } |
| 1156 | 1234 |
| 1157 int64 QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( | 1235 int64 QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( |
| 1158 const QuicServerId& server_id) const { | 1236 const QuicServerId& server_id) const { |
| 1159 if (!http_server_properties_) | 1237 if (!http_server_properties_) |
| 1160 return 0; | 1238 return 0; |
| 1161 const ServerNetworkStats* stats = | 1239 const ServerNetworkStats* stats = |
| 1162 http_server_properties_->GetServerNetworkStats( | 1240 http_server_properties_->GetServerNetworkStats( |
| 1163 server_id.host_port_pair()); | 1241 server_id.host_port_pair()); |
| 1164 if (stats == nullptr) | 1242 if (stats == nullptr) |
| 1165 return 0; | 1243 return 0; |
| 1166 return stats->srtt.InMicroseconds(); | 1244 return stats->srtt.InMicroseconds(); |
| 1167 } | 1245 } |
| 1168 | 1246 |
| 1247 bool QuicStreamFactory::WasAlternateProtocolRecentlyBroken( | |
| 1248 const QuicServerId& server_id) const { | |
| 1249 return http_server_properties_ && | |
| 1250 http_server_properties_->WasAlternateProtocolRecentlyBroken( | |
| 1251 server_id.host_port_pair()); | |
| 1252 } | |
| 1253 | |
| 1254 bool QuicStreamFactory::CryptoConfigCacheIsEmpty( | |
| 1255 const QuicServerId& server_id) { | |
| 1256 QuicCryptoClientConfig::CachedState* cached = | |
| 1257 crypto_config_.LookupOrCreate(server_id); | |
| 1258 return cached->IsEmpty(); | |
| 1259 } | |
| 1260 | |
| 1169 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( | 1261 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( |
| 1170 const QuicServerId& server_id, | 1262 const QuicServerId& server_id, |
| 1171 const scoped_ptr<QuicServerInfo>& server_info) { | 1263 const scoped_ptr<QuicServerInfo>& server_info) { |
| 1172 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1264 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1173 tracked_objects::ScopedTracker tracking_profile1( | 1265 tracked_objects::ScopedTracker tracking_profile1( |
| 1174 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1266 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1175 "422516 QuicStreamFactory::InitializeCachedStateInCryptoConfig1")); | 1267 "422516 QuicStreamFactory::InitializeCachedStateInCryptoConfig1")); |
| 1176 | 1268 |
| 1177 // |server_info| will be NULL, if a non-empty server config already exists in | 1269 // |server_info| will be NULL, if a non-empty server config already exists in |
| 1178 // the memory cache. This is a minor optimization to avoid LookupOrCreate. | 1270 // the memory cache. This is a minor optimization to avoid LookupOrCreate. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1272 http_server_properties_->ClearAlternateProtocol(server); | 1364 http_server_properties_->ClearAlternateProtocol(server); |
| 1273 http_server_properties_->SetAlternateProtocol( | 1365 http_server_properties_->SetAlternateProtocol( |
| 1274 server, alternate.port, alternate.protocol, 1); | 1366 server, alternate.port, alternate.protocol, 1); |
| 1275 DCHECK_EQ(QUIC, | 1367 DCHECK_EQ(QUIC, |
| 1276 http_server_properties_->GetAlternateProtocol(server).protocol); | 1368 http_server_properties_->GetAlternateProtocol(server).protocol); |
| 1277 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1369 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 1278 server)); | 1370 server)); |
| 1279 } | 1371 } |
| 1280 | 1372 |
| 1281 } // namespace net | 1373 } // namespace net |
| OLD | NEW |