~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_dump_url_async_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 2010 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
 
 
17
 
// Author: sligocki@google.com (Shawn Ligocki)
18
 
 
19
 
#ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_ASYNC_WRITER_H_
20
 
#define NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_ASYNC_WRITER_H_
21
 
 
22
 
#include "net/instaweb/http/public/url_async_fetcher.h"
23
 
#include "net/instaweb/http/public/http_dump_url_fetcher.h"
24
 
#include "net/instaweb/util/public/basictypes.h"
25
 
#include "net/instaweb/util/public/string.h"
26
 
#include "net/instaweb/util/public/string_util.h"
27
 
 
28
 
namespace net_instaweb {
29
 
 
30
 
class AsyncFetch;
31
 
class FileSystem;
32
 
class MessageHandler;
33
 
class Timer;
34
 
 
35
 
// HttpDumpWriter checks to see whether the HTTP dump is available on the
36
 
// filesystem.  If not, it fetches it from another fetcher (e.g. one that
37
 
// uses the network) and writes it to the filesystem so that HttpDumpFetcher
38
 
// can find it.
39
 
class HttpDumpUrlAsyncWriter : public UrlAsyncFetcher {
40
 
 public:
41
 
  HttpDumpUrlAsyncWriter(const StringPiece& root_dir,
42
 
                         UrlAsyncFetcher* base_fetcher,
43
 
                         FileSystem* file_system,
44
 
                         Timer* timer)
45
 
      : dump_fetcher_(root_dir, file_system, timer),
46
 
        base_fetcher_(base_fetcher),
47
 
        file_system_(file_system),
48
 
        accept_gzip_(true) {
49
 
    root_dir.CopyToString(&root_dir_);
50
 
  }
51
 
  virtual ~HttpDumpUrlAsyncWriter();
52
 
 
53
 
  virtual bool SupportsHttps() const { return base_fetcher_->SupportsHttps(); }
54
 
 
55
 
  // This is a synchronous/blocking implementation.
56
 
  virtual void Fetch(const GoogleString& url,
57
 
                     MessageHandler* handler,
58
 
                     AsyncFetch* base_fetch);
59
 
 
60
 
  // Controls whether we will request and save gzipped content to the
61
 
  // file system.  Note that http_dump_url_fetcher will inflate on
62
 
  // read if its caller does not want gzipped output.
63
 
  void set_accept_gzip(bool x) { accept_gzip_ = x; }
64
 
 
65
 
  // Print URLs each time they are fetched.
66
 
  void set_print_urls(bool on) { dump_fetcher_.set_print_urls(on); }
67
 
 
68
 
 private:
69
 
  // Helper class to manage individual fetchs.
70
 
  class DumpFetch;
71
 
 
72
 
  HttpDumpUrlFetcher dump_fetcher_;
73
 
  // Used to fetch urls that aren't in the dump yet.
74
 
  UrlAsyncFetcher* base_fetcher_;
75
 
  GoogleString root_dir_;  // Root directory of the HTTP dumps.
76
 
  FileSystem* file_system_;
77
 
  bool accept_gzip_;
78
 
 
79
 
  DISALLOW_COPY_AND_ASSIGN(HttpDumpUrlAsyncWriter);
80
 
};
81
 
 
82
 
}  // namespace net_instaweb
83
 
 
84
 
#endif  // NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_ASYNC_WRITER_H_