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

Side by Side Diff: net/websockets/websocket_job_spdy2_unittest.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 months 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
« no previous file with comments | « net/udp/udp_socket_win.cc ('k') | net/websockets/websocket_job_spdy3_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/websockets/websocket_job.h" 5 #include "net/websockets/websocket_job.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
18 #include "net/base/mock_host_resolver.h" 18 #include "net/base/mock_host_resolver.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/base/ssl_config_service.h" 20 #include "net/base/ssl_config_service.h"
21 #include "net/base/sys_addrinfo.h"
22 #include "net/base/test_completion_callback.h" 21 #include "net/base/test_completion_callback.h"
23 #include "net/base/transport_security_state.h" 22 #include "net/base/transport_security_state.h"
24 #include "net/cookies/cookie_store.h" 23 #include "net/cookies/cookie_store.h"
25 #include "net/cookies/cookie_store_test_helpers.h" 24 #include "net/cookies/cookie_store_test_helpers.h"
26 #include "net/http/http_transaction_factory.h" 25 #include "net/http/http_transaction_factory.h"
27 #include "net/proxy/proxy_service.h" 26 #include "net/proxy/proxy_service.h"
28 #include "net/socket/socket_test_util.h" 27 #include "net/socket/socket_test_util.h"
29 #include "net/socket_stream/socket_stream.h" 28 #include "net/socket_stream/socket_stream.h"
30 #include "net/spdy/spdy_session.h" 29 #include "net/spdy/spdy_session.h"
31 #include "net/spdy/spdy_test_util_spdy2.h" 30 #include "net/spdy/spdy_test_util_spdy2.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 399
401 socket_ = new SocketStream(url, websocket_.get()); 400 socket_ = new SocketStream(url, websocket_.get());
402 socket_factory_.reset(new MockClientSocketFactory); 401 socket_factory_.reset(new MockClientSocketFactory);
403 DCHECK(data_.get()); 402 DCHECK(data_.get());
404 socket_factory_->AddSocketDataProvider(data_.get()); 403 socket_factory_->AddSocketDataProvider(data_.get());
405 socket_->SetClientSocketFactory(socket_factory_.get()); 404 socket_->SetClientSocketFactory(socket_factory_.get());
406 } 405 }
407 406
408 websocket_->InitSocketStream(socket_.get()); 407 websocket_->InitSocketStream(socket_.get());
409 websocket_->set_context(context_.get()); 408 websocket_->set_context(context_.get());
410 struct addrinfo addr; 409 IPAddressNumber ip;
411 memset(&addr, 0, sizeof(struct addrinfo)); 410 ParseIPLiteralToNumber("127.0.0.1", &ip);
412 addr.ai_family = AF_INET; 411 websocket_->addresses_ = AddressList::CreateFromIPAddress(ip, 0);
413 addr.ai_addrlen = sizeof(struct sockaddr_in);
414 struct sockaddr_in sa_in;
415 memset(&sa_in, 0, sizeof(struct sockaddr_in));
416 memcpy(&sa_in.sin_addr, "\x7f\0\0\1", 4);
417 addr.ai_addr = reinterpret_cast<sockaddr*>(&sa_in);
418 addr.ai_next = NULL;
419 websocket_->addresses_ = AddressList::CreateByCopying(&addr);
420 } 412 }
421 void SkipToConnecting() { 413 void SkipToConnecting() {
422 websocket_->state_ = WebSocketJob::CONNECTING; 414 websocket_->state_ = WebSocketJob::CONNECTING;
423 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); 415 WebSocketThrottle::GetInstance()->PutInQueue(websocket_);
424 } 416 }
425 WebSocketJob::State GetWebSocketJobState() { 417 WebSocketJob::State GetWebSocketJobState() {
426 return websocket_->state_; 418 return websocket_->state_;
427 } 419 }
428 void CloseWebSocketJob() { 420 void CloseWebSocketJob() {
429 if (websocket_->socket_) { 421 if (websocket_->socket_) {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1102
1111 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { 1103 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) {
1112 WebSocketJob::set_websocket_over_spdy_enabled(true); 1104 WebSocketJob::set_websocket_over_spdy_enabled(true);
1113 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); 1105 TestConnectBySpdy(SPDY_ON, THROTTLING_ON);
1114 } 1106 }
1115 1107
1116 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. 1108 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation.
1117 // TODO(toyoshim,yutak): Add tests to verify closing handshake. 1109 // TODO(toyoshim,yutak): Add tests to verify closing handshake.
1118 1110
1119 } // namespace net 1111 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_win.cc ('k') | net/websockets/websocket_job_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698