OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_ |
6 #define NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_ | 6 #define NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <list> | 10 #include <list> |
9 #include <map> | 11 #include <map> |
10 #include <string> | 12 #include <string> |
11 | 13 |
12 #include "base/basictypes.h" | |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "net/tools/epoll_server/epoll_server.h" | 15 #include "net/tools/epoll_server/epoll_server.h" |
15 #include "net/tools/flip_server/constants.h" | 16 #include "net/tools/flip_server/constants.h" |
16 #include "net/tools/flip_server/mem_cache.h" | 17 #include "net/tools/flip_server/mem_cache.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 class SMConnectionInterface; | 21 class SMConnectionInterface; |
21 | 22 |
22 class OutputOrdering { | 23 class OutputOrdering { |
23 public: | 24 public: |
24 typedef std::list<MemCacheIter> PriorityRing; | 25 typedef std::list<MemCacheIter> PriorityRing; |
25 typedef std::map<uint32, PriorityRing> PriorityMap; | 26 typedef std::map<uint32_t, PriorityRing> PriorityMap; |
26 | 27 |
27 struct PriorityMapPointer { | 28 struct PriorityMapPointer { |
28 PriorityMapPointer(); | 29 PriorityMapPointer(); |
29 ~PriorityMapPointer(); | 30 ~PriorityMapPointer(); |
30 PriorityRing* ring; | 31 PriorityRing* ring; |
31 PriorityRing::iterator it; | 32 PriorityRing::iterator it; |
32 bool alarm_enabled; | 33 bool alarm_enabled; |
33 EpollServer::AlarmRegToken alarm_token; | 34 EpollServer::AlarmRegToken alarm_token; |
34 }; | 35 }; |
35 | 36 |
36 typedef std::map<uint32, PriorityMapPointer> StreamIdToPriorityMap; | 37 typedef std::map<uint32_t, PriorityMapPointer> StreamIdToPriorityMap; |
37 | 38 |
38 StreamIdToPriorityMap stream_ids_; | 39 StreamIdToPriorityMap stream_ids_; |
39 PriorityMap priority_map_; | 40 PriorityMap priority_map_; |
40 PriorityRing first_data_senders_; | 41 PriorityRing first_data_senders_; |
41 uint32 first_data_senders_threshold_; // when you've passed this, you're no | 42 uint32_t first_data_senders_threshold_; // when you've passed this, you're no |
42 // longer a first_data_sender... | 43 // longer a first_data_sender... |
43 SMConnectionInterface* connection_; | 44 SMConnectionInterface* connection_; |
44 EpollServer* epoll_server_; | 45 EpollServer* epoll_server_; |
45 | 46 |
46 explicit OutputOrdering(SMConnectionInterface* connection); | 47 explicit OutputOrdering(SMConnectionInterface* connection); |
47 ~OutputOrdering(); | 48 ~OutputOrdering(); |
48 void Reset(); | 49 void Reset(); |
49 bool ExistsInPriorityMaps(uint32 stream_id) const; | 50 bool ExistsInPriorityMaps(uint32_t stream_id) const; |
50 | 51 |
51 struct BeginOutputtingAlarm : public EpollAlarmCallbackInterface { | 52 struct BeginOutputtingAlarm : public EpollAlarmCallbackInterface { |
52 public: | 53 public: |
53 BeginOutputtingAlarm(OutputOrdering* oo, | 54 BeginOutputtingAlarm(OutputOrdering* oo, |
54 OutputOrdering::PriorityMapPointer* pmp, | 55 OutputOrdering::PriorityMapPointer* pmp, |
55 const MemCacheIter& mci); | 56 const MemCacheIter& mci); |
56 ~BeginOutputtingAlarm() override; | 57 ~BeginOutputtingAlarm() override; |
57 | 58 |
58 // EpollAlarmCallbackInterface: | 59 // EpollAlarmCallbackInterface: |
59 int64 OnAlarm() override; | 60 int64_t OnAlarm() override; |
60 void OnRegistration(const EpollServer::AlarmRegToken& tok, | 61 void OnRegistration(const EpollServer::AlarmRegToken& tok, |
61 EpollServer* eps) override; | 62 EpollServer* eps) override; |
62 void OnUnregistration() override; | 63 void OnUnregistration() override; |
63 void OnShutdown(EpollServer* eps) override; | 64 void OnShutdown(EpollServer* eps) override; |
64 | 65 |
65 private: | 66 private: |
66 OutputOrdering* output_ordering_; | 67 OutputOrdering* output_ordering_; |
67 OutputOrdering::PriorityMapPointer* pmp_; | 68 OutputOrdering::PriorityMapPointer* pmp_; |
68 MemCacheIter mci_; | 69 MemCacheIter mci_; |
69 EpollServer* epoll_server_; | 70 EpollServer* epoll_server_; |
70 }; | 71 }; |
71 | 72 |
72 void MoveToActive(PriorityMapPointer* pmp, MemCacheIter mci); | 73 void MoveToActive(PriorityMapPointer* pmp, MemCacheIter mci); |
73 void AddToOutputOrder(const MemCacheIter& mci); | 74 void AddToOutputOrder(const MemCacheIter& mci); |
74 void SpliceToPriorityRing(PriorityRing::iterator pri); | 75 void SpliceToPriorityRing(PriorityRing::iterator pri); |
75 MemCacheIter* GetIter(); | 76 MemCacheIter* GetIter(); |
76 void RemoveStreamId(uint32 stream_id); | 77 void RemoveStreamId(uint32_t stream_id); |
77 | 78 |
78 static double server_think_time_in_s() { return server_think_time_in_s_; } | 79 static double server_think_time_in_s() { return server_think_time_in_s_; } |
79 static void set_server_think_time_in_s(double value) { | 80 static void set_server_think_time_in_s(double value) { |
80 server_think_time_in_s_ = value; | 81 server_think_time_in_s_ = value; |
81 } | 82 } |
82 | 83 |
83 private: | 84 private: |
84 static double server_think_time_in_s_; | 85 static double server_think_time_in_s_; |
85 }; | 86 }; |
86 | 87 |
87 } // namespace net | 88 } // namespace net |
88 | 89 |
89 #endif // NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_ | 90 #endif // NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_ |
OLD | NEW |