"Fossies" - the Fresh Open Source Software Archive

Member "incubator-pagespeed-mod-1.14.36.1/pagespeed/system/admin_site.h" (28 Feb 2020, 6943 Bytes) of package /linux/www/apache_httpd_modules/incubator-pagespeed-mod-1.14.36.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "admin_site.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.13.35.2_vs_1.14.36.1.

    1 /*
    2  * Licensed to the Apache Software Foundation (ASF) under one
    3  * or more contributor license agreements.  See the NOTICE file
    4  * distributed with this work for additional information
    5  * regarding copyright ownership.  The ASF licenses this file
    6  * to you under the Apache License, Version 2.0 (the
    7  * "License"); you may not use this file except in compliance
    8  * with the License.  You may obtain a copy of the License at
    9  * 
   10  *   http://www.apache.org/licenses/LICENSE-2.0
   11  * 
   12  * Unless required by applicable law or agreed to in writing,
   13  * software distributed under the License is distributed on an
   14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15  * KIND, either express or implied.  See the License for the
   16  * specific language governing permissions and limitations
   17  * under the License.
   18  */
   19 
   20 
   21 #ifndef PAGESPEED_SYSTEM_ADMIN_SITE_H_
   22 #define PAGESPEED_SYSTEM_ADMIN_SITE_H_
   23 
   24 #include "pagespeed/kernel/base/basictypes.h"
   25 #include "pagespeed/kernel/base/string_util.h"
   26 
   27 namespace net_instaweb {
   28 
   29 class AsyncFetch;
   30 class CacheInterface;
   31 class GoogleUrl;
   32 class HTTPCache;
   33 class MessageHandler;
   34 class PropertyCache;
   35 class QueryParams;
   36 class RewriteOptions;
   37 class ServerContext;
   38 class StaticAssetManager;
   39 class Statistics;
   40 class SystemCachePath;
   41 class SystemCaches;
   42 class SystemRewriteOptions;
   43 class Timer;
   44 class Writer;
   45 
   46 // Implements the /pagespeed_admin pages.
   47 class AdminSite {
   48  public:
   49   // Identifies whether the user arrived at an admin page from a
   50   // /pagespeed_admin handler or a /*_pagespeed_statistics handler.
   51   // The main difference between these is that the _admin site might in the
   52   // future grant more privileges than the statistics site did, such as flushing
   53   // cache.  But it also affects the syntax of the links created to sub-pages
   54   // in the top navigation bar.
   55   enum AdminSource { kPageSpeedAdmin, kStatistics, kOther };
   56 
   57   AdminSite(StaticAssetManager* static_asset_manager, Timer* timer,
   58             MessageHandler* message_handler);
   59 
   60   ~AdminSite() {
   61   }
   62 
   63   // Handler which serves PSOL console.
   64   // Note: ConsoleHandler always succeeds.
   65   void ConsoleHandler(const SystemRewriteOptions& global_options,
   66                       const RewriteOptions& options, AdminSource source,
   67                       const QueryParams& query_params, AsyncFetch* fetch,
   68                       Statistics* statistics);
   69 
   70   // Displays recent Info/Warning/Error messages.: public ServerContext
   71   void MessageHistoryHandler(const RewriteOptions& options,
   72                              AdminSource source, AsyncFetch* fetch);
   73 
   74   // Deprecated handler for graphs in the PSOL console.
   75   void StatisticsGraphsHandler(
   76       Writer* writer, SystemRewriteOptions* global_system_rewrite_options);
   77 
   78   // Handle a request for /pagespeed_admin/*, which is a launching
   79   // point for all the administrator pages including stats,
   80   // message-histogram, console, etc.
   81   void AdminPage(bool is_global, const GoogleUrl& stripped_gurl,
   82                  const QueryParams& query_params,
   83                  const RewriteOptions* options,
   84                  SystemCachePath* cache_path,
   85                  AsyncFetch* fetch, SystemCaches* system_caches,
   86                  CacheInterface* filesystem_metadata_cache,
   87                  HTTPCache* http_cache, CacheInterface* metadata_cache,
   88                  PropertyCache* page_property_cache,
   89                  ServerContext* server_context, Statistics* statistics,
   90                  Statistics* stats,
   91                  SystemRewriteOptions* global_system_rewrite_options);
   92 
   93   // Handle a request for the legacy /*_pagespeed_statistics page, which also
   94   // serves as a launching point for a subset of the admin pages.  Because the
   95   // admin pages are not uniformly sensitive, an existing PageSpeed user might
   96   // have granted public access to /mod_pagespeed_statistics, but we don't
   97   // want that to automatically imply access to the server cache.
   98   void StatisticsPage(bool is_global, const QueryParams& query_params,
   99                       const RewriteOptions* options, AsyncFetch* fetch,
  100                       SystemCaches* system_caches,
  101                       CacheInterface* filesystem_metadata_cache,
  102                       HTTPCache* http_cache, CacheInterface* metadata_cache,
  103                       PropertyCache* page_property_cache,
  104                       ServerContext* server_context, Statistics* statistics,
  105                       Statistics* stats,
  106                       SystemRewriteOptions* global_system_rewrite_options);
  107 
  108   // Returns JSON used by the PageSpeed Console JavaScript.
  109   void ConsoleJsonHandler(const QueryParams& params, AsyncFetch* fetch,
  110                           Statistics* statistics);
  111 
  112   // Handler for /mod_pagespeed_statistics and
  113   // /ngx_pagespeed_statistics, as well as
  114   // /...pagespeed__global_statistics.  If the latter,
  115   // is_global_request should be true.
  116   void StatisticsHandler(const RewriteOptions& options, AdminSource source,
  117                          AsyncFetch* fetch, Statistics* stats);
  118 
  119   // Responds to 'fetch' with data used on statistics page and graphs page
  120   // in JSON format.
  121   void StatisticsJsonHandler(AsyncFetch* fetch, Statistics* stats);
  122 
  123   // Display various charts on graphs page.
  124   // TODO(xqyin): Integrate this into console page.
  125   void GraphsHandler(const RewriteOptions& options, AdminSource source,
  126                      const QueryParams& query_params, AsyncFetch* fetch,
  127                      Statistics* stats);;
  128 
  129   // Print details for configuration.
  130   void PrintConfig(AdminSource source, AsyncFetch* fetch,
  131                    SystemRewriteOptions* global_system_rewrite_options);
  132 
  133   // Print statistics about the caches.  In the future this will also
  134   // be a launching point for examining cache entries and purging them.
  135   void PrintCaches(bool is_global, AdminSource source,
  136                    const GoogleUrl& stripped_gurl,
  137                    const QueryParams& query_params,
  138                    const RewriteOptions* options,
  139                    SystemCachePath* cache_path,
  140                    AsyncFetch* fetch, SystemCaches* system_caches,
  141                    CacheInterface* filesystem_metadata_cache,
  142                    HTTPCache* http_cache, CacheInterface* metadata_cache,
  143                    PropertyCache* page_property_cache,
  144                    ServerContext* server_context);
  145 
  146   // Print histograms showing the dynamics of server activity.
  147   void PrintHistograms(AdminSource source, AsyncFetch* fetch,
  148                        Statistics* stats);
  149 
  150   void PurgeHandler(StringPiece url, SystemCachePath* cache_path,
  151                     AsyncFetch* fetch);
  152 
  153   // Return the message handler for debugging use.
  154   MessageHandler* MessageHandlerForTesting() { return message_handler_; }
  155 
  156  private:
  157   MessageHandler* message_handler_;
  158   StaticAssetManager* static_asset_manager_;
  159   Timer* timer_;
  160   DISALLOW_COPY_AND_ASSIGN(AdminSite);
  161 };
  162 
  163 }  // namespace net_instaweb
  164 
  165 #endif  // PAGESPEED_SYSTEM_ADMIN_SITE_H_