Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / tools / flip_server / output_ordering.h
blob0558e3e4e8d57cb1e05bd3c5c601d86ccb314999
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
3 // found in the LICENSE file.
5 #ifndef NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_
6 #define NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_
8 #include <list>
9 #include <map>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "net/tools/flip_server/constants.h"
15 #include "net/tools/flip_server/epoll_server.h"
16 #include "net/tools/flip_server/mem_cache.h"
18 namespace net {
20 class SMConnectionInterface;
22 class OutputOrdering {
23 public:
24 typedef std::list<MemCacheIter> PriorityRing;
25 typedef std::map<uint32, PriorityRing> PriorityMap;
27 struct PriorityMapPointer {
28 PriorityMapPointer();
29 PriorityRing* ring;
30 PriorityRing::iterator it;
31 bool alarm_enabled;
32 EpollServer::AlarmRegToken alarm_token;
35 typedef std::map<uint32, PriorityMapPointer> StreamIdToPriorityMap;
37 StreamIdToPriorityMap stream_ids_;
38 PriorityMap priority_map_;
39 PriorityRing first_data_senders_;
40 uint32 first_data_senders_threshold_; // when you've passed this, you're no
41 // longer a first_data_sender...
42 SMConnectionInterface* connection_;
43 EpollServer* epoll_server_;
45 explicit OutputOrdering(SMConnectionInterface* connection);
46 ~OutputOrdering();
47 void Reset();
48 bool ExistsInPriorityMaps(uint32 stream_id);
50 struct BeginOutputtingAlarm : public EpollAlarmCallbackInterface {
51 public:
52 BeginOutputtingAlarm(OutputOrdering* oo,
53 OutputOrdering::PriorityMapPointer* pmp,
54 const MemCacheIter& mci);
55 virtual ~BeginOutputtingAlarm();
57 // EpollAlarmCallbackInterface:
58 virtual int64 OnAlarm() OVERRIDE;
59 virtual void OnRegistration(const EpollServer::AlarmRegToken& tok,
60 EpollServer* eps) OVERRIDE;
61 virtual void OnUnregistration() OVERRIDE;
62 virtual void OnShutdown(EpollServer* eps) OVERRIDE;
64 private:
65 OutputOrdering* output_ordering_;
66 OutputOrdering::PriorityMapPointer* pmp_;
67 MemCacheIter mci_;
68 EpollServer* epoll_server_;
71 void MoveToActive(PriorityMapPointer* pmp, MemCacheIter mci);
72 void AddToOutputOrder(const MemCacheIter& mci);
73 void SpliceToPriorityRing(PriorityRing::iterator pri);
74 MemCacheIter* GetIter();
75 void RemoveStreamId(uint32 stream_id);
77 static double server_think_time_in_s() { return server_think_time_in_s_; }
78 static void set_server_think_time_in_s(double value) {
79 server_think_time_in_s_ = value;
82 private:
83 static double server_think_time_in_s_;
86 } // namespace net
88 #endif // NET_TOOLS_FLIP_SERVER_OUTPUT_ORDERING_H_