1
// Copyright 2013 Google Inc.
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
7
// http://www.apache.org/licenses/LICENSE-2.0
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.
15
// Author: jefftk@google.com (Jeff Kaufman)
16
// Author: xqyin@google.com (XiaoQian Yin)
18
#ifndef NET_INSTAWEB_SYSTEM_PUBLIC_ADMIN_SITE_H_
19
#define NET_INSTAWEB_SYSTEM_PUBLIC_ADMIN_SITE_H_
21
#include "net/instaweb/util/public/basictypes.h"
22
#include "pagespeed/kernel/base/string_util.h"
24
namespace net_instaweb {
35
class StaticAssetManager;
37
class SystemCachePath;
39
class SystemRewriteOptions;
43
// Implements the /pagespeed_admin pages.
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 };
54
AdminSite(StaticAssetManager* static_asset_manager, Timer* timer,
55
MessageHandler* message_handler);
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);
67
// Displays recent Info/Warning/Error messages.: public ServerContext
68
void MessageHistoryHandler(const RewriteOptions& options,
69
AdminSource source, AsyncFetch* fetch);
71
// Deprecated handler for graphs in the PSOL console.
72
void StatisticsGraphsHandler(
73
Writer* writer, SystemRewriteOptions* global_system_rewrite_options);
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,
88
SystemRewriteOptions* global_system_rewrite_options,
89
const SystemRewriteOptions* spdy_config);
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,
104
SystemRewriteOptions* global_system_rewrite_options,
105
const SystemRewriteOptions* spdy_config);
107
// Returns JSON used by the PageSpeed Console JavaScript.
108
void ConsoleJsonHandler(const QueryParams& params, AsyncFetch* fetch,
109
Statistics* statistics);
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.
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.
120
// In systems without a spdy-specific config, spdy_config should be
122
void StatisticsHandler(const RewriteOptions& options, AdminSource source,
123
AsyncFetch* fetch, Statistics* stats);
125
// Responds to 'fetch' with data used on statistics page and graphs page
127
void StatisticsJsonHandler(AsyncFetch* fetch, Statistics* stats);
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,
135
// Print details fo the SPDY configuration.
136
void PrintSpdyConfig(AdminSource source, AsyncFetch* fetch,
137
const SystemRewriteOptions* spdy_config);
139
// Print details fo the non-SPDY configuration.
140
void PrintNormalConfig(AdminSource source, AsyncFetch* fetch,
141
SystemRewriteOptions* global_system_rewrite_options);
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);
156
// Print histograms showing the dynamics of server activity.
157
void PrintHistograms(AdminSource source, AsyncFetch* fetch,
160
void PurgeHandler(StringPiece url, SystemCachePath* cache_path,
163
// Return the message handler for debugging use.
164
MessageHandler* MessageHandlerForTesting() { return message_handler_; }
167
MessageHandler* message_handler_;
168
StaticAssetManager* static_asset_manager_;
170
DISALLOW_COPY_AND_ASSIGN(AdminSite);
173
} // namespace net_instaweb
175
#endif // NET_INSTAWEB_SYSTEM_PUBLIC_ADMIN_SITE_H_