Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest chromium for w64 fix #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions capi/cef_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ struct _cef_focus_handler_t* CEF_CALLBACK get_focus_handler(
return NULL;
}

///
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
///
struct _cef_geolocation_handler_t* CEF_CALLBACK get_geolocation_handler(
struct _cef_client_t* self) {
DEBUG_CALLBACK("get_geolocation_handler\n");
return NULL;
}
// ///
// // Return the handler for geolocation permissions requests. If no handler is
// // provided geolocation access will be denied by default.
// ///
// struct _cef_geolocation_handler_t* CEF_CALLBACK get_geolocation_handler(
// struct _cef_client_t* self) {
// DEBUG_CALLBACK("get_geolocation_handler\n");
// return NULL;
// }

///
// Return the handler for JavaScript dialogs. If no handler is provided the
Expand Down Expand Up @@ -149,8 +149,11 @@ struct _cef_request_handler_t* CEF_CALLBACK get_request_handler(
///
int CEF_CALLBACK on_process_message_received(
struct _cef_client_t* self,
struct _cef_browser_t* browser, cef_process_id_t source_process,
struct _cef_process_message_t* message) {
struct _cef_browser_t* browser,
struct _cef_frame_t* frame,
cef_process_id_t source_process,
struct _cef_process_message_t* message
) {
DEBUG_CALLBACK("on_process_message_received\n");
return 0;
}
Expand All @@ -166,7 +169,7 @@ void initialize_cef_client(cef_client_t* client) {
client->get_download_handler = get_download_handler;
client->get_drag_handler = get_drag_handler;
client->get_focus_handler = get_focus_handler;
client->get_geolocation_handler = get_geolocation_handler;
// client->get_geolocation_handler = get_geolocation_handler;
client->get_jsdialog_handler = get_jsdialog_handler;
client->get_keyboard_handler = get_keyboard_handler;
client->get_life_span_handler = get_life_span_handler; // Implemented!
Expand Down
12 changes: 6 additions & 6 deletions examples/main_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "capi/cef_client.h"
#include "capi/cef_life_span_handler.h"

#include "include/cef_version_win.h"
#include "include/cef_version.h"

// Globals
cef_life_span_handler_t g_life_span_handler = {};
Expand Down Expand Up @@ -79,10 +79,10 @@ int main(int argc, char** argv) {
window_info.style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN \
| WS_CLIPSIBLINGS | WS_VISIBLE;
window_info.parent_window = NULL;
window_info.x = CW_USEDEFAULT;
window_info.y = CW_USEDEFAULT;
window_info.width = CW_USEDEFAULT;
window_info.height = CW_USEDEFAULT;
// window_info.x = CW_USEDEFAULT;
// window_info.y = CW_USEDEFAULT;
// window_info.width = CW_USEDEFAULT;
// window_info.height = CW_USEDEFAULT;

// Window info - window title
char window_name[] = "cefcapi example";
Expand Down Expand Up @@ -110,7 +110,7 @@ int main(int argc, char** argv) {
// synchronous version of this function available.
printf("cef_browser_host_create_browser\n");
cef_browser_host_create_browser(&window_info, &client, &cef_url,
&browser_settings, NULL);
&browser_settings, NULL, NULL);

// Message loop. There is also cef_do_message_loop_work()
// that allow for integrating with existing message loops.
Expand Down
97 changes: 97 additions & 0 deletions include/base/cef_atomic_flag.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
// Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
#define CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
#pragma once

#if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/synchronization/atomic_flag.h"

#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.

#include <stdint.h>

#include <atomic>

#include "include/base/cef_thread_checker.h"

namespace base {

///
/// A flag that can safely be set from one thread and read from other threads.
///
/// This class IS NOT intended for synchronization between threads.
///
class AtomicFlag {
public:
AtomicFlag();

AtomicFlag(const AtomicFlag&) = delete;
AtomicFlag& operator=(const AtomicFlag&) = delete;

~AtomicFlag();

///
/// Set the flag. Must always be called from the same thread.
///
void Set();

///
/// Returns true iff the flag was set. If this returns true, the current
/// thread is guaranteed to be synchronized with all memory operations on the
/// thread which invoked Set() up until at least the first call to Set() on
/// it.
///
bool IsSet() const {
// Inline here: this has a measurable performance impact on base::WeakPtr.
return flag_.load(std::memory_order_acquire) != 0;
}

///
/// Resets the flag. Be careful when using this: callers might not expect
/// IsSet() to return false after returning true once.
///
void UnsafeResetForTesting();

private:
std::atomic<uint_fast8_t> flag_{0};
base::ThreadChecker set_thread_checker_;
};

} // namespace base

#endif // !USING_CHROMIUM_INCLUDES

#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
164 changes: 61 additions & 103 deletions include/base/cef_atomic_ref_count.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,120 +43,78 @@
// When building CEF include the Chromium header directly.
#include "base/atomic_ref_count.h"

// Used when declaring a base::AtomicRefCount value. This is an object type with
// Chromium headers.
#define ATOMIC_DECLARATION (0)

// Maintaining compatibility with AtompicRefCount* functions that were removed
// from Chromium in http://crrev.com/ee96d561.
namespace base {

// Increment a reference count by 1.
inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) {
const_cast<AtomicRefCount*>(ptr)->Increment();
}

// Decrement a reference count by 1 and return whether the result is non-zero.
// Insert barriers to ensure that state written before the reference count
// became zero will be visible to a thread that has just made the count zero.
inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) {
return const_cast<AtomicRefCount*>(ptr)->Decrement();
}

// Return whether the reference count is one. If the reference count is used
// in the conventional way, a refrerence count of 1 implies that the current
// thread owns the reference and no other thread shares it. This call performs
// the test for a reference count of one, and performs the memory barrier
// needed for the owning thread to act on the object, knowing that it has
// exclusive access to the object.
inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) {
return const_cast<AtomicRefCount*>(ptr)->IsOne();
}

// Return whether the reference count is zero. With conventional object
// referencing counting, the object will be destroyed, so the reference count
// should never be zero. Hence this is generally used for a debug check.
inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) {
return const_cast<AtomicRefCount*>(ptr)->IsZero();
}

} // namespace base

