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

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

Issue 1737323002: Wire up /batches in skiaserve (Closed) Base URL: https://skia.googlesource.com/skia@skiaserve-1
Patch Set: minor tweak 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 | « tools/skiaserve/Response.h ('k') | tools/skiaserve/skiaserve.cpp » ('j') | 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 "Response.h" 8 #include "Response.h"
9 9
10 #include "microhttpd.h" 10 #include "microhttpd.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 if (setContentDisposition) { 71 if (setContentDisposition) {
72 MHD_add_response_header(response, "Content-Disposition", dispositionStri ng); 72 MHD_add_response_header(response, "Content-Disposition", dispositionStri ng);
73 } 73 }
74 74
75 int ret = MHD_queue_response(connection, MHD_HTTP_OK, response); 75 int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
76 MHD_destroy_response(response); 76 MHD_destroy_response(response);
77 return ret; 77 return ret;
78 } 78 }
79 79
80 int SendJSON(MHD_Connection* connection, Request* request, int n) {
81 SkCanvas* canvas = request->getCanvas();
82 SkDebugCanvas* debugCanvas = request->fDebugCanvas;
83 UrlDataManager* urlDataManager = &request->fUrlDataManager;
84 Json::Value root = debugCanvas->toJSON(*urlDataManager, n, canvas);
85 root["mode"] = Json::Value(request->fGPUEnabled ? "gpu" : "cpu");
86 SkDynamicMemoryWStream stream;
87 stream.writeText(Json::FastWriter().write(root).c_str());
88
89 SkAutoTUnref<SkData> data(stream.copyToData());
90 return SendData(connection, data, "application/json");
91 }
92
93 int SendTemplate(MHD_Connection* connection, bool redirect, const char* redirect Url) { 80 int SendTemplate(MHD_Connection* connection, bool redirect, const char* redirect Url) {
94 SkString debuggerTemplate = generate_template(SkString(FLAGS_source[0])); 81 SkString debuggerTemplate = generate_template(SkString(FLAGS_source[0]));
95 82
96 MHD_Response* response = MHD_create_response_from_buffer( 83 MHD_Response* response = MHD_create_response_from_buffer(
97 debuggerTemplate.size(), 84 debuggerTemplate.size(),
98 (void*) const_cast<char*>(debuggerTemplate.c_str()), 85 (void*) const_cast<char*>(debuggerTemplate.c_str()),
99 MHD_RESPMEM_MUST_COPY); 86 MHD_RESPMEM_MUST_COPY);
100 MHD_add_response_header (response, "Access-Control-Allow-Origin", "*"); 87 MHD_add_response_header (response, "Access-Control-Allow-Origin", "*");
101 88
102 int status = MHD_HTTP_OK; 89 int status = MHD_HTTP_OK;
103 90
104 if (redirect) { 91 if (redirect) {
105 MHD_add_response_header (response, "Location", redirectUrl); 92 MHD_add_response_header (response, "Location", redirectUrl);
106 status = MHD_HTTP_SEE_OTHER; 93 status = MHD_HTTP_SEE_OTHER;
107 } 94 }
108 95
109 int ret = MHD_queue_response(connection, status, response); 96 int ret = MHD_queue_response(connection, status, response);
110 MHD_destroy_response(response); 97 MHD_destroy_response(response);
111 return ret; 98 return ret;
112 } 99 }
113 100
114 } // namespace Response 101 } // namespace Response
OLDNEW
« no previous file with comments | « tools/skiaserve/Response.h ('k') | tools/skiaserve/skiaserve.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698