mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-04-21 01:16:52 -04:00
browser/client: keep on stack
This commit is contained in:
@@ -5,15 +5,21 @@
|
||||
#include "include/cef_client.h"
|
||||
|
||||
namespace Browser {
|
||||
/// Implementation of CefClient. Store on the stack, but access only via CefRefPtr.
|
||||
/// https://github.com/chromiumembedded/cef/blob/5563/include/cef_client.h
|
||||
struct Client: public CefClient {
|
||||
CefRefPtr<CefLifeSpanHandler> life_span_handler;
|
||||
|
||||
Client(CefRefPtr<CefLifeSpanHandler>);
|
||||
CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override;
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(Client);
|
||||
DISALLOW_COPY_AND_ASSIGN(Client);
|
||||
Client(const Client&) = delete;
|
||||
Client& operator=(const Client&) = delete;
|
||||
void AddRef() const override { this->ref_count.AddRef(); }
|
||||
bool Release() const override { return this->ref_count.Release(); }
|
||||
bool HasOneRef() const override { return this->ref_count.HasOneRef(); }
|
||||
bool HasAtLeastOneRef() const override { return this->ref_count.HasAtLeastOneRef(); }
|
||||
private: CefRefCount ref_count;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Our CEF client and the various things it needs pointers to
|
||||
CefRefPtr<CefLifeSpanHandler> life_span_handler = new Browser::LifeSpanHandler;
|
||||
CefRefPtr<CefClient> client = new Browser::Client(life_span_handler);
|
||||
Browser::Client client_(life_span_handler);
|
||||
CefRefPtr<CefClient> client = &client_;
|
||||
|
||||
// Spawn a window using the "views" pipeline
|
||||
Browser::Details details = {
|
||||
|
||||
Reference in New Issue
Block a user