OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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" |
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1098 |
1099 void WebSocketJobTest::TestThrottlingLimit() { | 1099 void WebSocketJobTest::TestThrottlingLimit() { |
1100 std::vector<scoped_refptr<WebSocketJob> > jobs; | 1100 std::vector<scoped_refptr<WebSocketJob> > jobs; |
1101 const int kMaxWebSocketJobsThrottled = 1024; | 1101 const int kMaxWebSocketJobsThrottled = 1024; |
1102 IPAddressNumber ip; | 1102 IPAddressNumber ip; |
1103 ParseIPLiteralToNumber("127.0.0.1", &ip); | 1103 ParseIPLiteralToNumber("127.0.0.1", &ip); |
1104 for (int i = 0; i < kMaxWebSocketJobsThrottled + 1; ++i) { | 1104 for (int i = 0; i < kMaxWebSocketJobsThrottled + 1; ++i) { |
1105 scoped_refptr<WebSocketJob> job = new WebSocketJob(NULL); | 1105 scoped_refptr<WebSocketJob> job = new WebSocketJob(NULL); |
1106 job->addresses_ = AddressList(AddressList::CreateFromIPAddress(ip, 80)); | 1106 job->addresses_ = AddressList(AddressList::CreateFromIPAddress(ip, 80)); |
1107 if (i >= kMaxWebSocketJobsThrottled) | 1107 if (i >= kMaxWebSocketJobsThrottled) |
1108 EXPECT_FALSE(WebSocketThrottle::GetInstance()->PutInQueue(job)); | 1108 EXPECT_FALSE(WebSocketThrottle::GetInstance()->PutInQueue(job.get())); |
1109 else | 1109 else |
1110 EXPECT_TRUE(WebSocketThrottle::GetInstance()->PutInQueue(job)); | 1110 EXPECT_TRUE(WebSocketThrottle::GetInstance()->PutInQueue(job.get())); |
1111 jobs.push_back(job); | 1111 jobs.push_back(job); |
1112 } | 1112 } |
1113 | 1113 |
1114 // Close the jobs in reverse order. Otherwise, We need to make them prepared | 1114 // Close the jobs in reverse order. Otherwise, We need to make them prepared |
1115 // for Wakeup call. | 1115 // for Wakeup call. |
1116 for (std::vector<scoped_refptr<WebSocketJob> >::reverse_iterator iter = | 1116 for (std::vector<scoped_refptr<WebSocketJob> >::reverse_iterator iter = |
1117 jobs.rbegin(); | 1117 jobs.rbegin(); |
1118 iter != jobs.rend(); | 1118 iter != jobs.rend(); |
1119 ++iter) { | 1119 ++iter) { |
1120 WebSocketJob* job = (*iter).get(); | 1120 WebSocketJob* job = (*iter).get(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 job()->Connect(); | 1285 job()->Connect(); |
1286 SetDeleteNext(); | 1286 SetDeleteNext(); |
1287 job()->OnReceivedData( | 1287 job()->OnReceivedData( |
1288 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); | 1288 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); |
1289 EXPECT_FALSE(job()); | 1289 EXPECT_FALSE(job()); |
1290 } | 1290 } |
1291 | 1291 |
1292 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1292 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
1293 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1293 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
1294 } // namespace net | 1294 } // namespace net |
OLD | NEW |