loolwsd/ChildProcessSession.hpp | 11 -- loolwsd/ClientSession.hpp | 15 +-- loolwsd/LOOLSession.hpp | 8 - loolwsd/MasterProcessSession.cpp | 186 --------------------------------------- loolwsd/MasterProcessSession.hpp | 12 -- loolwsd/PrisonerSession.hpp | 29 ------ 6 files changed, 10 insertions(+), 251 deletions(-)
New commits: commit cf26d9191ccfe49590fe48be51758099b937a15a Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Mon May 16 19:30:03 2016 -0400 loolwsd: MasterProcessSession splitting: member function scope Change-Id: I3fa43f761ccc93d52badff346941de2a8cd9de03 Reviewed-on: https://gerrit.libreoffice.org/25043 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/ChildProcessSession.hpp b/loolwsd/ChildProcessSession.hpp index 7b6275e..ab552d3 100644 --- a/loolwsd/ChildProcessSession.hpp +++ b/loolwsd/ChildProcessSession.hpp @@ -44,12 +44,8 @@ public: OnUnloadCallback onUnload); virtual ~ChildProcessSession(); - virtual bool getStatus(const char *buffer, int length) override; - - virtual bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - - virtual bool getPartPageRectangles(const char *buffer, int length) override; - + bool getStatus(const char *buffer, int length); + bool getPartPageRectangles(const char *buffer, int length); virtual void disconnect() override; int getViewId() const { return _viewId; } @@ -67,7 +63,8 @@ public: protected: bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens); - virtual void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens) override; + void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens); + bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens); bool clientZoom(const char *buffer, int length, Poco::StringTokenizer& tokens); bool clientVisibleArea(const char *buffer, int length, Poco::StringTokenizer& tokens); diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp index 1f4bb74..8bc7bec 100644 --- a/loolwsd/ClientSession.hpp +++ b/loolwsd/ClientSession.hpp @@ -52,19 +52,16 @@ public: private: virtual bool _handleInput(const char *buffer, int length) override; - virtual bool getStatus(const char *buffer, int length) override; - - virtual bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - - virtual bool getPartPageRectangles(const char *buffer, int length) override; bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens); - virtual void sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens); - - virtual void sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens); + bool getStatus(const char *buffer, int length); + bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens); + bool getPartPageRectangles(const char *buffer, int length); - virtual void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens) override; + void sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens); + void sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens); + void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens); private: diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp index e28fd4b..137a0d9 100644 --- a/loolwsd/LOOLSession.hpp +++ b/loolwsd/LOOLSession.hpp @@ -42,12 +42,6 @@ public: void sendTextFrame(const std::string& text); void sendBinaryFrame(const char *buffer, int length); - virtual bool getStatus(const char *buffer, int length) = 0; - - virtual bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens) = 0; - - virtual bool getPartPageRectangles(const char *buffer, int length) = 0; - bool handleInput(const char *buffer, int length); /// Invoked when we want to disconnect a session. @@ -85,8 +79,6 @@ protected: /// Parses the options of the "load" command, shared between MasterProcessSession::loadDocument() and ChildProcessSession::loadDocument(). void parseDocOptions(const Poco::StringTokenizer& tokens, int& part, std::string& timestamp); - virtual void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens) = 0; - void updateLastActivityTime() { _lastActivityTime = std::chrono::steady_clock::now(); diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index f8b94d7..9c491bb 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -49,32 +49,6 @@ MasterProcessSession::~MasterProcessSession() { } -bool MasterProcessSession::getStatus(const char *buffer, int length) -{ - const std::string status = _docBroker->tileCache().getTextFile("status.txt"); - if (!status.empty()) - { - sendTextFrame(status); - - // And let clients know if they hold the edit lock. - std::string message = "editlock: "; - message += std::to_string(isEditLocked()); - Log::debug("Forwarding [" + message + "] in response to status."); - sendTextFrame(message); - - return true; - } - - if (_peer.expired()) - { - Log::trace("Dispatching child to handle [getStatus]."); - dispatchChild(); - } - - forwardToPeer(buffer, length); - return true; -} - void MasterProcessSession::setEditLock(const bool value) { // Update the sate and forward to child. @@ -83,166 +57,6 @@ void MasterProcessSession::setEditLock(const bool value) forwardToPeer(msg.data(), msg.size()); } -bool MasterProcessSession::getCommandValues(const char *buffer, int length, StringTokenizer& tokens) -{ - std::string command; - if (tokens.count() != 2 || !getTokenString(tokens[1], "command", command)) - { - sendTextFrame("error: cmd=commandvalues kind=syntax"); - return false; - } - - const std::string cmdValues = _docBroker->tileCache().getTextFile("cmdValues" + command + ".txt"); - if (cmdValues.size() > 0) - { - sendTextFrame(cmdValues); - return true; - } - - if (_peer.expired()) - dispatchChild(); - forwardToPeer(buffer, length); - return true; -} - -bool MasterProcessSession::getPartPageRectangles(const char *buffer, int length) -{ - const std::string partPageRectangles = _docBroker->tileCache().getTextFile("partpagerectangles.txt"); - if (partPageRectangles.size() > 0) - { - sendTextFrame(partPageRectangles); - return true; - } - - if (_peer.expired()) - dispatchChild(); - forwardToPeer(buffer, length); - return true; -} - -void MasterProcessSession::sendFontRendering(const char *buffer, int length, StringTokenizer& tokens) -{ - std::string font; - if (tokens.count() < 2 || - !getTokenString(tokens[1], "font", font)) - { - sendTextFrame("error: cmd=renderfont kind=syntax"); - return; - } - - const std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n"; - - std::vector<char> output; - output.resize(response.size()); - std::memcpy(output.data(), response.data(), response.size()); - - std::unique_ptr<std::fstream> cachedRendering = _docBroker->tileCache().lookupRendering(font, "font"); - if (cachedRendering && cachedRendering->is_open()) - { - cachedRendering->seekg(0, std::ios_base::end); - size_t pos = output.size(); - std::streamsize size = cachedRendering->tellg(); - output.resize(pos + size); - cachedRendering->seekg(0, std::ios_base::beg); - cachedRendering->read(output.data() + pos, size); - cachedRendering->close(); - - sendBinaryFrame(output.data(), output.size()); - return; - } - - if (_peer.expired()) - dispatchChild(); - forwardToPeer(buffer, length); -} - -void MasterProcessSession::sendTile(const char * /*buffer*/, int /*length*/, StringTokenizer& tokens) -{ - try - { - auto tileDesc = TileDesc::parse(tokens); - _docBroker->handleTileRequest(tileDesc, shared_from_this()); - } - catch (const std::exception& exc) - { - Log::error(std::string("Failed to process tile command: ") + exc.what() + "."); - sendTextFrame("error: cmd=tile kind=invalid"); - } -} - -void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) -{ - int part, pixelWidth, pixelHeight, tileWidth, tileHeight; - std::string tilePositionsX, tilePositionsY; - if (tokens.count() < 8 || - !getTokenInteger(tokens[1], "part", part) || - !getTokenInteger(tokens[2], "width", pixelWidth) || - !getTokenInteger(tokens[3], "height", pixelHeight) || - !getTokenString (tokens[4], "tileposx", tilePositionsX) || - !getTokenString (tokens[5], "tileposy", tilePositionsY) || - !getTokenInteger(tokens[6], "tilewidth", tileWidth) || - !getTokenInteger(tokens[7], "tileheight", tileHeight)) - { - sendTextFrame("error: cmd=tilecombine kind=syntax"); - return; - } - - if (part < 0 || pixelWidth <= 0 || pixelHeight <= 0 || - tileWidth <= 0 || tileHeight <= 0 || - tilePositionsX.empty() || tilePositionsY.empty()) - { - sendTextFrame("error: cmd=tilecombine kind=invalid"); - return; - } - - std::string reqTimestamp; - size_t index = 8; - if (tokens.count() > index && tokens[index].find("timestamp") == 0) - { - getTokenString(tokens[index], "timestamp", reqTimestamp); - ++index; - } - - int id = -1; - if (tokens.count() > index && tokens[index].find("id") == 0) - { - getTokenInteger(tokens[index], "id", id); - ++index; - } - - StringTokenizer positionXtokens(tilePositionsX, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - StringTokenizer positionYtokens(tilePositionsY, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - - size_t numberOfPositions = positionYtokens.count(); - - // check that number of positions for X and Y is the same - if (numberOfPositions != positionXtokens.count()) - { - sendTextFrame("error: cmd=tilecombine kind=invalid"); - return; - } - - for (size_t i = 0; i < numberOfPositions; ++i) - { - int x = 0; - if (!stringToInteger(positionXtokens[i], x)) - { - sendTextFrame("error: cmd=tilecombine kind=syntax"); - return; - } - - int y = 0; - if (!stringToInteger(positionYtokens[i], y)) - { - sendTextFrame("error: cmd=tilecombine kind=syntax"); - return; - } - - const TileDesc tile(part, pixelWidth, pixelHeight, x, y, tileWidth, tileHeight); - _docBroker->handleTileRequest(tile, shared_from_this()); - } -} - void MasterProcessSession::dispatchChild() { std::ostringstream oss; diff --git a/loolwsd/MasterProcessSession.hpp b/loolwsd/MasterProcessSession.hpp index 83437c4..5dc23db 100644 --- a/loolwsd/MasterProcessSession.hpp +++ b/loolwsd/MasterProcessSession.hpp @@ -29,12 +29,6 @@ class MasterProcessSession : public LOOLSession, public std::enable_shared_from_ std::shared_ptr<BasicTileQueue> queue); virtual ~MasterProcessSession(); - virtual bool getStatus(const char *buffer, int length) override; - - virtual bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - - virtual bool getPartPageRectangles(const char *buffer, int length) override; - std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker; } std::shared_ptr<BasicTileQueue> getQueue() const { return _queue; } @@ -50,12 +44,6 @@ public: bool _bLoadError = false; protected: - virtual void sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens); - - virtual void sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens); - - virtual void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - void dispatchChild(); void forwardToPeer(const char *buffer, int length); diff --git a/loolwsd/PrisonerSession.hpp b/loolwsd/PrisonerSession.hpp index 65418ee..5d8fddd 100644 --- a/loolwsd/PrisonerSession.hpp +++ b/loolwsd/PrisonerSession.hpp @@ -38,26 +38,6 @@ private: std::weak_ptr<ClientSession> _peer; #if 0 - public: - MasterProcessSession(const std::string& id, - const Kind kind, - std::shared_ptr<Poco::Net::WebSocket> ws, - std::shared_ptr<DocumentBroker> docBroker, - std::shared_ptr<BasicTileQueue> queue); - virtual ~MasterProcessSession(); - - virtual bool getStatus(const char *buffer, int length) override; - - virtual bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - - virtual bool getPartPageRectangles(const char *buffer, int length) override; - - /** - * Return the URL of the saved-as document when it's ready. If called - * before it's ready, the call blocks till then. - */ - std::string getSaveAs(); - std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker; } std::shared_ptr<BasicTileQueue> getQueue() const { return _queue; } @@ -68,15 +48,6 @@ public: // Raise this flag on ToClient from ToPrisoner to let ToClient know of load failures bool _bLoadError = false; - protected: - virtual bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - - virtual void sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens); - - virtual void sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens); - - virtual void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens) override; - private: void dispatchChild(); void forwardToPeer(const char *buffer, int length); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits