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 "UrlHandler.h" | 8 #include "UrlHandler.h" |
9 | 9 |
10 #include "microhttpd.h" | 10 #include "microhttpd.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 return result; | 31 return result; |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 int BreakHandler::handle(Request* request, MHD_Connection* connection, | 35 int BreakHandler::handle(Request* request, MHD_Connection* connection, |
36 const char* url, const char* method, | 36 const char* url, const char* method, |
37 const char* upload_data, size_t* upload_data_size) { | 37 const char* upload_data, size_t* upload_data_size) { |
38 SkTArray<SkString> commands; | 38 SkTArray<SkString> commands; |
39 SkStrSplit(url, "/", &commands); | 39 SkStrSplit(url, "/", &commands); |
40 | 40 |
41 if (!request->fPicture.get() || commands.count() != 4) { | 41 if (!request->hasPicture() || commands.count() != 4) { |
42 return MHD_NO; | 42 return MHD_NO; |
43 } | 43 } |
44 | 44 |
45 // /break/<n>/<x>/<y> | 45 // /break/<n>/<x>/<y> |
46 int n; | 46 int n; |
47 sscanf(commands[1].c_str(), "%d", &n); | 47 sscanf(commands[1].c_str(), "%d", &n); |
48 int x; | 48 int x; |
49 sscanf(commands[2].c_str(), "%d", &x); | 49 sscanf(commands[2].c_str(), "%d", &x); |
50 int y; | 50 int y; |
51 sscanf(commands[3].c_str(), "%d", &y); | 51 sscanf(commands[3].c_str(), "%d", &y); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 break; | 90 break; |
91 } | 91 } |
92 } | 92 } |
93 canvas->restoreToCount(saveCount); | 93 canvas->restoreToCount(saveCount); |
94 SkDynamicMemoryWStream stream; | 94 SkDynamicMemoryWStream stream; |
95 stream.writeText(Json::FastWriter().write(response).c_str()); | 95 stream.writeText(Json::FastWriter().write(response).c_str()); |
96 SkAutoTUnref<SkData> data(stream.copyToData()); | 96 SkAutoTUnref<SkData> data(stream.copyToData()); |
97 return SendData(connection, data, "application/json"); | 97 return SendData(connection, data, "application/json"); |
98 } | 98 } |
99 | 99 |
OLD | NEW |