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

Unified Diff: chrome/profiling/profiling_globals.cc

Issue 2937133002: Launch browser when --memlog is specified on the command line. (Closed)
Patch Set: Fix Created 3 years, 6 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 | « chrome/profiling/profiling_globals.h ('k') | chrome/profiling/profiling_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/profiling/profiling_globals.cc
diff --git a/chrome/profiling/profiling_globals.cc b/chrome/profiling/profiling_globals.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5cd552e70aa231527188a8dd2af5c38fb6a79017
--- /dev/null
+++ b/chrome/profiling/profiling_globals.cc
@@ -0,0 +1,59 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/profiling/profiling_globals.h"
+
+#include "base/memory/ptr_util.h"
+#include "base/message_loop/message_loop.h"
+#include "build/build_config.h"
+
+namespace profiling {
+
+ProfilingGlobals::ProfilingGlobals()
+ : io_thread_("IO thread") {
+#if defined(OS_WIN)
+ io_thread_.init_com_with_mta(true);
+#endif
+ base::Thread::Options options;
+ options.message_loop_type = base::MessageLoop::TYPE_IO;
+ io_thread_.StartWithOptions(options);
+}
+
+ProfilingGlobals::~ProfilingGlobals() {}
+
+// static
+ProfilingGlobals* ProfilingGlobals::Get() {
+ static ProfilingGlobals singleton;
+ return &singleton;
+}
+
+base::TaskRunner* ProfilingGlobals::GetIORunner() {
+ return io_thread_.task_runner().get();
+}
+
+scoped_refptr<base::SingleThreadTaskRunner> ProfilingGlobals::GetMainThread()
+ const {
+ CHECK(base::MessageLoop::current() == main_message_loop_);
+ return main_message_loop_->task_runner();
+}
+
+void ProfilingGlobals::RunMainMessageLoop() {
+ // TODO(brettw) if we never add anything interesting on the main thread here,
+ // we can change this so the main thread *is* the I/O thread. This will save
+ // some resources.
+ base::MessageLoopForUI message_loop;
+ DCHECK(!main_message_loop_);
+ main_message_loop_ = &message_loop;
+
+ base::RunLoop run_loop;
+ run_loop.Run();
+
+ main_message_loop_ = nullptr;
+}
+
+void ProfilingGlobals::QuitWhenIdle() {
+ main_message_loop_->QuitWhenIdle();
+}
+
+} // namespace profiling
« no previous file with comments | « chrome/profiling/profiling_globals.h ('k') | chrome/profiling/profiling_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698