OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrCaps.h" | 8 #include "GrCaps.h" |
9 #include "GrContextFactory.h" | 9 #include "GrContextFactory.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return MHD_NO; | 239 return MHD_NO; |
240 } | 240 } |
241 | 241 |
242 class UrlManager { | 242 class UrlManager { |
243 public: | 243 public: |
244 UrlManager() { | 244 UrlManager() { |
245 // Register handlers | 245 // Register handlers |
246 fHandlers.push_back({MHD_HTTP_METHOD_GET, "/", rootHandler}); | 246 fHandlers.push_back({MHD_HTTP_METHOD_GET, "/", rootHandler}); |
247 fHandlers.push_back({MHD_HTTP_METHOD_POST, "/new", postHandler}); | 247 fHandlers.push_back({MHD_HTTP_METHOD_POST, "/new", postHandler}); |
248 fHandlers.push_back({MHD_HTTP_METHOD_GET, "/img", imgHandler}); | 248 fHandlers.push_back({MHD_HTTP_METHOD_GET, "/img", imgHandler}); |
249 //fHandlers.push_back({MHD_HTTP_METHOD_GET, "/cmd", infoHandler}); | 249 fHandlers.push_back({MHD_HTTP_METHOD_GET, "/cmd", infoHandler}); |
250 } | 250 } |
251 | 251 |
252 // This is clearly not efficient for a large number of urls and handlers | 252 // This is clearly not efficient for a large number of urls and handlers |
253 int invoke(Request* request, MHD_Connection* connection, const char* url, co
nst char* method, | 253 int invoke(Request* request, MHD_Connection* connection, const char* url, co
nst char* method, |
254 const char* upload_data, size_t* upload_data_size) const { | 254 const char* upload_data, size_t* upload_data_size) const { |
255 for (int i = 0; i < fHandlers.count(); i++) { | 255 for (int i = 0; i < fHandlers.count(); i++) { |
256 const Url& urlHandler = fHandlers[i]; | 256 const Url& urlHandler = fHandlers[i]; |
257 if (0 == strcmp(method, urlHandler.fMethod) && | 257 if (0 == strcmp(method, urlHandler.fMethod) && |
258 0 == strcmp(url, urlHandler.fPath)) { | 258 0 == strcmp(url, urlHandler.fPath)) { |
259 return (*urlHandler.fHandler)(request, connection, upload_da
ta, | 259 return (*urlHandler.fHandler)(request, connection, upload_da
ta, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 MHD_stop_daemon(daemon); | 298 MHD_stop_daemon(daemon); |
299 return 0; | 299 return 0; |
300 } | 300 } |
301 | 301 |
302 #if !defined SK_BUILD_FOR_IOS | 302 #if !defined SK_BUILD_FOR_IOS |
303 int main(int argc, char** argv) { | 303 int main(int argc, char** argv) { |
304 SkCommandLineFlags::Parse(argc, argv); | 304 SkCommandLineFlags::Parse(argc, argv); |
305 return skiaserve_main(); | 305 return skiaserve_main(); |
306 } | 306 } |
307 #endif | 307 #endif |
OLD | NEW |