[Libreoffice-commits] online.git: common/Session.cpp common/Session.hpp common/Unit.hpp kit/ChildSession.cpp kit/ChildSession.hpp test/UnitFuzz.cpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/PrisonerSession.cpp wsd/PrisonerSession.hpp wsd/QueueHandler.hpp wsd/SenderQueue.hpp wsd/TileCache.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Dec 13 04:34:39 UTC 2016


 common/Session.cpp      |   30 +++++++++++++++---------------
 common/Session.hpp      |   18 +++++++++---------
 common/Unit.hpp         |    4 ++--
 kit/ChildSession.cpp    |    4 ++--
 kit/ChildSession.hpp    |    2 +-
 test/UnitFuzz.cpp       |    2 +-
 wsd/ClientSession.cpp   |    2 +-
 wsd/ClientSession.hpp   |    2 +-
 wsd/PrisonerSession.cpp |    2 +-
 wsd/PrisonerSession.hpp |    3 ++-
 wsd/QueueHandler.hpp    |    4 ++--
 wsd/SenderQueue.hpp     |    4 ++--
 wsd/TileCache.cpp       |    2 +-
 13 files changed, 40 insertions(+), 39 deletions(-)

New commits:
commit e60bc28a0059c25f3c30bd06dcdae8a391641ecc
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Dec 12 19:53:58 2016 -0500

    loolwsd: LOOLSession -> Session
    
    Change-Id: I94369480fb0a6789375dfe5610ada300e94b80eb
    Reviewed-on: https://gerrit.libreoffice.org/31930
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/common/Session.cpp b/common/Session.cpp
index 5ead325..f2c68ec 100644
--- a/common/Session.cpp
+++ b/common/Session.cpp
@@ -49,7 +49,7 @@ using Poco::Net::Socket;
 using Poco::Net::WebSocket;
 using Poco::StringTokenizer;
 
