Skip to content

Commit

Permalink
Give some ServiceWorker and TLS related symbols more unique names
Browse files Browse the repository at this point in the history
In jumbo builds more code compile in the same translation unit
so it's more important to keep the names unique to avoid
compilation clashes.

Bug: 746953
Change-Id: I649731d0725a9c5b5ab0ec72775cc81ea54434a9
Reviewed-on: https://chromium-review.googlesource.com/819556
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#523737}
  • Loading branch information
bratell-at-opera authored and Commit Bot committed Dec 13, 2017
1 parent 1b896bf commit 5ec1b52
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
8 changes: 5 additions & 3 deletions content/renderer/cache_storage/cache_storage_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static base::LazyInstance<base::ThreadLocalPointer<CacheStorageDispatcher>>::

namespace {

CacheStorageDispatcher* const kHasBeenDeleted =
CacheStorageDispatcher* const kDeletedCacheStorageDispatcherMarker =
reinterpret_cast<CacheStorageDispatcher*>(0x1);

ServiceWorkerFetchRequest FetchRequestFromWebRequest(
Expand Down Expand Up @@ -200,12 +200,14 @@ CacheStorageDispatcher::~CacheStorageDispatcher() {
ClearCallbacksMapWithErrors(&cache_keys_callbacks_);
ClearCallbacksMapWithErrors(&cache_batch_callbacks_);

g_cache_storage_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
g_cache_storage_dispatcher_tls.Pointer()->Set(
kDeletedCacheStorageDispatcherMarker);
}

CacheStorageDispatcher* CacheStorageDispatcher::ThreadSpecificInstance(
ThreadSafeSender* thread_safe_sender) {
if (g_cache_storage_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
if (g_cache_storage_dispatcher_tls.Pointer()->Get() ==
kDeletedCacheStorageDispatcherMarker) {
NOTREACHED() << "Re-instantiating TLS CacheStorageDispatcher.";
g_cache_storage_dispatcher_tls.Pointer()->Set(nullptr);
}
Expand Down
7 changes: 4 additions & 3 deletions content/renderer/indexed_db/indexed_db_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher>>::Leaky

namespace {

IndexedDBDispatcher* const kHasBeenDeleted =
IndexedDBDispatcher* const kDeletedIndexedDBDispatcherMarker =
reinterpret_cast<IndexedDBDispatcher*>(0x1);

} // unnamed namespace
Expand All @@ -39,11 +39,12 @@ IndexedDBDispatcher::~IndexedDBDispatcher() {
mojo_owned_callback_state_.clear();
mojo_owned_database_callback_state_.clear();

g_idb_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
g_idb_dispatcher_tls.Pointer()->Set(kDeletedIndexedDBDispatcherMarker);
}

IndexedDBDispatcher* IndexedDBDispatcher::ThreadSpecificInstance() {
if (g_idb_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
if (g_idb_dispatcher_tls.Pointer()->Get() ==
kDeletedIndexedDBDispatcherMarker) {
NOTREACHED() << "Re-instantiating TLS IndexedDBDispatcher.";
g_idb_dispatcher_tls.Pointer()->Set(nullptr);
}
Expand Down
11 changes: 7 additions & 4 deletions content/renderer/service_worker/service_worker_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace {
base::LazyInstance<ThreadLocalPointer<void>>::Leaky g_dispatcher_tls =
LAZY_INSTANCE_INITIALIZER;

void* const kHasBeenDeleted = reinterpret_cast<void*>(0x1);
void* const kDeletedServiceWorkerDispatcherMarker =
reinterpret_cast<void*>(0x1);

} // namespace

Expand All @@ -55,7 +56,7 @@ ServiceWorkerDispatcher::~ServiceWorkerDispatcher() {
g_dispatcher_tls.Pointer()->Set(nullptr);
return;
}
g_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
g_dispatcher_tls.Pointer()->Set(kDeletedServiceWorkerDispatcherMarker);
}

void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
Expand All @@ -76,7 +77,8 @@ ServiceWorkerDispatcher*
ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
scoped_refptr<ThreadSafeSender> thread_safe_sender,
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) {
if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
if (g_dispatcher_tls.Pointer()->Get() ==
kDeletedServiceWorkerDispatcherMarker) {
NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher.";
g_dispatcher_tls.Pointer()->Set(nullptr);
}
Expand All @@ -92,7 +94,8 @@ ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
}

ServiceWorkerDispatcher* ServiceWorkerDispatcher::GetThreadSpecificInstance() {
if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted)
if (g_dispatcher_tls.Pointer()->Get() ==
kDeletedServiceWorkerDispatcherMarker)
return nullptr;
return static_cast<ServiceWorkerDispatcher*>(
g_dispatcher_tls.Pointer()->Get());
Expand Down
11 changes: 6 additions & 5 deletions content/renderer/service_worker/web_service_worker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ namespace content {

namespace {

class HandleImpl : public blink::WebServiceWorker::Handle {
class ServiceWorkerHandleImpl : public blink::WebServiceWorker::Handle {
public:
explicit HandleImpl(const scoped_refptr<WebServiceWorkerImpl>& worker)
explicit ServiceWorkerHandleImpl(
const scoped_refptr<WebServiceWorkerImpl>& worker)
: worker_(worker) {}
~HandleImpl() override {}
~ServiceWorkerHandleImpl() override {}

blink::WebServiceWorker* ServiceWorker() override { return worker_.get(); }

private:
scoped_refptr<WebServiceWorkerImpl> worker_;

DISALLOW_COPY_AND_ASSIGN(HandleImpl);
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleImpl);
};

} // namespace
Expand Down Expand Up @@ -105,7 +106,7 @@ WebServiceWorkerImpl::CreateHandle(
const scoped_refptr<WebServiceWorkerImpl>& worker) {
if (!worker)
return nullptr;
return std::make_unique<HandleImpl>(worker);
return std::make_unique<ServiceWorkerHandleImpl>(worker);
}

WebServiceWorkerImpl::~WebServiceWorkerImpl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ namespace content {

namespace {

class HandleImpl : public blink::WebServiceWorkerRegistration::Handle {
class ServiceWorkerRegistrationHandleImpl
: public blink::WebServiceWorkerRegistration::Handle {
public:
explicit HandleImpl(
explicit ServiceWorkerRegistrationHandleImpl(
scoped_refptr<WebServiceWorkerRegistrationImpl> registration)
: registration_(std::move(registration)) {}
~HandleImpl() override {}
~ServiceWorkerRegistrationHandleImpl() override {}

blink::WebServiceWorkerRegistration* Registration() override {
return registration_.get();
Expand All @@ -38,7 +39,7 @@ class HandleImpl : public blink::WebServiceWorkerRegistration::Handle {
private:
scoped_refptr<WebServiceWorkerRegistrationImpl> registration_;

DISALLOW_COPY_AND_ASSIGN(HandleImpl);
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandleImpl);
};

} // namespace
Expand Down Expand Up @@ -380,7 +381,8 @@ WebServiceWorkerRegistrationImpl::CreateHandle(
scoped_refptr<WebServiceWorkerRegistrationImpl> registration) {
if (!registration)
return nullptr;
return std::make_unique<HandleImpl>(std::move(registration));
return std::make_unique<ServiceWorkerRegistrationHandleImpl>(
std::move(registration));
}

// static
Expand Down

0 comments on commit 5ec1b52

Please sign in to comment.