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

Unified Diff: base/message_loop/message_loop.h

Issue 1058603004: [Approach 3] Pre-allocate IncomigTaskQueue before MessageLoop for faster thread startup Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « base/message_loop/incoming_task_queue.cc ('k') | base/message_loop/message_loop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop.h
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index fd7596a79204ed89291f32b2f9135108a73b2882..e7228a7b31ec94b3a25c65a6aa676a0ed514b304 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -11,7 +11,6 @@
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/callback_forward.h"
-#include "base/debug/task_annotator.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -109,12 +108,36 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
#endif // defined(OS_ANDROID)
};
+ struct BASE_EXPORT Options {
+ using MessagePumpFactory = Callback<scoped_ptr<MessagePump>()>;
+ Options();
+ ~Options();
+
+ // Specify the type of message loop.
+ // This is ignored if message_pump_factory.is_null() is false.
+ MessageLoop::Type message_loop_type;
+
+ // Used to create the MessagePump for the MessageLoop.
+ // If message_pump_factory.is_null() is true, then a MessagePump appropriate
+ // for |message_loop_type| is created. Setting this forces the
+ // MessageLoop::Type to TYPE_CUSTOM.
+ MessagePumpFactory message_pump_factory;
+
+ // If non-null incoming_task_queue is specified this message loop will
+ // use it as its incoming task queue.
+ scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue;
+ };
+
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
// is typical to make use of the current thread's MessageLoop instance.
+ explicit MessageLoop(const Options& options);
+
+ // Creates a MessageLoop for the supplied type. This constructor is used
+ // only for testing.
explicit MessageLoop(Type type = TYPE_DEFAULT);
// Creates a TYPE_CUSTOM MessageLoop with the supplied MessagePump, which must
- // be non-NULL.
- explicit MessageLoop(scoped_ptr<base::MessagePump> pump);
+ // be non-NULL. This constructor is used only for testing.
+ explicit MessageLoop(scoped_ptr<MessagePump> pump);
~MessageLoop() override;
// Returns the MessageLoop object for the current thread, or null if none.
@@ -400,7 +423,9 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
// Returns the TaskAnnotator which is used to add debug information to posted
// tasks.
- debug::TaskAnnotator* task_annotator() { return &task_annotator_; }
+ debug::TaskAnnotator* task_annotator() {
+ return incoming_task_queue_->task_annotator();
+ }
// Runs the specified PendingTask.
void RunTask(const PendingTask& pending_task);
@@ -412,7 +437,7 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
private:
friend class RunLoop;
- // Configures various members for the two constructors.
+ // Configures various members for the constructors.
void Init();
// Invokes the actual run loop using the message pump.
@@ -498,8 +523,6 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
ObserverList<TaskObserver> task_observers_;
- debug::TaskAnnotator task_annotator_;
-
scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_;
// The message loop proxy associated with this message loop.
« no previous file with comments | « base/message_loop/incoming_task_queue.cc ('k') | base/message_loop/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698