-LOOLSession::LOOLSession(const std::string& id, const Kind kind,
+Session::Session(const std::string& id, const Kind kind,
                          std::shared_ptr<LOOLWebSocket> ws) :
     _id(id),
     _kind(kind),
@@ -67,11 +67,11 @@ LOOLSession::LOOLSession(const std::string& id, const Kind kind,
 {
 }
 
-LOOLSession::~LOOLSession()
+Session::~Session()
 {
 }
 
-bool LOOLSession::sendTextFrame(const char* buffer, const int length)
+bool Session::sendTextFrame(const char* buffer, const int length)
 {
     LOG_TRC(getName() << ": Send: " << getAbbreviatedMessage(buffer, length));
     try
@@ -89,14 +89,14 @@ bool LOOLSession::sendTextFrame(const char* buffer, const int length)
     }
     catch (const Exception& exc)
     {
-        LOG_ERR("LOOLSession::sendTextFrame: Exception: " << exc.displayText() <<
+        LOG_ERR("Session::sendTextFrame: Exception: " << exc.displayText() <<
                 (exc.nested() ? "( " + exc.nested()->displayText() + ")" : ""));
     }
 
     return false;
 }
 
-bool LOOLSession::sendBinaryFrame(const char *buffer, int length)
+bool Session::sendBinaryFrame(const char *buffer, int length)
 {
     LOG_TRC(getName() << ": Send: " << std::to_string(length) << " bytes.");
     try
@@ -114,14 +114,14 @@ bool LOOLSession::sendBinaryFrame(const char *buffer, int length)
     }
     catch (const Exception& exc)
     {
-        LOG_ERR("LOOLSession::sendBinaryFrame: Exception: " << exc.displayText() <<
+        LOG_ERR("Session::sendBinaryFrame: Exception: " << exc.displayText() <<
                 (exc.nested() ? "( " + exc.nested()->displayText() + ")" : ""));
     }
 
     return false;
 }
 
-void LOOLSession::parseDocOptions(const StringTokenizer& tokens, int& part, std::string& timestamp)
+void Session::parseDocOptions(const StringTokenizer& tokens, int& part, std::string& timestamp)
 {
     // First token is the "load" command itself.
     size_t offset = 1;
@@ -178,7 +178,7 @@ void LOOLSession::parseDocOptions(const StringTokenizer& tokens, int& part, std:
     }
 }
 
-void LOOLSession::disconnect()
+void Session::disconnect()
 {
     try
     {
@@ -190,19 +190,19 @@ void LOOLSession::disconnect()
     }
     catch (const IOException& exc)
     {
-        LOG_ERR("LOOLSession::disconnect: Exception: " << exc.displayText() <<
+        LOG_ERR("Session::disconnect: Exception: " << exc.displayText() <<
                 (exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
     }
 }
 
-bool LOOLSession::handleDisconnect()
+bool Session::handleDisconnect()
 {
     _disconnected = true;
     IoUtil::shutdownWebSocket(_ws);
     return false;
 }
 
-void LOOLSession::shutdown(Poco::UInt16 statusCode, const std::string& statusMessage)
+void Session::shutdown(Poco::UInt16 statusCode, const std::string& statusMessage)
 {
     if (_ws)
     {
@@ -213,13 +213,13 @@ void LOOLSession::shutdown(Poco::UInt16 statusCode, const std::string& statusMes
         }
         catch (const Poco::Exception &exc)
         {
-            LOG_WRN("LOOLSession::shutdown LOOLWebSocket: Exception: " <<
+            LOG_WRN("Session::shutdown LOOLWebSocket: Exception: " <<
                     exc.displayText() << (exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
         }
     }
 }
 
-bool LOOLSession::handleInput(const char *buffer, int length)
+bool Session::handleInput(const char *buffer, int length)
 {
     assert(buffer != nullptr);
 
@@ -238,14 +238,14 @@ bool LOOLSession::handleInput(const char *buffer, int length)
     }
     catch (const Exception& exc)
     {
-        LOG_ERR("LOOLSession::handleInput: Exception while handling [" <<
+        LOG_ERR("Session::handleInput: Exception while handling [" <<
                 getAbbreviatedMessage(buffer, length) <<
                 "] in " << getName() << ": " << exc.displayText() <<
                 (exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
     }
     catch (const std::exception& exc)
     {
-        LOG_ERR("LOOLSession::handleInput: Exception while handling [" <<
+        LOG_ERR("Session::handleInput: Exception while handling [" <<
                 getAbbreviatedMessage(buffer, length) << "]: " << exc.what());
     }
 
diff --git a/common/Session.hpp b/common/Session.hpp
index fe0fc3b..617348a 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -7,8 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#ifndef INCLUDED_LOOLSESSION_HPP
-#define INCLUDED_LOOLSESSION_HPP
+#ifndef INCLUDED_SESSION_HPP
+#define INCLUDED_SESSION_HPP
 
 #include <atomic>
 #include <cassert>
@@ -29,7 +29,7 @@
 #include "TileCache.hpp"
 
 /// Base class of a LOOLWebSocket session.
-class LOOLSession
+class Session
 {
 public:
     /// We have three kinds of Websocket sessions
@@ -82,9 +82,9 @@ public:
     bool isHeadless() const { return _ws == nullptr; }
 
 protected:
-    LOOLSession(const std::string& id, const Kind kind,
+    Session(const std::string& id, const Kind kind,
                 std::shared_ptr<LOOLWebSocket> ws);
-    virtual ~LOOLSession();
+    virtual ~Session();
 
     /// 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);
@@ -159,15 +159,15 @@ protected:
 };
 
 template <typename charT, typename traits>
-inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, LOOLSession::Kind kind)
+inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, Session::Kind kind)
 {
     switch (kind)
     {
-    case LOOLSession::Kind::ToClient:
+    case Session::Kind::ToClient:
         return stream << "TO_CLIENT";
-    case LOOLSession::Kind::ToPrisoner:
+    case Session::Kind::ToPrisoner:
         return stream << "TO_PRISONER";
-    case LOOLSession::Kind::ToMaster:
+    case Session::Kind::ToMaster:
         return stream << "TO_MASTER";
     default:
         assert(false);
diff --git a/common/Unit.hpp b/common/Unit.hpp
index 40f20b3..9bcb86b 100644
--- a/common/Unit.hpp
+++ b/common/Unit.hpp
@@ -38,7 +38,7 @@ namespace Poco
     }
 }
 
-class LOOLSession;
+class Session;
 class StorageBase;
 
 typedef UnitBase *(CreateUnitHooksFunction)();
@@ -90,7 +90,7 @@ public:
     virtual void returnValue(int& /* retValue */);
 
     /// Input message either for WSD or Kit
-    virtual bool filterSessionInput(LOOLSession *, const char */* buffer */,
+    virtual bool filterSessionInput(Session *, const char */* buffer */,
                                     int /* length */,
                                     std::unique_ptr< std::vector<char> > & /* replace */)
     {
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 3022344..9df2b56 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -37,7 +37,7 @@ std::recursive_mutex ChildSession::Mutex;
 ChildSession::ChildSession(const std::string& id,
                            const std::string& jailId,
                            IDocumentManager& docManager) :
-    LOOLSession(id, Kind::ToMaster, nullptr),
+    Session(id, Kind::ToMaster, nullptr),
     _jailId(jailId),
     _docManager(docManager),
     _viewId(-1),
@@ -68,7 +68,7 @@ void ChildSession::disconnect()
             LOG_WRN("Skipping unload on incomplete view.");
         }
 
-        LOOLSession::disconnect();
+        Session::disconnect();
     }
 }
 
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 665e09f..19005ac 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -61,7 +61,7 @@ public:
 };
 
 /// Represents a session to the WSD process, in a Kit process. Note that this is not a singleton.
-class ChildSession final : public LOOLSession
+class ChildSession final : public Session
 {
 public:
     /// Create a new ChildSession
diff --git a/test/UnitFuzz.cpp b/test/UnitFuzz.cpp
index 6460962..64a34b2 100644
--- a/test/UnitFuzz.cpp
+++ b/test/UnitFuzz.cpp
@@ -66,7 +66,7 @@ public:
      * Note: Fuzzers are fragile and their performance is rather
      * sensitive. Please avoid random code tweaking in this method.
      */
-    virtual bool filterSessionInput(LOOLSession *, const char *buffer,
+    virtual bool filterSessionInput(Session *, const char *buffer,
                                     int length,
                                     std::unique_ptr< std::vector<char> > &replace) override
     {
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 9e01217..3befec5 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -39,7 +39,7 @@ ClientSession::ClientSession(const std::string& id,
                              const std::shared_ptr<DocumentBroker>& docBroker,
                              const Poco::URI& uriPublic,
                              const bool readOnly) :
-    LOOLSession(id, Kind::ToClient, ws),
+    Session(id, Kind::ToClient, ws),
     _docBroker(docBroker),
     _uriPublic(uriPublic),
     _isReadOnly(readOnly),
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 3703593..25007a4 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -19,7 +19,7 @@ class DocumentBroker;
 class PrisonerSession;
 
 /// Represents a session to a LOOL client, in the WSD process.
-class ClientSession final : public LOOLSession, public std::enable_shared_from_this<ClientSession>
+class ClientSession final : public Session, public std::enable_shared_from_this<ClientSession>
 {
 public:
     ClientSession(const std::string& id,
diff --git a/wsd/PrisonerSession.cpp b/wsd/PrisonerSession.cpp
index 3e93bee..2bd9c41 100644
--- a/wsd/PrisonerSession.cpp
+++ b/wsd/PrisonerSession.cpp
@@ -36,7 +36,7 @@ using Poco::StringTokenizer;
 
 PrisonerSession::PrisonerSession(std::shared_ptr<ClientSession> clientSession,
                                  std::shared_ptr<DocumentBroker> docBroker) :
-    LOOLSession(clientSession->getId(), Kind::ToPrisoner, nullptr),
+    Session(clientSession->getId(), Kind::ToPrisoner, nullptr),
     _docBroker(std::move(docBroker)),
     _peer(clientSession),
     _curPart(0)
diff --git a/wsd/PrisonerSession.hpp b/wsd/PrisonerSession.hpp
index aee1266..4085fb3 100644
--- a/wsd/PrisonerSession.hpp
+++ b/wsd/PrisonerSession.hpp
@@ -18,7 +18,8 @@ class ClientSession;
 /// Represents an internal session to a Kit process, in the WSD process.
 /// This doesn't really have a direct connection to any Kit process, rather
 /// all communication to said Kit process is really handled by DocumentBroker.
-class PrisonerSession final : public LOOLSession, public std::enable_shared_from_this<PrisonerSession>
+class PrisonerSession final : public Session,
+                              public std::enable_shared_from_this<PrisonerSession>
 {
 public:
     PrisonerSession(std::shared_ptr<ClientSession> clientSession,
diff --git a/wsd/QueueHandler.hpp b/wsd/QueueHandler.hpp
index 445b91e..8ef3f62 100644
--- a/wsd/QueueHandler.hpp
+++ b/wsd/QueueHandler.hpp
@@ -19,7 +19,7 @@ class QueueHandler : public Poco::Runnable
 {
 public:
     QueueHandler(std::shared_ptr<MessageQueue> queue,
-                 const std::shared_ptr<LOOLSession>& session,
+                 const std::shared_ptr<Session>& session,
                  const std::string& name):
         _queue(std::move(queue)),
         _session(session),
@@ -61,7 +61,7 @@ public:
 
 private:
     std::shared_ptr<MessageQueue> _queue;
-    std::shared_ptr<LOOLSession> _session;
+    std::shared_ptr<Session> _session;
     const std::string _name;
 };
 
diff --git a/wsd/SenderQueue.hpp b/wsd/SenderQueue.hpp
index 11b89ee..3dc2856 100644
--- a/wsd/SenderQueue.hpp
+++ b/wsd/SenderQueue.hpp
@@ -43,7 +43,7 @@ private:
 
 struct SendItem
 {
-    std::weak_ptr<LOOLSession> Session;
+    std::weak_ptr<::Session> Session;
     std::shared_ptr<MessagePayload> Data;
     std::chrono::steady_clock::time_point BirthTime;
 };
@@ -62,7 +62,7 @@ public:
          _cv.notify_all();
     }
 
-    size_t enqueue(const std::weak_ptr<LOOLSession>& session,
+    size_t enqueue(const std::weak_ptr<Session>& session,
                    const std::shared_ptr<MessagePayload>& data)
     {
         SendItem item = { session, data, std::chrono::steady_clock::now() };
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 0000715..010ce00 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -436,7 +436,7 @@ void TileCache::saveLastModified(const Timestamp& timestamp)
 // FIXME: to be further simplified when we centralize tile messages.
 void TileCache::subscribeToTileRendering(const TileDesc& tile, const std::shared_ptr<ClientSession> &subscriber)
 {
-    assert(subscriber->getKind() == LOOLSession::Kind::ToClient);
+    assert(subscriber->getKind() == Session::Kind::ToClient);
 
     std::ostringstream oss;
     oss << '(' << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ')';


More information about the Libreoffice-commits mailing list