#else // !USING_CHROMIUM_INCLUDES
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.

#include "include/base/cef_atomicops.h"

// Annotations are not currently supported.
#define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */
#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */

// Used when declaring a base::AtomicRefCount value. This is an integer/ptr type
// with CEF headers.
#define ATOMIC_DECLARATION = 0
#include <atomic>

namespace base {

typedef subtle::Atomic32 AtomicRefCount;

// Increment a reference count by "increment", which must exceed 0.
inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr,
AtomicRefCount increment) {
subtle::NoBarrier_AtomicIncrement(ptr, increment);
}

// Decrement a reference count by "decrement", which must exceed 0,
// and return whether the result is non-zero.
// Insert barriers to ensure that state written before the reference count
// became zero will be visible to a thread that has just made the count zero.
inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr,
AtomicRefCount decrement) {
ANNOTATE_HAPPENS_BEFORE(ptr);
bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0);
if (!res) {
ANNOTATE_HAPPENS_AFTER(ptr);
class AtomicRefCount {
public:
constexpr AtomicRefCount() : ref_count_(0) {}
explicit constexpr AtomicRefCount(int initial_value)
: ref_count_(initial_value) {}

///
/// Increment a reference count.
/// Returns the previous value of the count.
///
int Increment() { return Increment(1); }

///
/// Increment a reference count by "increment", which must exceed 0.
/// Returns the previous value of the count.
///
int Increment(int increment) {
return ref_count_.fetch_add(increment, std::memory_order_relaxed);
}

///
/// Decrement a reference count, and return whether the result is non-zero.
/// Insert barriers to ensure that state written before the reference count
/// became zero will be visible to a thread that has just made the count zero.
///
bool Decrement() {
// TODO(jbroman): Technically this doesn't need to be an acquire operation
// unless the result is 1 (i.e., the ref count did indeed reach zero).
// However, there are toolchain issues that make that not work as well at
// present (notably TSAN doesn't like it).
return ref_count_.fetch_sub(1, std::memory_order_acq_rel) != 1;
}
return res;
}

// Increment a reference count by 1.
inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) {
base::AtomicRefCountIncN(ptr, 1);
}

// Decrement a reference count by 1 and return whether the result is non-zero.
// Insert barriers to ensure that state written before the reference count
// became zero will be visible to a thread that has just made the count zero.
inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) {
return base::AtomicRefCountDecN(ptr, 1);
}

// Return whether the reference count is one. If the reference count is used
// in the conventional way, a refrerence count of 1 implies that the current
// thread owns the reference and no other thread shares it. This call performs
// the test for a reference count of one, and performs the memory barrier
// needed for the owning thread to act on the object, knowing that it has
// exclusive access to the object.
inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) {
bool res = (subtle::Acquire_Load(ptr) == 1);
if (res) {
ANNOTATE_HAPPENS_AFTER(ptr);

///
/// Return whether the reference count is one. If the reference count is used
/// in the conventional way, a refrerence count of 1 implies that the current
/// thread owns the reference and no other thread shares it. This call
/// performs the test for a reference count of one, and performs the memory
/// barrier needed for the owning thread to act on the object, knowing that it
/// has exclusive access to the object.
///
bool IsOne() const { return ref_count_.load(std::memory_order_acquire) == 1; }

///
/// Return whether the reference count is zero. With conventional object
/// referencing counting, the object will be destroyed, so the reference count
/// should never be zero. Hence this is generally used for a debug check.
///
bool IsZero() const {
return ref_count_.load(std::memory_order_acquire) == 0;
}
return res;
}

// Return whether the reference count is zero. With conventional object
// referencing counting, the object will be destroyed, so the reference count
// should never be zero. Hence this is generally used for a debug check.
inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) {
bool res = (subtle::Acquire_Load(ptr) == 0);
if (res) {
ANNOTATE_HAPPENS_AFTER(ptr);

///
/// Returns the current reference count (with no barriers). This is subtle,
/// and should be used only for debugging.
///
int SubtleRefCountForDebug() const {
return ref_count_.load(std::memory_order_relaxed);
}
return res;
}

private:
std::atomic_int ref_count_;
};

} // namespace base

Expand Down
Loading