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 "Request.h" | 8 #include "Request.h" |
9 #include "Response.h" | 9 #include "Response.h" |
10 | 10 |
11 #include "SkCommandLineFlags.h" | 11 #include "SkCommandLineFlags.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
13 | 13 |
14 #include "microhttpd.h" | 14 #include "microhttpd.h" |
15 | 15 |
16 #include "urlhandlers/UrlHandler.h" | 16 #include "urlhandlers/UrlHandler.h" |
17 | 17 |
18 #include <errno.h> | 18 #include <errno.h> |
19 | 19 |
20 #if !defined _WIN32 | 20 #if !defined _WIN32 |
21 #include <sys/socket.h> | 21 #include <sys/socket.h> |
22 #include <arpa/inet.h> | 22 #include <arpa/inet.h> |
23 #endif | 23 #endif |
24 | 24 |
25 using namespace Response; | 25 using namespace Response; |
26 | 26 |
27 DEFINE_int32(port, 8888, "The port to listen on."); | 27 DEFINE_int32(port, 8888, "The port to listen on."); |
28 DEFINE_string(address, "127.0.0.1", "The address to bind to."); | 28 DEFINE_string(address, "127.0.0.1", "The address to bind to."); |
| 29 DEFINE_bool(hosted, false, "Running in hosted mode on debugger.skia.org."); |
29 | 30 |
30 class UrlManager { | 31 class UrlManager { |
31 public: | 32 public: |
32 UrlManager() { | 33 UrlManager() { |
33 // Register handlers | 34 // Register handlers |
34 fHandlers.push_back(new RootHandler); | 35 fHandlers.push_back(new RootHandler); |
35 fHandlers.push_back(new PostHandler); | 36 fHandlers.push_back(new PostHandler); |
36 fHandlers.push_back(new ImgHandler); | 37 fHandlers.push_back(new ImgHandler); |
37 fHandlers.push_back(new ClipAlphaHandler); | 38 fHandlers.push_back(new ClipAlphaHandler); |
38 fHandlers.push_back(new EnableGPUHandler); | 39 fHandlers.push_back(new EnableGPUHandler); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 #endif | 109 #endif |
109 , FLAGS_port, nullptr, nullptr, | 110 , FLAGS_port, nullptr, nullptr, |
110 &answer_to_connection, &request, | 111 &answer_to_connection, &request, |
111 MHD_OPTION_SOCK_ADDR, &address, | 112 MHD_OPTION_SOCK_ADDR, &address, |
112 MHD_OPTION_END); | 113 MHD_OPTION_END); |
113 if (NULL == daemon) { | 114 if (NULL == daemon) { |
114 SkDebugf("Could not initialize daemon\n"); | 115 SkDebugf("Could not initialize daemon\n"); |
115 return 1; | 116 return 1; |
116 } | 117 } |
117 | 118 |
118 getchar(); | 119 if (FLAGS_hosted) { |
| 120 while (1) { |
| 121 SkDebugf("loop\n"); |
| 122 #if defined(SK_BUILD_FOR_WIN) |
| 123 Sleep(60 * 1000); |
| 124 #else |
| 125 sleep(60); |
| 126 #endif |
| 127 } |
| 128 } else { |
| 129 getchar(); |
| 130 } |
119 MHD_stop_daemon(daemon); | 131 MHD_stop_daemon(daemon); |
120 return 0; | 132 return 0; |
121 } | 133 } |
122 | 134 |
123 #if !defined SK_BUILD_FOR_IOS | 135 #if !defined SK_BUILD_FOR_IOS |
124 int main(int argc, char** argv) { | 136 int main(int argc, char** argv) { |
125 SkCommandLineFlags::Parse(argc, argv); | 137 SkCommandLineFlags::Parse(argc, argv); |
126 return skiaserve_main(); | 138 return skiaserve_main(); |
127 } | 139 } |
128 #endif | 140 #endif |
OLD | NEW |