Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: tools/skiaserve/skiaserve.cpp

Issue 1686553006: skiaserve: Fix /cmd/N and /cmd/N[0|1], the response was never queued. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const char* content_type, const char* transfer_en coding, 136 const char* content_type, const char* transfer_en coding,
137 const char* data, uint64_t off, size_t size) { 137 const char* data, uint64_t off, size_t size) {
138 struct UploadContext* uc = reinterpret_cast<UploadContext*>(cls); 138 struct UploadContext* uc = reinterpret_cast<UploadContext*>(cls);
139 139
140 if (0 != size) { 140 if (0 != size) {
141 uc->fStream.write(data, size); 141 uc->fStream.write(data, size);
142 } 142 }
143 return MHD_YES; 143 return MHD_YES;
144 } 144 }
145 145
146 // SendOK just sends an empty response with a 200 OK status code.
147 static int SendOK(MHD_Connection* connection) {
148 const char* data = "";
149
150 MHD_Response* response = MHD_create_response_from_buffer(strlen(data),
151 (void*)data,
152 MHD_RESPMEM_PERSIST ENT);
153 int ret = MHD_queue_response(connection, 200, response);
154 MHD_destroy_response(response);
155 return ret;
156 }
157
146 static int SendData(MHD_Connection* connection, const SkData* data, const char* type, 158 static int SendData(MHD_Connection* connection, const SkData* data, const char* type,
147 bool setContentDisposition = false, const char* dispositionS tring = nullptr) { 159 bool setContentDisposition = false, const char* dispositionS tring = nullptr) {
148 MHD_Response* response = MHD_create_response_from_buffer(data->size(), 160 MHD_Response* response = MHD_create_response_from_buffer(data->size(),
149 const_cast<void*>(d ata->data()), 161 const_cast<void*>(d ata->data()),
150 MHD_RESPMEM_MUST_CO PY); 162 MHD_RESPMEM_MUST_CO PY);
151 MHD_add_response_header(response, "Content-Type", type); 163 MHD_add_response_header(response, "Content-Type", type);
152 164
153 if (setContentDisposition) { 165 if (setContentDisposition) {
154 MHD_add_response_header(response, "Content-Disposition", dispositionStri ng); 166 MHD_add_response_header(response, "Content-Disposition", dispositionStri ng);
155 } 167 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (commands.count() == 1 && 0 == strcmp(method, MHD_HTTP_METHOD_GET)) { 233 if (commands.count() == 1 && 0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
222 int n = request->fDebugCanvas->getSize() - 1; 234 int n = request->fDebugCanvas->getSize() - 1;
223 return SendJSON(connection, request->fDebugCanvas, n); 235 return SendJSON(connection, request->fDebugCanvas, n);
224 } 236 }
225 237
226 // /cmd/N, for now only delete supported 238 // /cmd/N, for now only delete supported
227 if (commands.count() == 2 && 0 == strcmp(method, MHD_HTTP_METHOD_DELETE) ) { 239 if (commands.count() == 2 && 0 == strcmp(method, MHD_HTTP_METHOD_DELETE) ) {
228 int n; 240 int n;
229 sscanf(commands[1].c_str(), "%d", &n); 241 sscanf(commands[1].c_str(), "%d", &n);
230 request->fDebugCanvas->deleteDrawCommandAt(n); 242 request->fDebugCanvas->deleteDrawCommandAt(n);
231 return MHD_YES; 243 return SendOK(connection);
232 } 244 }
233 245
234 // /cmd/N/[0|1] 246 // /cmd/N/[0|1]
235 if (commands.count() == 3 && 0 == strcmp(method, MHD_HTTP_METHOD_POST)) { 247 if (commands.count() == 3 && 0 == strcmp(method, MHD_HTTP_METHOD_POST)) {
236 int n, toggle; 248 int n, toggle;
237 sscanf(commands[1].c_str(), "%d", &n); 249 sscanf(commands[1].c_str(), "%d", &n);
238 sscanf(commands[2].c_str(), "%d", &toggle); 250 sscanf(commands[2].c_str(), "%d", &toggle);
239 request->fDebugCanvas->toggleCommand(n, toggle); 251 request->fDebugCanvas->toggleCommand(n, toggle);
240 return MHD_YES; 252 return SendOK(connection);
241 } 253 }
242 254
243 return MHD_NO; 255 return MHD_NO;
244 } 256 }
245 }; 257 };
246 258
247 class ImgHandler : public UrlHandler { 259 class ImgHandler : public UrlHandler {
248 public: 260 public:
249 bool canHandle(const char* method, const char* url) override { 261 bool canHandle(const char* method, const char* url) override {
250 static const char* kBasePath = "/img"; 262 static const char* kBasePath = "/img";
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 MHD_stop_daemon(daemon); 558 MHD_stop_daemon(daemon);
547 return 0; 559 return 0;
548 } 560 }
549 561
550 #if !defined SK_BUILD_FOR_IOS 562 #if !defined SK_BUILD_FOR_IOS
551 int main(int argc, char** argv) { 563 int main(int argc, char** argv) {
552 SkCommandLineFlags::Parse(argc, argv); 564 SkCommandLineFlags::Parse(argc, argv);
553 return skiaserve_main(); 565 return skiaserve_main();
554 } 566 }
555 #endif 567 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698