~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

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