In a debug build, say in the tile: reponse also whether it was found in cache

Also, do the construction of the response string in
MasterProcessSession::sendTile() only when it is actually going to be
used.
This commit is contained in:
Tor Lillqvist 2016-04-20 18:44:25 +03:00
parent 842525c25c
commit 5a509f9211
2 changed files with 22 additions and 9 deletions

View file

@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "config.h"
#include <Poco/FileStream.h>
#include <Poco/JSON/Object.h>
#include <Poco/JSON/Parser.h>
@ -572,16 +574,22 @@ void MasterProcessSession::sendTile(const char *buffer, int length, StringTokeni
return;
}
const std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
std::vector<char> output;
output.reserve(4 * width * height);
output.resize(response.size());
std::memcpy(output.data(), response.data(), response.size());
std::unique_ptr<std::fstream> cachedTile = _docBroker->tileCache().lookupTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight);
if (cachedTile)
{
std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end());
#if ENABLE_DEBUG
response += " renderid=cached";
#endif
response += "\n";
std::vector<char> output;
output.reserve(4 * width * height);
output.resize(response.size());
std::memcpy(output.data(), response.data(), response.size());
assert(cachedTile->is_open());
cachedTile->seekg(0, std::ios_base::end);
size_t pos = output.size();
@ -691,6 +699,10 @@ void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*lengt
oss << " timestamp=" << reqTimestamp;
}
#if ENABLE_DEBUG
oss << " renderid=cached";
#endif
oss << "\n";
const std::string response = oss.str();

View file

@ -237,9 +237,10 @@ tile: part=<partNumber> width=<width> height=<height> tileposx=<xpos> tileposy=<
The parameters from the corresponding 'tile' command.
Additionally, in a debug build, the renderid is a unique
Additionally, in a debug build, the renderid is either a unique
identifier, different for each actual call to LibreOfficeKit to
render a tile.
render a tile, or the string 'cached' if the tile was found in the
cache.
Each LOK_CALLBACK_FOO_BAR callback causes a corresponding message to
the client, consisting of the FOO_BAR part in lowercase, without