Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: mojo/edk/system/request_context.cc

Issue 1767003002: [mojo-edk] Cache the context thread-local in the RequestContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« mojo/edk/system/request_context.h ('K') | « mojo/edk/system/request_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/request_context.cc
diff --git a/mojo/edk/system/request_context.cc b/mojo/edk/system/request_context.cc
index 4ae87132f48d7dc4bfebe8f9b036333df4469015..c30d8bb821c501af2d424baac908ef6130b742d4 100644
--- a/mojo/edk/system/request_context.cc
+++ b/mojo/edk/system/request_context.cc
@@ -18,11 +18,11 @@ base::LazyInstance<base::ThreadLocalPointer<RequestContext>>::Leaky
} // namespace
-RequestContext::RequestContext() {
+RequestContext::RequestContext() : tls_context_(g_current_context.Pointer()){
// We allow nested RequestContexts to exist as long as they aren't actually
// used for anything.
- if (!g_current_context.Pointer()->Get())
- g_current_context.Pointer()->Set(this);
+ if (!tls_context_->Get())
+ tls_context_->Set(this);
}
RequestContext::~RequestContext() {
@@ -30,7 +30,7 @@ RequestContext::~RequestContext() {
// EDK requests on this thread, so we need to reset the thread-local context
// pointer before calling them.
if (IsCurrent())
- g_current_context.Pointer()->Set(nullptr);
+ tls_context_->Set(nullptr);
for (const WatchNotifyFinalizer& watch :
watch_notify_finalizers_.container()) {
@@ -66,7 +66,7 @@ void RequestContext::AddWatchCancelFinalizer(scoped_refptr<Watcher> watcher) {
}
bool RequestContext::IsCurrent() const {
- return g_current_context.Pointer()->Get() == this;
+ return tls_context_->Get() == this;
}
RequestContext::WatchNotifyFinalizer::WatchNotifyFinalizer(
« mojo/edk/system/request_context.h ('K') | « mojo/edk/system/request_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698