| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/flip/flip_network_transaction.h" | 5 #include "net/flip/flip_network_transaction.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/field_trial.h" | 9 #include "base/field_trial.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 295 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
| 296 | 296 |
| 297 std::string host = request_->url.HostNoBrackets(); | 297 std::string host = request_->url.HostNoBrackets(); |
| 298 int port = request_->url.EffectiveIntPort(); | 298 int port = request_->url.EffectiveIntPort(); |
| 299 | 299 |
| 300 std::string connection_group = "flip."; | 300 std::string connection_group = "flip."; |
| 301 connection_group.append(host); | 301 connection_group.append(host); |
| 302 | 302 |
| 303 HostResolver::RequestInfo resolve_info(host, port); | 303 HostResolver::RequestInfo resolve_info(host, port); |
| 304 | 304 |
| 305 // TODO(mbelshe): Cleanup these testing tricks. | |
| 306 // If we want to use multiple connections, grab the flip session | |
| 307 // up front using the original domain name. | |
| 308 #undef USE_MULTIPLE_CONNECTIONS | |
| 309 #undef DIVERT_URLS_TO_TEST_SERVER | |
| 310 #if defined(USE_MULTIPLE_CONNECTIONS) || !defined(DIVERT_URLS_TO_TEST_SERVER) | |
| 311 flip_ = FlipSession::GetFlipSession(resolve_info, session_); | 305 flip_ = FlipSession::GetFlipSession(resolve_info, session_); |
| 312 #endif | 306 DCHECK(flip_); |
| 313 | |
| 314 // Use this to divert URLs to a test server. | |
| 315 #ifdef DIVERT_URLS_TO_TEST_SERVER | |
| 316 // Fake out this session to go to our test server. | |
| 317 host = "servername"; | |
| 318 port = 443; | |
| 319 resolve_info = HostResolver::RequestInfo(host, port); | |
| 320 #ifndef USE_MULTIPLE_CONNECTIONS | |
| 321 flip_ = FlipSession::GetFlipSession(resolve_info, session_); | |
| 322 #endif // USE_MULTIPLE_CONNECTIONS | |
| 323 | |
| 324 #endif // DIVERT_URLS_TO_TEST_SERVER | |
| 325 | 307 |
| 326 int rv = flip_->Connect(connection_group, resolve_info, request_->priority); | 308 int rv = flip_->Connect(connection_group, resolve_info, request_->priority); |
| 327 DCHECK(rv == net::OK); // The API says it will always return OK. | 309 DCHECK(rv == net::OK); // The API says it will always return OK. |
| 328 return net::OK; | 310 return net::OK; |
| 329 } | 311 } |
| 330 | 312 |
| 331 int FlipNetworkTransaction::DoInitConnectionComplete(int result) { | 313 int FlipNetworkTransaction::DoInitConnectionComplete(int result) { |
| 332 if (result < 0) | 314 if (result < 0) |
| 333 return result; | 315 return result; |
| 334 | 316 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 381 } |
| 400 | 382 |
| 401 int FlipNetworkTransaction::DoReadBodyComplete(int result) { | 383 int FlipNetworkTransaction::DoReadBodyComplete(int result) { |
| 402 // TODO(mbelshe): record success or failure of the transaction? | 384 // TODO(mbelshe): record success or failure of the transaction? |
| 403 if (user_callback_) | 385 if (user_callback_) |
| 404 DoHttpTransactionCallback(result); | 386 DoHttpTransactionCallback(result); |
| 405 return OK; | 387 return OK; |
| 406 } | 388 } |
| 407 | 389 |
| 408 } // namespace net | 390 } // namespace net |
| OLD | NEW |