mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Add CefServer API for handling HTTP/WebSocket requests (issue #2278)
This commit is contained in:
		
							
								
								
									
										301
									
								
								libcef_dll/cpptoc/server_cpptoc.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										301
									
								
								libcef_dll/cpptoc/server_cpptoc.cc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,301 @@
 | 
			
		||||
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
 | 
			
		||||
// reserved. Use of this source code is governed by a BSD-style license that
 | 
			
		||||
// can be found in the LICENSE file.
 | 
			
		||||
//
 | 
			
		||||
// ---------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// This file was generated by the CEF translator tool. If making changes by
 | 
			
		||||
// hand only do so within the body of existing method and function
 | 
			
		||||
// implementations. See the translator.README.txt file in the tools directory
 | 
			
		||||
// for more information.
 | 
			
		||||
//
 | 
			
		||||
// $hash=aa194ad76a31d7a0497333d78595e8b349a0551e$
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "libcef_dll/cpptoc/server_cpptoc.h"
 | 
			
		||||
#include "libcef_dll/cpptoc/task_runner_cpptoc.h"
 | 
			
		||||
#include "libcef_dll/ctocpp/server_handler_ctocpp.h"
 | 
			
		||||
#include "libcef_dll/transfer_util.h"
 | 
			
		||||
 | 
			
		||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
 | 
			
		||||
 | 
			
		||||
CEF_EXPORT void cef_server_create(const cef_string_t* address,
 | 
			
		||||
                                  uint16 port,
 | 
			
		||||
                                  int backlog,
 | 
			
		||||
                                  struct _cef_server_handler_t* handler) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  // Verify param: address; type: string_byref_const
 | 
			
		||||
  DCHECK(address);
 | 
			
		||||
  if (!address)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: handler; type: refptr_diff
 | 
			
		||||
  DCHECK(handler);
 | 
			
		||||
  if (!handler)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServer::CreateServer(CefString(address), port, backlog,
 | 
			
		||||
                          CefServerHandlerCToCpp::Wrap(handler));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
 | 
			
		||||
// MEMBER FUNCTIONS - Body may be edited by hand.
 | 
			
		||||
 | 
			
		||||
struct _cef_task_runner_t* CEF_CALLBACK
 | 
			
		||||
server_get_task_runner(struct _cef_server_t* self) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefRefPtr<CefTaskRunner> _retval =
 | 
			
		||||
      CefServerCppToC::Get(self)->GetTaskRunner();
 | 
			
		||||
 | 
			
		||||
  // Return type: refptr_same
 | 
			
		||||
  return CefTaskRunnerCppToC::Wrap(_retval);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK server_shutdown(struct _cef_server_t* self) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->Shutdown();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CEF_CALLBACK server_is_running(struct _cef_server_t* self) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  bool _retval = CefServerCppToC::Get(self)->IsRunning();
 | 
			
		||||
 | 
			
		||||
  // Return type: bool
 | 
			
		||||
  return _retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cef_string_userfree_t CEF_CALLBACK
 | 
			
		||||
server_get_address(struct _cef_server_t* self) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefString _retval = CefServerCppToC::Get(self)->GetAddress();
 | 
			
		||||
 | 
			
		||||
  // Return type: string
 | 
			
		||||
  return _retval.DetachToUserFree();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CEF_CALLBACK server_has_connection(struct _cef_server_t* self) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  bool _retval = CefServerCppToC::Get(self)->HasConnection();
 | 
			
		||||
 | 
			
		||||
  // Return type: bool
 | 
			
		||||
  return _retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CEF_CALLBACK server_is_valid_connection(struct _cef_server_t* self,
 | 
			
		||||
                                            int connection_id) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  bool _retval = CefServerCppToC::Get(self)->IsValidConnection(connection_id);
 | 
			
		||||
 | 
			
		||||
  // Return type: bool
 | 
			
		||||
  return _retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK server_send_http200response(struct _cef_server_t* self,
 | 
			
		||||
                                              int connection_id,
 | 
			
		||||
                                              const cef_string_t* content_type,
 | 
			
		||||
                                              const void* data,
 | 
			
		||||
                                              size_t data_size) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: content_type; type: string_byref_const
 | 
			
		||||
  DCHECK(content_type);
 | 
			
		||||
  if (!content_type)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: data; type: simple_byaddr
 | 
			
		||||
  DCHECK(data);
 | 
			
		||||
  if (!data)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->SendHttp200Response(
 | 
			
		||||
      connection_id, CefString(content_type), data, data_size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK server_send_http404response(struct _cef_server_t* self,
 | 
			
		||||
                                              int connection_id) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->SendHttp404Response(connection_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_send_http500response(struct _cef_server_t* self,
 | 
			
		||||
                            int connection_id,
 | 
			
		||||
                            const cef_string_t* error_message) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: error_message; type: string_byref_const
 | 
			
		||||
  DCHECK(error_message);
 | 
			
		||||
  if (!error_message)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->SendHttp500Response(connection_id,
 | 
			
		||||
                                                  CefString(error_message));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_send_http_response(struct _cef_server_t* self,
 | 
			
		||||
                          int connection_id,
 | 
			
		||||
                          int response_code,
 | 
			
		||||
                          const cef_string_t* content_type,
 | 
			
		||||
                          int64 content_length,
 | 
			
		||||
                          cef_string_multimap_t extra_headers) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: content_type; type: string_byref_const
 | 
			
		||||
  DCHECK(content_type);
 | 
			
		||||
  if (!content_type)
 | 
			
		||||
    return;
 | 
			
		||||
  // Unverified params: extra_headers
 | 
			
		||||
 | 
			
		||||
  // Translate param: extra_headers; type: string_map_multi_byref_const
 | 
			
		||||
  std::multimap<CefString, CefString> extra_headersMultimap;
 | 
			
		||||
  transfer_string_multimap_contents(extra_headers, extra_headersMultimap);
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->SendHttpResponse(
 | 
			
		||||
      connection_id, response_code, CefString(content_type), content_length,
 | 
			
		||||
      extra_headersMultimap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK server_send_raw_data(struct _cef_server_t* self,
 | 
			
		||||
                                       int connection_id,
 | 
			
		||||
                                       const void* data,
 | 
			
		||||
                                       size_t data_size) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: data; type: simple_byaddr
 | 
			
		||||
  DCHECK(data);
 | 
			
		||||
  if (!data)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->SendRawData(connection_id, data, data_size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK server_close_connection(struct _cef_server_t* self,
 | 
			
		||||
                                          int connection_id) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->CloseConnection(connection_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK server_send_web_socket_message(struct _cef_server_t* self,
 | 
			
		||||
                                                 int connection_id,
 | 
			
		||||
                                                 const void* data,
 | 
			
		||||
                                                 size_t data_size) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: data; type: simple_byaddr
 | 
			
		||||
  DCHECK(data);
 | 
			
		||||
  if (!data)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerCppToC::Get(self)->SendWebSocketMessage(connection_id, data,
 | 
			
		||||
                                                   data_size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace
 | 
			
		||||
 | 
			
		||||
// CONSTRUCTOR - Do not edit by hand.
 | 
			
		||||
 | 
			
		||||
CefServerCppToC::CefServerCppToC() {
 | 
			
		||||
  GetStruct()->get_task_runner = server_get_task_runner;
 | 
			
		||||
  GetStruct()->shutdown = server_shutdown;
 | 
			
		||||
  GetStruct()->is_running = server_is_running;
 | 
			
		||||
  GetStruct()->get_address = server_get_address;
 | 
			
		||||
  GetStruct()->has_connection = server_has_connection;
 | 
			
		||||
  GetStruct()->is_valid_connection = server_is_valid_connection;
 | 
			
		||||
  GetStruct()->send_http200response = server_send_http200response;
 | 
			
		||||
  GetStruct()->send_http404response = server_send_http404response;
 | 
			
		||||
  GetStruct()->send_http500response = server_send_http500response;
 | 
			
		||||
  GetStruct()->send_http_response = server_send_http_response;
 | 
			
		||||
  GetStruct()->send_raw_data = server_send_raw_data;
 | 
			
		||||
  GetStruct()->close_connection = server_close_connection;
 | 
			
		||||
  GetStruct()->send_web_socket_message = server_send_web_socket_message;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
CefRefPtr<CefServer>
 | 
			
		||||
CefCppToCRefCounted<CefServerCppToC, CefServer, cef_server_t>::UnwrapDerived(
 | 
			
		||||
    CefWrapperType type,
 | 
			
		||||
    cef_server_t* s) {
 | 
			
		||||
  NOTREACHED() << "Unexpected class type: " << type;
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if DCHECK_IS_ON()
 | 
			
		||||
template <>
 | 
			
		||||
base::AtomicRefCount
 | 
			
		||||
    CefCppToCRefCounted<CefServerCppToC, CefServer, cef_server_t>::DebugObjCt
 | 
			
		||||
        ATOMIC_DECLARATION;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
CefWrapperType CefCppToCRefCounted<CefServerCppToC, CefServer, cef_server_t>::
 | 
			
		||||
    kWrapperType = WT_SERVER;
 | 
			
		||||
							
								
								
									
										35
									
								
								libcef_dll/cpptoc/server_cpptoc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								libcef_dll/cpptoc/server_cpptoc.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
 | 
			
		||||
// reserved. Use of this source code is governed by a BSD-style license that
 | 
			
		||||
// can be found in the LICENSE file.
 | 
			
		||||
//
 | 
			
		||||
// ---------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// This file was generated by the CEF translator tool. If making changes by
 | 
			
		||||
// hand only do so within the body of existing method and function
 | 
			
		||||
// implementations. See the translator.README.txt file in the tools directory
 | 
			
		||||
// for more information.
 | 
			
		||||
//
 | 
			
		||||
// $hash=0f4a3453e43f2aa85bfdfaed15772373c43eccb8$
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_SERVER_CPPTOC_H_
 | 
			
		||||
#define CEF_LIBCEF_DLL_CPPTOC_SERVER_CPPTOC_H_
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#if !defined(BUILDING_CEF_SHARED)
 | 
			
		||||
#error This file can be included DLL-side only
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "include/capi/cef_server_capi.h"
 | 
			
		||||
#include "include/cef_server.h"
 | 
			
		||||
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
 | 
			
		||||
 | 
			
		||||
// Wrap a C++ class with a C structure.
 | 
			
		||||
// This class may be instantiated and accessed DLL-side only.
 | 
			
		||||
class CefServerCppToC
 | 
			
		||||
    : public CefCppToCRefCounted<CefServerCppToC, CefServer, cef_server_t> {
 | 
			
		||||
 public:
 | 
			
		||||
  CefServerCppToC();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif  // CEF_LIBCEF_DLL_CPPTOC_SERVER_CPPTOC_H_
 | 
			
		||||
							
								
								
									
										244
									
								
								libcef_dll/cpptoc/server_handler_cpptoc.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										244
									
								
								libcef_dll/cpptoc/server_handler_cpptoc.cc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,244 @@
 | 
			
		||||
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
 | 
			
		||||
// reserved. Use of this source code is governed by a BSD-style license that
 | 
			
		||||
// can be found in the LICENSE file.
 | 
			
		||||
//
 | 
			
		||||
// ---------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// This file was generated by the CEF translator tool. If making changes by
 | 
			
		||||
// hand only do so within the body of existing method and function
 | 
			
		||||
// implementations. See the translator.README.txt file in the tools directory
 | 
			
		||||
// for more information.
 | 
			
		||||
//
 | 
			
		||||
// $hash=36e97984dadd60442c0eba6189c08b6512d05f78$
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "libcef_dll/cpptoc/server_handler_cpptoc.h"
 | 
			
		||||
#include "libcef_dll/ctocpp/callback_ctocpp.h"
 | 
			
		||||
#include "libcef_dll/ctocpp/request_ctocpp.h"
 | 
			
		||||
#include "libcef_dll/ctocpp/server_ctocpp.h"
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
 | 
			
		||||
// MEMBER FUNCTIONS - Body may be edited by hand.
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_server_created(struct _cef_server_handler_t* self,
 | 
			
		||||
                                 cef_server_t* server) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnServerCreated(
 | 
			
		||||
      CefServerCToCpp::Wrap(server));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_server_destroyed(struct _cef_server_handler_t* self,
 | 
			
		||||
                                   cef_server_t* server) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnServerDestroyed(
 | 
			
		||||
      CefServerCToCpp::Wrap(server));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_client_connected(struct _cef_server_handler_t* self,
 | 
			
		||||
                                   cef_server_t* server,
 | 
			
		||||
                                   int connection_id) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnClientConnected(
 | 
			
		||||
      CefServerCToCpp::Wrap(server), connection_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_client_disconnected(struct _cef_server_handler_t* self,
 | 
			
		||||
                                      cef_server_t* server,
 | 
			
		||||
                                      int connection_id) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnClientDisconnected(
 | 
			
		||||
      CefServerCToCpp::Wrap(server), connection_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_http_request(struct _cef_server_handler_t* self,
 | 
			
		||||
                               cef_server_t* server,
 | 
			
		||||
                               int connection_id,
 | 
			
		||||
                               const cef_string_t* client_address,
 | 
			
		||||
                               cef_request_t* request) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: client_address; type: string_byref_const
 | 
			
		||||
  DCHECK(client_address);
 | 
			
		||||
  if (!client_address)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: request; type: refptr_diff
 | 
			
		||||
  DCHECK(request);
 | 
			
		||||
  if (!request)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnHttpRequest(
 | 
			
		||||
      CefServerCToCpp::Wrap(server), connection_id, CefString(client_address),
 | 
			
		||||
      CefRequestCToCpp::Wrap(request));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_web_socket_request(struct _cef_server_handler_t* self,
 | 
			
		||||
                                     cef_server_t* server,
 | 
			
		||||
                                     int connection_id,
 | 
			
		||||
                                     const cef_string_t* client_address,
 | 
			
		||||
                                     cef_request_t* request,
 | 
			
		||||
                                     cef_callback_t* callback) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: client_address; type: string_byref_const
 | 
			
		||||
  DCHECK(client_address);
 | 
			
		||||
  if (!client_address)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: request; type: refptr_diff
 | 
			
		||||
  DCHECK(request);
 | 
			
		||||
  if (!request)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: callback; type: refptr_diff
 | 
			
		||||
  DCHECK(callback);
 | 
			
		||||
  if (!callback)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnWebSocketRequest(
 | 
			
		||||
      CefServerCToCpp::Wrap(server), connection_id, CefString(client_address),
 | 
			
		||||
      CefRequestCToCpp::Wrap(request), CefCallbackCToCpp::Wrap(callback));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_web_socket_connected(struct _cef_server_handler_t* self,
 | 
			
		||||
                                       cef_server_t* server,
 | 
			
		||||
                                       int connection_id) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnWebSocketConnected(
 | 
			
		||||
      CefServerCToCpp::Wrap(server), connection_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK
 | 
			
		||||
server_handler_on_web_socket_message(struct _cef_server_handler_t* self,
 | 
			
		||||
                                     cef_server_t* server,
 | 
			
		||||
                                     int connection_id,
 | 
			
		||||
                                     const void* data,
 | 
			
		||||
                                     size_t data_size) {
 | 
			
		||||
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
 | 
			
		||||
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: server; type: refptr_diff
 | 
			
		||||
  DCHECK(server);
 | 
			
		||||
  if (!server)
 | 
			
		||||
    return;
 | 
			
		||||
  // Verify param: data; type: simple_byaddr
 | 
			
		||||
  DCHECK(data);
 | 
			
		||||
  if (!data)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Execute
 | 
			
		||||
  CefServerHandlerCppToC::Get(self)->OnWebSocketMessage(
 | 
			
		||||
      CefServerCToCpp::Wrap(server), connection_id, data, data_size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace
 | 
			
		||||
 | 
			
		||||
// CONSTRUCTOR - Do not edit by hand.
 | 
			
		||||
 | 
			
		||||
CefServerHandlerCppToC::CefServerHandlerCppToC() {
 | 
			
		||||
  GetStruct()->on_server_created = server_handler_on_server_created;
 | 
			
		||||
  GetStruct()->on_server_destroyed = server_handler_on_server_destroyed;
 | 
			
		||||
  GetStruct()->on_client_connected = server_handler_on_client_connected;
 | 
			
		||||
  GetStruct()->on_client_disconnected = server_handler_on_client_disconnected;
 | 
			
		||||
  GetStruct()->on_http_request = server_handler_on_http_request;
 | 
			
		||||
  GetStruct()->on_web_socket_request = server_handler_on_web_socket_request;
 | 
			
		||||
  GetStruct()->on_web_socket_connected = server_handler_on_web_socket_connected;
 | 
			
		||||
  GetStruct()->on_web_socket_message = server_handler_on_web_socket_message;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
CefRefPtr<CefServerHandler> CefCppToCRefCounted<
 | 
			
		||||
    CefServerHandlerCppToC,
 | 
			
		||||
    CefServerHandler,
 | 
			
		||||
    cef_server_handler_t>::UnwrapDerived(CefWrapperType type,
 | 
			
		||||
                                         cef_server_handler_t* s) {
 | 
			
		||||
  NOTREACHED() << "Unexpected class type: " << type;
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if DCHECK_IS_ON()
 | 
			
		||||
template <>
 | 
			
		||||
base::AtomicRefCount CefCppToCRefCounted<CefServerHandlerCppToC,
 | 
			
		||||
                                         CefServerHandler,
 | 
			
		||||
                                         cef_server_handler_t>::DebugObjCt
 | 
			
		||||
    ATOMIC_DECLARATION;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
CefWrapperType CefCppToCRefCounted<CefServerHandlerCppToC,
 | 
			
		||||
                                   CefServerHandler,
 | 
			
		||||
                                   cef_server_handler_t>::kWrapperType =
 | 
			
		||||
    WT_SERVER_HANDLER;
 | 
			
		||||
							
								
								
									
										37
									
								
								libcef_dll/cpptoc/server_handler_cpptoc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								libcef_dll/cpptoc/server_handler_cpptoc.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
 | 
			
		||||
// reserved. Use of this source code is governed by a BSD-style license that
 | 
			
		||||
// can be found in the LICENSE file.
 | 
			
		||||
//
 | 
			
		||||
// ---------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// This file was generated by the CEF translator tool. If making changes by
 | 
			
		||||
// hand only do so within the body of existing method and function
 | 
			
		||||
// implementations. See the translator.README.txt file in the tools directory
 | 
			
		||||
// for more information.
 | 
			
		||||
//
 | 
			
		||||
// $hash=01080491feb0e65e1385fcc5547ecb9c88de70c3$
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_SERVER_HANDLER_CPPTOC_H_
 | 
			
		||||
#define CEF_LIBCEF_DLL_CPPTOC_SERVER_HANDLER_CPPTOC_H_
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#if !defined(WRAPPING_CEF_SHARED)
 | 
			
		||||
#error This file can be included wrapper-side only
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "include/capi/cef_server_capi.h"
 | 
			
		||||
#include "include/cef_server.h"
 | 
			
		||||
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
 | 
			
		||||
 | 
			
		||||
// Wrap a C++ class with a C structure.
 | 
			
		||||
// This class may be instantiated and accessed wrapper-side only.
 | 
			
		||||
class CefServerHandlerCppToC
 | 
			
		||||
    : public CefCppToCRefCounted<CefServerHandlerCppToC,
 | 
			
		||||
                                 CefServerHandler,
 | 
			
		||||
                                 cef_server_handler_t> {
 | 
			
		||||
 public:
 | 
			
		||||
  CefServerHandlerCppToC();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif  // CEF_LIBCEF_DLL_CPPTOC_SERVER_HANDLER_CPPTOC_H_
 | 
			
		||||
		Reference in New Issue
	
	Block a user