~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/third_party/mod_spdy/src/mod_spdy/common/http_to_spdy_converter.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2011 Google Inc.
2
 
//
3
 
// Licensed under the Apache License, Version 2.0 (the "License");
4
 
// you may not use this file except in compliance with the License.
5
 
// You may obtain a copy of the License at
6
 
//
7
 
//      http://www.apache.org/licenses/LICENSE-2.0
8
 
//
9
 
// Unless required by applicable law or agreed to in writing, software
10
 
// distributed under the License is distributed on an "AS IS" BASIS,
11
 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
// See the License for the specific language governing permissions and
13
 
// limitations under the License.
14
 
 
15
 
#ifndef MOD_SPDY_COMMON_HTTP_TO_SPDY_CONVERTER_H_
16
 
#define MOD_SPDY_COMMON_HTTP_TO_SPDY_CONVERTER_H_
17
 
 
18
 
#include <string>
19
 
 
20
 
#include "base/basictypes.h"
21
 
#include "base/memory/scoped_ptr.h"
22
 
#include "base/string_piece.h"
23
 
#include "mod_spdy/common/http_response_parser.h"
24
 
#include "net/spdy/spdy_framer.h"  // for SpdyHeaderBlock
25
 
 
26
 
namespace mod_spdy {
27
 
 
28
 
// Parses incoming HTTP response data and converts it into equivalent SPDY
29
 
// frame data.
30
 
class HttpToSpdyConverter {
31
 
 public:
32
 
  // Interface for the class that will receive frame data from the converter.
33
 
  class SpdyReceiver {
34
 
   public:
35
 
    SpdyReceiver();
36
 
    virtual ~SpdyReceiver();
37
 
 
38
 
    // Receive a SYN_REPLY frame with the given headers.  The callee is free to
39
 
    // mutate the headers map (e.g. to add an extra header) before forwarding
40
 
    // it on, but the pointer will not remain valid after this method returns.
41
 
    virtual void ReceiveSynReply(net::SpdyHeaderBlock* headers,
42
 
                                 bool flag_fin) = 0;
43
 
 
44
 
    // Receive a DATA frame with the given payload.  The data pointer will not
45
 
    // remain valid after this method returns.
46
 
    virtual void ReceiveData(base::StringPiece data, bool flag_fin) = 0;
47
 
 
48
 
   private:
49
 
    DISALLOW_COPY_AND_ASSIGN(SpdyReceiver);
50
 
  };
51
 
 
52
 
  // Create a converter that will send frame data to the given receiver.  The
53
 
  // converter does *not* gain ownership of the receiver.
54
 
  HttpToSpdyConverter(int spdy_version, SpdyReceiver* receiver);
55
 
  ~HttpToSpdyConverter();
56
 
 
57
 
  // Parse and process the next chunk of input; return true on success, false
58
 
  // on failure.
59
 
  bool ProcessInput(base::StringPiece input_data);
60
 
  bool ProcessInput(const char* data, size_t size) {
61
 
    return ProcessInput(base::StringPiece(data, size));
62
 
  }
63
 
 
64
 
  // Flush out any buffered data.
65
 
  void Flush();
66
 
 
67
 
 private:
68
 
  class ConverterImpl;
69
 
  scoped_ptr<ConverterImpl> impl_;
70
 
  HttpResponseParser parser_;
71
 
 
72
 
  DISALLOW_COPY_AND_ASSIGN(HttpToSpdyConverter);
73
 
};
74
 
 
75
 
}  // namespace mod_spdy
76
 
 
77
 
#endif  // MOD_SPDY_COMMON_HTTP_TO_SPDY_CONVERTER_H_