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

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

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « mojo/edk/system/multiprocess_message_pipe_unittest.cc ('k') | mojo/edk/system/request_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/request_context.h
diff --git a/mojo/edk/system/request_context.h b/mojo/edk/system/request_context.h
index 7aa0e69b51bb2a73b1175577dec98874f5be91a9..d1f43bdfbd16ddbfe7af92d8834a564510b752b7 100644
--- a/mojo/edk/system/request_context.h
+++ b/mojo/edk/system/request_context.h
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "mojo/edk/system/handle_signals_state.h"
#include "mojo/edk/system/system_impl_export.h"
-#include "mojo/edk/system/watcher.h"
+#include "mojo/edk/system/watch.h"
namespace base {
template<typename T> class ThreadLocalPointer;
@@ -49,43 +49,44 @@ class MOJO_SYSTEM_IMPL_EXPORT RequestContext {
// Adds a finalizer to this RequestContext corresponding to a watch callback
// which should be triggered in response to some handle state change. If
- // the Watcher hasn't been cancelled by the time this RequestContext is
+ // the WatcherDispatcher hasn't been closed by the time this RequestContext is
// destroyed, its WatchCallback will be invoked with |result| and |state|
// arguments.
- void AddWatchNotifyFinalizer(scoped_refptr<Watcher> watcher,
+ void AddWatchNotifyFinalizer(scoped_refptr<Watch> watch,
MojoResult result,
const HandleSignalsState& state);
- // Adds a finalizer to this RequestContext which cancels a watch.
- void AddWatchCancelFinalizer(scoped_refptr<Watcher> watcher);
+ // Adds a finalizer to this RequestContext corresponding to a watch callback
+ // which should be triggered to notify of watch cancellation. This appends to
+ // a separate finalizer list from AddWatchNotifyFinalizer, as pending
+ // cancellations must always preempt other pending notifications.
+ void AddWatchCancelFinalizer(scoped_refptr<Watch> watch);
private:
// Is this request context the current one?
bool IsCurrent() const;
struct WatchNotifyFinalizer {
- WatchNotifyFinalizer(scoped_refptr<Watcher> watcher,
+ WatchNotifyFinalizer(scoped_refptr<Watch> watch,
MojoResult result,
const HandleSignalsState& state);
WatchNotifyFinalizer(const WatchNotifyFinalizer& other);
~WatchNotifyFinalizer();
- scoped_refptr<Watcher> watcher;
+ scoped_refptr<Watch> watch;
MojoResult result;
HandleSignalsState state;
};
- // Chosen by fair dice roll.
- //
- // TODO: We should measure the distribution of # of finalizers typical to
- // any RequestContext and adjust this number accordingly. It's probably
- // almost always 1, but 4 seems like a harmless upper bound for now.
- static const size_t kStaticWatchFinalizersCapacity = 4;
+ // NOTE: This upper bound was chosen somewhat arbitrarily after observing some
+ // rare worst-case behavior in Chrome. A vast majority of RequestContexts only
+ // ever accumulate 0 or 1 finalizers.
+ static const size_t kStaticWatchFinalizersCapacity = 8;
using WatchNotifyFinalizerList =
base::StackVector<WatchNotifyFinalizer, kStaticWatchFinalizersCapacity>;
using WatchCancelFinalizerList =
- base::StackVector<scoped_refptr<Watcher>, kStaticWatchFinalizersCapacity>;
+ base::StackVector<scoped_refptr<Watch>, kStaticWatchFinalizersCapacity>;
const Source source_;
« no previous file with comments | « mojo/edk/system/multiprocess_message_pipe_unittest.cc ('k') | mojo/edk/system/request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698