<commit_before>/// \file base_handler.cxx
/// \ingroup CanvasPainter ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-06-29
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
/// is welcome!

#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wshadow"

#include "base_handler.h"

#include "TString.h"
#include "TError.h"
#include "THttpServer.h"
#include "THttpWSEngine.h"
#include "THttpCallArg.h"
// #include "TRootSniffer.h"

#include <sstream>
#include <string>

#include "include/base/cef_bind.h"
#include "include/cef_app.h"
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_helpers.h"

namespace {

//////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TCefWSEngine                                                         //
//                                                                      //
// Emulation of websocket with CEF messages                             //
// Allows to send data from ROOT server to JS client without            //
// involving special HTTP requests                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TCefWSEngine : public THttpWSEngine {
protected:
   CefRefPtr<CefMessageRouterBrowserSide::Callback> fCallback;

public:
   TCefWSEngine(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback)
      : THttpWSEngine(), fCallback(callback)
   {
   }

   virtual ~TCefWSEngine()
   {
      if (fCallback)
         fCallback->Failure(0, "close");
   }

   virtual UInt_t GetId() const
   {
      const void *ptr = (const void *)this;
      return TString::Hash((void *)&ptr, sizeof(void *));
   }

   virtual void ClearHandle() { fCallback = NULL; }

   virtual void Send(const void * /*buf*/, int /*len*/)
   {
      ::Error("TCefWSEngine::Send", "Should never be called, only text is supported");<commit_msg>webgui: preliminary binary data support for cefQuery messaging<commit_after>/// \file base_handler.cxx
/// \ingroup CanvasPainter ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-06-29
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
/// is welcome!

#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wshadow"

#include "base_handler.h"

#include "TString.h"
#include "TError.h"
#include "THttpServer.h"
#include "THttpWSEngine.h"
#include "THttpCallArg.h"
// #include "TRootSniffer.h"

#include <sstream>
#include <string>

#include "include/base/cef_bind.h"
#include "include/cef_app.h"
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_helpers.h"

namespace {

//////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TCefWSEngine                                                         //
//                                                                      //
// Emulation of websocket with CEF messages                             //
// Allows to send data from ROOT server to JS client without            //
// involving special HTTP requests                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TCefWSEngine : public THttpWSEngine {
protected:
   CefRefPtr<CefMessageRouterBrowserSide::Callback> fCallback;

public:
   TCefWSEngine(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback)
      : THttpWSEngine(), fCallback(callback)
   {
   }

   virtual ~TCefWSEngine()
   {
      if (fCallback)
         fCallback->Failure(0, "close");
   }

   virtual UInt_t GetId() const
   {
      const void *ptr = (const void *)this;
      return TString::Hash((void *)&ptr, sizeof(void *));
   }

   virtual void ClearHandle() { fCallback = NULL; }

   virtual void Send(const void * /*buf*/, int /*len*/)
   {
      ::Error("TCefWSEngine::Send", "Should never be called, only text is supported");
   }

   virtual void SendHeader(const char * /*hdr*/, const void * /*buf*/, int /*len*/)
   {
      ::Error("TCefWSEngine::SendHeader", "Should never be called, only text is supported");
{'fraction_non_alphanumeric': 0.20753551575046325, 'fraction_numerical': 0.004529544986617253, 'mean_word_length': 1.4773074961754207, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4805183', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1255, 'n_words': 321}