Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_EDK_SYSTEM_REQUEST_CONTEXT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_REQUEST_CONTEXT_H_ |
| 6 #define MOJO_EDK_SYSTEM_REQUEST_CONTEXT_H_ | 6 #define MOJO_EDK_SYSTEM_REQUEST_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/containers/stack_container.h" | 8 #include "base/containers/stack_container.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "mojo/edk/system/handle_signals_state.h" | 10 #include "mojo/edk/system/handle_signals_state.h" |
| 11 #include "mojo/edk/system/watcher.h" | 11 #include "mojo/edk/system/watcher.h" |
| 12 | 12 |
| 13 namespace base { | |
| 14 template<typename T> class ThreadLocalPointer; | |
| 15 } | |
| 16 | |
| 13 namespace mojo { | 17 namespace mojo { |
| 14 namespace edk { | 18 namespace edk { |
| 15 | 19 |
| 16 // A RequestContext is a thread-local object which exists for the duration of | 20 // A RequestContext is a thread-local object which exists for the duration of |
| 17 // a single system API call. It is constructed immediately upon EDK entry and | 21 // a single system API call. It is constructed immediately upon EDK entry and |
| 18 // destructed immediately before returning to the caller, after any internal | 22 // destructed immediately before returning to the caller, after any internal |
| 19 // locks have been released. | 23 // locks have been released. |
| 20 // | 24 // |
| 21 // NOTE: It is legal to construct a RequestContext while another one already | 25 // NOTE: It is legal to construct a RequestContext while another one already |
| 22 // exists on the current thread, but it is not safe to use the nested context | 26 // exists on the current thread, but it is not safe to use the nested context |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 static const size_t kStaticWatchFinalizersCapacity = 4; | 70 static const size_t kStaticWatchFinalizersCapacity = 4; |
| 67 | 71 |
| 68 using WatchNotifyFinalizerList = | 72 using WatchNotifyFinalizerList = |
| 69 base::StackVector<WatchNotifyFinalizer, kStaticWatchFinalizersCapacity>; | 73 base::StackVector<WatchNotifyFinalizer, kStaticWatchFinalizersCapacity>; |
| 70 using WatchCancelFinalizerList = | 74 using WatchCancelFinalizerList = |
| 71 base::StackVector<scoped_refptr<Watcher>, kStaticWatchFinalizersCapacity>; | 75 base::StackVector<scoped_refptr<Watcher>, kStaticWatchFinalizersCapacity>; |
| 72 | 76 |
| 73 WatchNotifyFinalizerList watch_notify_finalizers_; | 77 WatchNotifyFinalizerList watch_notify_finalizers_; |
| 74 WatchCancelFinalizerList watch_cancel_finalizers_; | 78 WatchCancelFinalizerList watch_cancel_finalizers_; |
| 75 | 79 |
| 80 // Pointer to the TLS context. Although this can easily be accessed via the | |
| 81 // global LazyInstance, accessing a LazyInstance has a large cost relative to | |
| 82 // the rest of this class and its usages. | |
| 83 base::ThreadLocalPointer<RequestContext>* tls_context_; | |
|
Ken Rockot(use gerrit already)
2016/03/07 04:25:00
Hmm, couldn't this just be a raw pointer?
| |
| 84 | |
| 76 DISALLOW_COPY_AND_ASSIGN(RequestContext); | 85 DISALLOW_COPY_AND_ASSIGN(RequestContext); |
| 77 }; | 86 }; |
| 78 | 87 |
| 79 } // namespace edk | 88 } // namespace edk |
| 80 } // namespace mojo | 89 } // namespace mojo |
| 81 | 90 |
| 82 #endif // MOJO_EDK_SYSTEM_REQUEST_CONTEXT_H_ | 91 #endif // MOJO_EDK_SYSTEM_REQUEST_CONTEXT_H_ |
| OLD | NEW |