~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/http/public/http_value_writer.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
 
/*
2
 
 * Copyright 2012 Google Inc.
3
 
 *
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
7
 
 *
8
 
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 
 *
10
 
 * Unless required by applicable law or agreed to in writing, software
11
 
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 
 * See the License for the specific language governing permissions and
14
 
 * limitations under the License.
15
 
 */
16
 
// Author: mmohabey@google.com (Megha Mohabey)
17
 
 
18
 
#ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_VALUE_WRITER_H_
19
 
#define NET_INSTAWEB_HTTP_PUBLIC_HTTP_VALUE_WRITER_H_
20
 
 
21
 
#include "net/instaweb/util/public/basictypes.h"
22
 
#include "net/instaweb/util/public/string_util.h"
23
 
 
24
 
namespace net_instaweb {
25
 
 
26
 
class HTTPCache;
27
 
class HTTPValue;
28
 
class MessageHandler;
29
 
class ResponseHeaders;
30
 
 
31
 
// Wrappper for buffering an HTTPValue. HTTPValueWriter ensures that an
32
 
// HTTPValue which cannot be eventually cached is not buffered.
33
 
class HTTPValueWriter {
34
 
 public:
35
 
  HTTPValueWriter(HTTPValue* value, HTTPCache* cache)
36
 
      : value_(value),
37
 
        cache_(cache),
38
 
        has_buffered_(true) {}
39
 
 
40
 
  void SetHeaders(ResponseHeaders* headers);
41
 
 
42
 
  bool Write(const StringPiece& str, MessageHandler* handler);
43
 
 
44
 
  bool has_buffered() const { return has_buffered_; }
45
 
 
46
 
  // Checks if the http_value should be buffered or not depending on whether we
47
 
  // can eventually cache it. It also clears the http_value if it can not be
48
 
  // buffered. Note that this only checks the size constraints, not cache
49
 
  // headers.
50
 
  bool CheckCanCacheElseClear(ResponseHeaders* headers);
51
 
 
52
 
  // Checks if we can write the string to the HttpValue without going over
53
 
  // limits.
54
 
  bool CanCacheContent(const StringPiece& str) const;
55
 
 
56
 
 private:
57
 
  HTTPValue* value_;
58
 
  HTTPCache* cache_;
59
 
  bool has_buffered_;
60
 
  DISALLOW_COPY_AND_ASSIGN(HTTPValueWriter);
61
 
};
62
 
 
63
 
}  // namespace net_instaweb
64
 
#endif  // NET_INSTAWEB_HTTP_PUBLIC_HTTP_VALUE_WRITER_H_