| OLD | NEW |
| 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 "net/websockets/websocket_throttle.h" | 5 #include "net/websockets/websocket_throttle.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 WebSocketThrottle::WebSocketThrottle() { | 49 WebSocketThrottle::WebSocketThrottle() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 WebSocketThrottle::~WebSocketThrottle() { | 52 WebSocketThrottle::~WebSocketThrottle() { |
| 53 DCHECK(queue_.empty()); | 53 DCHECK(queue_.empty()); |
| 54 DCHECK(addr_map_.empty()); | 54 DCHECK(addr_map_.empty()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // static |
| 58 WebSocketThrottle* WebSocketThrottle::GetInstance() { |
| 59 return Singleton<WebSocketThrottle>::get(); |
| 60 } |
| 61 |
| 57 void WebSocketThrottle::PutInQueue(WebSocketJob* job) { | 62 void WebSocketThrottle::PutInQueue(WebSocketJob* job) { |
| 58 queue_.push_back(job); | 63 queue_.push_back(job); |
| 59 const AddressList& address_list = job->address_list(); | 64 const AddressList& address_list = job->address_list(); |
| 60 base::hash_set<std::string> address_set; | 65 base::hash_set<std::string> address_set; |
| 61 for (const struct addrinfo* addrinfo = address_list.head(); | 66 for (const struct addrinfo* addrinfo = address_list.head(); |
| 62 addrinfo != NULL; | 67 addrinfo != NULL; |
| 63 addrinfo = addrinfo->ai_next) { | 68 addrinfo = addrinfo->ai_next) { |
| 64 std::string addrkey = AddrinfoToHashkey(addrinfo); | 69 std::string addrkey = AddrinfoToHashkey(addrinfo); |
| 65 | 70 |
| 66 // If |addrkey| is already processed, don't do it again. | 71 // If |addrkey| is already processed, don't do it again. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 should_wakeup = false; | 151 should_wakeup = false; |
| 147 break; | 152 break; |
| 148 } | 153 } |
| 149 } | 154 } |
| 150 if (should_wakeup) | 155 if (should_wakeup) |
| 151 job->Wakeup(); | 156 job->Wakeup(); |
| 152 } | 157 } |
| 153 } | 158 } |
| 154 | 159 |
| 155 } // namespace net | 160 } // namespace net |
| OLD | NEW |