View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.spdy;
20  
21  import org.eclipse.jetty.spdy.api.DataInfo;
22  
23  // TODO: add methods that tell how much written and whether we're TCP congested ?
24  public interface FlowControlStrategy
25  {
26      public int getWindowSize(ISession session);
27  
28      public void setWindowSize(ISession session, int windowSize);
29  
30      public void onNewStream(ISession session, IStream stream);
31  
32      public void onWindowUpdate(ISession session, IStream stream, int delta);
33  
34      public void updateWindow(ISession session, IStream stream, int delta);
35  
36      public void onDataReceived(ISession session, IStream stream, DataInfo dataInfo);
37  
38      public void onDataConsumed(ISession session, IStream stream, DataInfo dataInfo, int delta);
39  
40      public static class None implements FlowControlStrategy
41      {
42          private volatile int windowSize;
43  
44          public None()
45          {
46              this(65536);
47          }
48  
49          public None(int windowSize)
50          {
51              this.windowSize = windowSize;
52          }
53  
54          @Override
55          public int getWindowSize(ISession session)
56          {
57              return windowSize;
58          }
59  
60          @Override
61          public void setWindowSize(ISession session, int windowSize)
62          {
63              this.windowSize = windowSize;
64          }
65  
66          @Override
67          public void onNewStream(ISession session, IStream stream)
68          {
69              stream.updateWindowSize(windowSize);
70          }
71  
72          @Override
73          public void onWindowUpdate(ISession session, IStream stream, int delta)
74          {
75          }
76  
77          @Override
78          public void updateWindow(ISession session, IStream stream, int delta)
79          {
80          }
81  
82          @Override
83          public void onDataReceived(ISession session, IStream stream, DataInfo dataInfo)
84          {
85          }
86  
87          @Override
88          public void onDataConsumed(ISession session, IStream stream, DataInfo dataInfo, int delta)
89          {
90          }
91      }
92  }