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

Side by Side Diff: chrome/profiling/profiling_globals.cc

Issue 2937133002: Launch browser when --memlog is specified on the command line. (Closed)
Patch Set: Format 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/profiling/profiling_globals.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/threading/thread.h"
10 #include "build/build_config.h"
11
12 namespace profiling {
13
14 ProfilingGlobals::ProfilingGlobals()
15 : io_thread_(base::MakeUnique<base::Thread>("IO thread")) {
awong 2017/06/14 23:15:19 Don't change this code, but do we actually want an
brettw 2017/06/14 23:23:55 I changed it. I did it that way because I was thin
16 #if defined(OS_WIN)
17 io_thread_->init_com_with_mta(true);
18 #endif
19 base::Thread::Options options;
20 options.message_loop_type = base::MessageLoop::TYPE_IO;
21 io_thread_->StartWithOptions(options);
22 }
23
24 ProfilingGlobals::~ProfilingGlobals() {}
25
26 // static
27 ProfilingGlobals* ProfilingGlobals::Get() {
28 static ProfilingGlobals singleton;
29 return &singleton;
30 }
31
32 base::TaskRunner* ProfilingGlobals::GetIORunner() {
33 return io_thread_->task_runner().get();
34 }
35
36 scoped_refptr<base::SingleThreadTaskRunner> ProfilingGlobals::GetMainThread()
37 const {
38 CHECK(base::MessageLoop::current() == main_message_loop_);
39 return main_message_loop_->task_runner();
40 }
41
42 void ProfilingGlobals::RunMainMessageLoop() {
43 base::MessageLoopForUI message_loop;
44 DCHECK(!main_message_loop_);
45 main_message_loop_ = &message_loop;
46
47 base::RunLoop run_loop;
48 run_loop.Run();
49
50 main_message_loop_ = nullptr;
51 }
52
53 void ProfilingGlobals::QuitWhenIdle() {
54 main_message_loop_->QuitWhenIdle();
55 }
56
57 } // namespace profiling
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698