Page Speed Optimization Libraries  1.7.30.4
net/instaweb/http/public/http_dump_url_fetcher.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http:///www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00018 
00019 #ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
00020 #define NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
00021 
00022 #include "net/instaweb/http/public/url_async_fetcher.h"
00023 #include "net/instaweb/util/public/basictypes.h"
00024 #include "net/instaweb/util/public/file_system.h"
00025 #include "net/instaweb/util/public/scoped_ptr.h"
00026 #include "net/instaweb/util/public/string.h"
00027 #include "net/instaweb/util/public/string_util.h"
00028 
00029 namespace net_instaweb {
00030 
00031 class AsyncFetch;
00032 class GoogleUrl;
00033 class MessageHandler;
00034 class ResponseHeaders;
00035 class Timer;
00036 class Writer;
00037 
00041 
00045 class HttpDumpUrlFetcher : public UrlAsyncFetcher {
00046  public:
00052   static const char kGzipContentLengthAttribute[];
00053 
00054   HttpDumpUrlFetcher(const StringPiece& root_dir, FileSystem* file_system,
00055                      Timer* timer);
00056   virtual ~HttpDumpUrlFetcher();
00057 
00060   static bool GetFilenameFromUrl(const StringPiece& root_dir,
00061                                  const GoogleUrl& url,
00062                                  GoogleString* filename,
00063                                  MessageHandler* message_handler);
00064 
00066   bool GetFilename(const GoogleUrl& url,
00067                    GoogleString* filename,
00068                    MessageHandler* message_handler) {
00069     return GetFilenameFromUrl(root_dir_, url, filename, message_handler);
00070   }
00071 
00073   virtual void Fetch(const GoogleString& url,
00074                      MessageHandler* message_handler,
00075                      AsyncFetch* fetch);
00076 
00079   bool ParseFile(FileSystem::InputFile* file,
00080                  ResponseHeaders* response_headers,
00081                  Writer* response_writer,
00082                  MessageHandler* handler);
00083 
00085   void RespondError(ResponseHeaders* response_headers, Writer* response_writer,
00086                     MessageHandler* handler);
00087 
00089   void set_print_urls(bool on);
00090 
00091  private:
00092   GoogleString root_dir_; 
00093   FileSystem* file_system_;
00094   Timer* timer_;
00095 
00097   GoogleString error_body_;
00098 
00099   scoped_ptr<StringSet> urls_;
00100 
00101   DISALLOW_COPY_AND_ASSIGN(HttpDumpUrlFetcher);
00102 };
00103 
00104 }  
00105 
00106 #endif  ///< NET_INSTAWEB_HTTP_PUBLIC_HTTP_DUMP_URL_FETCHER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines