-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CefStringVisitorAdapter.h
52 lines (42 loc) · 1.5 KB
/
CefStringVisitorAdapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright © 2014 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include <msclr\marshal_cppstd.h>
#include <stdlib.h>
#include <string.h>
#include "include/cef_string_visitor.h"
using namespace msclr::interop;
namespace CefSharp
{
namespace Internals
{
private class CefStringVisitorAdapter : public CefStringVisitor
{
private:
gcroot<IStringVisitor^> _visitor;
public:
CefStringVisitorAdapter(IStringVisitor^ visitor) :
_visitor(visitor)
{
}
~CefStringVisitorAdapter()
{
delete _visitor;
_visitor = nullptr;
}
virtual void Visit(const CefString& string) override
{
// New Mojo IPC implementation uses shared memory rather than a string copy
// Attempt to workaround the access violation that's been reported in a few isolated cases
// by copying the string rather than using directly.
// https://github.com/chromiumembedded/cef/commit/ebee84755ed14e71388b343231d3a419f1c5c1fd
std::wstring str = string.ToWString();
auto clrString = marshal_as<String^>(str);
_visitor->Visit(clrString);
}
IMPLEMENT_REFCOUNTINGM(CefStringVisitorAdapter);
};
}
}