mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Convert legacy IPC messages to Mojo (fixes issue #3123)
This change introduces a few minor CEF API behavior changes: - A CefProcessMessage object cannot be reused after being passed to SendProcessMessage. - The |extra_info| argument to CefRenderProcessHandler::OnBrowserCreated may now be NULL. Where appropriate, we now utilize the default UTF string encoding format and shared memory to reduce copies and conversions for the cross-process transfer of arbitrary-length strings. For example, CefFrame::GetSource/GetText now involves zero UTF conversions and zero copies in the browser process for the CefString delivered to CefStringVisitor::Visit().
This commit is contained in:
44
libcef/common/string_util.h
Normal file
44
libcef/common/string_util.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2021 The Chromium Embedded Framework Authors. Portions copyright
|
||||
// 2011 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_COMMON_STRING_UTIL_H_
|
||||
#define CEF_LIBCEF_COMMON_STRING_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
|
||||
namespace base {
|
||||
class ReadOnlySharedMemoryRegion;
|
||||
class RefCountedMemory;
|
||||
} // namespace base
|
||||
|
||||
namespace blink {
|
||||
class WebString;
|
||||
}
|
||||
|
||||
namespace string_util {
|
||||
|
||||
// Convert |source| to |cef_string|, avoiding UTF conversions if possible.
|
||||
void GetCefString(const blink::WebString& source, CefString& cef_string);
|
||||
void GetCefString(scoped_refptr<base::RefCountedMemory> source,
|
||||
CefString& cef_string);
|
||||
|
||||
// Read |source| into shared memory, avoiding UTF conversions if possible.
|
||||
// Use ExecuteWithScopedCefString() to retrieve the value on the receiving end
|
||||
// with zero UTF conversions and zero copies if possible.
|
||||
base::ReadOnlySharedMemoryRegion CreateSharedMemoryRegion(
|
||||
const blink::WebString& source);
|
||||
|
||||
using ScopedCefStringCallback = base::OnceCallback<void(const CefString&)>;
|
||||
|
||||
// Helper for executing |callback| with |region| as a scoped CefString.
|
||||
void ExecuteWithScopedCefString(base::ReadOnlySharedMemoryRegion region,
|
||||
ScopedCefStringCallback callback);
|
||||
|
||||
} // namespace string_util
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_STRING_UTIL_H_
|
Reference in New Issue
Block a user