Page Speed Optimization Libraries  1.4.26.1
net/instaweb/automatic/public/static_rewriter.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 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_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_
00020 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_
00021 
00022 #include "net/instaweb/rewriter/public/rewrite_driver_factory.h"
00023 #include "net/instaweb/rewriter/public/rewrite_gflags.h"
00024 #include "net/instaweb/util/public/basictypes.h"
00025 #include "net/instaweb/util/public/simple_stats.h"
00026 #include "net/instaweb/util/public/string_util.h"
00027 
00028 namespace net_instaweb {
00029 
00030 class FileSystem;
00031 class Hasher;
00032 class MessageHandler;
00033 class ServerContext;
00034 class Statistics;
00035 class Timer;
00036 class UrlAsyncFetcher;
00037 class UrlFetcher;
00038 class Writer;
00039 
00046 class FileRewriter : public RewriteDriverFactory {
00047  public:
00048   FileRewriter(const RewriteGflags* gflags,
00049                bool echo_errors_to_stdout);
00050   virtual ~FileRewriter();
00051   virtual Hasher* NewHasher();
00052   virtual UrlFetcher* DefaultUrlFetcher();
00053   virtual UrlAsyncFetcher* DefaultAsyncUrlFetcher();
00054   virtual MessageHandler* DefaultHtmlParseMessageHandler();
00055   virtual MessageHandler* DefaultMessageHandler();
00056   virtual FileSystem* DefaultFileSystem();
00057   virtual Timer* DefaultTimer();
00058   virtual void SetupCaches(ServerContext* resource_manager);
00059   virtual Statistics* statistics();
00060   virtual ServerContext* NewServerContext();
00061   virtual bool UseBeaconResultsInFilters() const { return false; }
00062 
00063  private:
00064   const RewriteGflags* gflags_;
00065   SimpleStats simple_stats_;
00066   bool echo_errors_to_stdout_;
00067 
00068   DISALLOW_COPY_AND_ASSIGN(FileRewriter);
00069 };
00070 
00073 class StaticRewriter {
00074  public:
00075   StaticRewriter(int* argc, char*** argv);
00076   StaticRewriter();
00077   ~StaticRewriter();
00078 
00079   bool ParseText(const StringPiece& text,
00080                  const StringPiece& url,
00081                  const StringPiece& id,
00082                  const StringPiece& output_dir,
00083                  Writer* writer);
00084 
00085   FileSystem* file_system();
00086   MessageHandler* message_handler();
00087 
00088  private:
00089   RewriteGflags gflags_;
00090   FileRewriter file_rewriter_;
00091   ServerContext* server_context_;
00092 
00093   DISALLOW_COPY_AND_ASSIGN(StaticRewriter);
00094 };
00095 
00096 }  
00097 
00098 #endif  ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_STATIC_REWRITER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines