Skip to content

Commit

Permalink
Remove starboard/common/atomic usage above Starboard (#3252)
Browse files Browse the repository at this point in the history
Remove starboard/common/atomic usage above Starboard

b/322249881

Change-Id: I1c1abc3192f00b3b208b33faa3bdcf7613d3b6c6
(cherry picked from commit 9263496)
  • Loading branch information
iuriionishchenko authored and anonymous1-me committed May 31, 2024
1 parent 72dab7b commit ab35e11
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cobalt/browser/web_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class WebModule::Impl {

// Used to avoid a deadlock when running |Impl::Pause| while waiting for the
// web debugger to connect.
starboard::atomic_bool* waiting_for_web_debugger_;
std::atomic_bool* waiting_for_web_debugger_;

// Interface to report behaviour relevant to the web debugger.
debug::backend::DebuggerHooksImpl debugger_hooks_;
Expand Down
7 changes: 4 additions & 3 deletions cobalt/browser/web_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_BROWSER_WEB_MODULE_H_
#define COBALT_BROWSER_WEB_MODULE_H_

#include <atomic>
#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -424,7 +425,7 @@ class WebModule : public base::CurrentThread::DestructionObserver,
int dom_max_element_depth, float layout_refresh_rate,
const scoped_refptr<ui_navigation::NavItem>& ui_nav_root,
#if defined(ENABLE_DEBUGGER)
starboard::atomic_bool* waiting_for_web_debugger,
std::atomic_bool* waiting_for_web_debugger,
#endif // defined(ENABLE_DEBUGGER)
base::WaitableEvent* synchronous_loader_interrupt,
const Options& options)
Expand Down Expand Up @@ -464,7 +465,7 @@ class WebModule : public base::CurrentThread::DestructionObserver,
float layout_refresh_rate;
scoped_refptr<ui_navigation::NavItem> ui_nav_root;
#if defined(ENABLE_DEBUGGER)
starboard::atomic_bool* waiting_for_web_debugger;
std::atomic_bool* waiting_for_web_debugger;
#endif // defined(ENABLE_DEBUGGER)
base::WaitableEvent* synchronous_loader_interrupt;
Options options;
Expand Down Expand Up @@ -503,7 +504,7 @@ class WebModule : public base::CurrentThread::DestructionObserver,
#if defined(ENABLE_DEBUGGER)
// Used to avoid a deadlock when running |Blur| while waiting for the web
// debugger to connect. Initializes to false.
starboard::atomic_bool waiting_for_web_debugger_;
std::atomic_bool waiting_for_web_debugger_;
#endif // defined(ENABLE_DEBUGGER)

// This event is used to interrupt the loader when JavaScript is loaded
Expand Down
3 changes: 2 additions & 1 deletion cobalt/loader/net_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_LOADER_NET_FETCHER_H_
#define COBALT_LOADER_NET_FETCHER_H_

#include <atomic>
#include <memory>
#include <string>

Expand Down Expand Up @@ -132,7 +133,7 @@ class NetFetcher : public Fetcher,

scoped_refptr<base::SequencedTaskRunner> const task_runner_;
bool skip_fetch_intercept_;
starboard::atomic_bool will_destroy_current_task_runner_;
std::atomic_bool will_destroy_current_task_runner_;
bool main_resource_;

DISALLOW_COPY_AND_ASSIGN(NetFetcher);
Expand Down
3 changes: 2 additions & 1 deletion cobalt/media/decoder_buffer_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_
#define COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_

#include <atomic>
#include <memory>

#include "base/compiler_specific.h"
Expand Down Expand Up @@ -75,7 +76,7 @@ class DecoderBufferAllocator : public ::media::DecoderBuffer::Allocator,
int max_buffer_capacity_ = 0;

// Monitor memory allocation and use when |using_memory_pool_| is false
starboard::atomic_int32_t sbmemory_bytes_used_;
std::atomic_int32_t sbmemory_bytes_used_;
};

} // namespace media
Expand Down
41 changes: 20 additions & 21 deletions cobalt/network/disk_cache/resource_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "cobalt/network/disk_cache/resource_type.h"

#include <atomic>

#include "base/logging.h"

namespace cobalt {
Expand Down Expand Up @@ -85,27 +87,24 @@ namespace settings {

namespace {

starboard::atomic_int32_t other_quota =
starboard::atomic_int32_t(defaults::GetQuota(kOther));
starboard::atomic_int32_t html_quota =
starboard::atomic_int32_t(defaults::GetQuota(kHTML));
starboard::atomic_int32_t css_quota =
starboard::atomic_int32_t(defaults::GetQuota(kCSS));
starboard::atomic_int32_t image_quota =
starboard::atomic_int32_t(defaults::GetQuota(kImage));
starboard::atomic_int32_t font_quota =
starboard::atomic_int32_t(defaults::GetQuota(kFont));
starboard::atomic_int32_t splash_screen_quota =
starboard::atomic_int32_t(defaults::GetQuota(kSplashScreen));
starboard::atomic_int32_t uncompiled_script_quota =
starboard::atomic_int32_t(defaults::GetQuota(kUncompiledScript));
starboard::atomic_int32_t compiled_script_quota =
starboard::atomic_int32_t(defaults::GetQuota(kCompiledScript));
starboard::atomic_int32_t cache_api_quota =
starboard::atomic_int32_t(defaults::GetQuota(kCacheApi));
starboard::atomic_int32_t service_worker_script_quota =
starboard::atomic_int32_t(defaults::GetQuota(kServiceWorkerScript));
starboard::atomic_bool cache_enabled = starboard::atomic_bool(true);
std::atomic_int32_t other_quota =
std::atomic_int32_t(defaults::GetQuota(kOther));
std::atomic_int32_t html_quota = std::atomic_int32_t(defaults::GetQuota(kHTML));
std::atomic_int32_t css_quota = std::atomic_int32_t(defaults::GetQuota(kCSS));
std::atomic_int32_t image_quota =
std::atomic_int32_t(defaults::GetQuota(kImage));
std::atomic_int32_t font_quota = std::atomic_int32_t(defaults::GetQuota(kFont));
std::atomic_int32_t splash_screen_quota =
std::atomic_int32_t(defaults::GetQuota(kSplashScreen));
std::atomic_int32_t uncompiled_script_quota =
std::atomic_int32_t(defaults::GetQuota(kUncompiledScript));
std::atomic_int32_t compiled_script_quota =
std::atomic_int32_t(defaults::GetQuota(kCompiledScript));
std::atomic_int32_t cache_api_quota =
std::atomic_int32_t(defaults::GetQuota(kCacheApi));
std::atomic_int32_t service_worker_script_quota =
std::atomic_int32_t(defaults::GetQuota(kServiceWorkerScript));
std::atomic_bool cache_enabled = std::atomic_bool(true);

} // namespace

Expand Down
3 changes: 2 additions & 1 deletion cobalt/updater/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <stdint.h>

#include <atomic>
#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -114,7 +115,7 @@ class Configurator : public update_client::Configurator {
std::string user_agent_string_;
uint64_t min_free_space_bytes_ = 48 * 1024 * 1024;
base::Lock min_free_space_bytes_lock_;
starboard::atomic_bool use_compressed_updates_;
std::atomic_bool use_compressed_updates_;

DISALLOW_COPY_AND_ASSIGN(Configurator);
};
Expand Down
3 changes: 2 additions & 1 deletion cobalt/watchdog/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <pthread.h>

#include <atomic>
#include <memory>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -198,7 +199,7 @@ class Watchdog : public Singleton<Watchdog> {
// Monitor thread.
pthread_t watchdog_thread_;
// Flag to stop monitor thread.
starboard::atomic_bool is_monitoring_;
std::atomic_bool is_monitoring_;
// Conditional Variable to wait and shutdown monitor thread.
starboard::ConditionVariable monitor_wait_ =
starboard::ConditionVariable(mutex_);
Expand Down
13 changes: 9 additions & 4 deletions cobalt/worker/service_worker_jobs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

#include "cobalt/worker/service_worker_jobs.h"

<<<<<<< HEAD
=======
#include <atomic>
#include <vector>

>>>>>>> 9263496a5dc (Remove starboard/common/atomic usage above Starboard (#3252))
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/task/current_thread.h"
Expand Down Expand Up @@ -787,8 +793,7 @@ void ServiceWorkerJobs::Install(
// Using a shared pointer because this flag is explicitly defined in the spec
// to be modified from the worker's event loop, at asynchronous promise
// completion that may occur after a timeout.
std::shared_ptr<starboard::atomic_bool> install_failed(
new starboard::atomic_bool(false));
std::shared_ptr<std::atomic_bool> install_failed(new std::atomic_bool(false));

// 2. Let newestWorker be the result of running Get Newest Worker algorithm
// passing registration as its argument.
Expand Down Expand Up @@ -878,7 +883,7 @@ void ServiceWorkerJobs::Install(
base::Bind(
[](ServiceWorkerObject* installing_worker,
base::WaitableEvent* done_event,
std::shared_ptr<starboard::atomic_bool> install_failed) {
std::shared_ptr<std::atomic_bool> install_failed) {
// 11.3.1.1. Let e be the result of creating an event with
// ExtendableEvent.
// 11.3.1.2. Initialize e’s type attribute to install.
Expand All @@ -895,7 +900,7 @@ void ServiceWorkerJobs::Install(
// If task is discarded, set installFailed to true.
auto done_callback = base::BindOnce(
[](base::WaitableEvent* done_event,
std::shared_ptr<starboard::atomic_bool> install_failed,
std::shared_ptr<std::atomic_bool> install_failed,
bool was_rejected) {
if (was_rejected) install_failed->store(true);
done_event->Signal();
Expand Down
3 changes: 2 additions & 1 deletion cobalt/worker/service_worker_jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_WORKER_SERVICE_WORKER_JOBS_H_
#define COBALT_WORKER_SERVICE_WORKER_JOBS_H_

#include <atomic>
#include <deque>
#include <map>
#include <memory>
Expand Down Expand Up @@ -83,7 +84,7 @@ class ServiceWorkerJobs {
bool is_pending() const { return is_pending_.load(); }

private:
starboard::atomic_bool is_pending_{true};
std::atomic_bool is_pending_{true};
std::unique_ptr<script::ValuePromiseBool::Reference>
promise_bool_reference_;
std::unique_ptr<script::ValuePromiseWrappable::Reference>
Expand Down
3 changes: 2 additions & 1 deletion cobalt/worker/service_worker_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_WORKER_SERVICE_WORKER_OBJECT_H_
#define COBALT_WORKER_SERVICE_WORKER_OBJECT_H_

#include <atomic>
#include <map>
#include <memory>
#include <set>
Expand Down Expand Up @@ -196,7 +197,7 @@ class ServiceWorkerObject
// https://www.w3.org/TR/2022/CRD-service-workers-20220712/#service-worker-start-status
std::unique_ptr<std::string> start_status_;

starboard::atomic_bool start_failed_;
std::atomic_bool start_failed_;

scoped_refptr<WorkerGlobalScope> worker_global_scope_;

Expand Down
3 changes: 2 additions & 1 deletion cobalt/xhr/xml_http_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_XHR_XML_HTTP_REQUEST_H_
#define COBALT_XHR_XML_HTTP_REQUEST_H_

#include <atomic>
#include <memory>
#include <ostream>
#include <string>
Expand Down Expand Up @@ -347,7 +348,7 @@ class XMLHttpRequestImpl : public base::SupportsWeakPtr<XMLHttpRequestImpl>,
bool upload_listener_;
bool with_credentials_;
XMLHttpRequest* xhr_;
starboard::atomic_bool will_destroy_current_task_runner_;
std::atomic_bool will_destroy_current_task_runner_;

// A corspreflight instance for potentially sending preflight
// request and performing cors check for all cross origin requests.
Expand Down

0 comments on commit ab35e11

Please sign in to comment.