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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/profiling/profiling_globals.h ('k') | chrome/profiling/profiling_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "build/build_config.h"
10
11 namespace profiling {
12
13 ProfilingGlobals::ProfilingGlobals()
14 : io_thread_("IO thread") {
15 #if defined(OS_WIN)
16 io_thread_.init_com_with_mta(true);
17 #endif
18 base::Thread::Options options;
19 options.message_loop_type = base::MessageLoop::TYPE_IO;
20 io_thread_.StartWithOptions(options);
21 }
22
23 ProfilingGlobals::~ProfilingGlobals() {}
24
25 // static
26 ProfilingGlobals* ProfilingGlobals::Get() {
27 static ProfilingGlobals singleton;
28 return &singleton;
29 }
30
31 base::TaskRunner* ProfilingGlobals::GetIORunner() {
32 return io_thread_.task_runner().get();
33 }
34
35 scoped_refptr<base::SingleThreadTaskRunner> ProfilingGlobals::GetMainThread()
36 const {
37 CHECK(base::MessageLoop::current() == main_message_loop_);
38 return main_message_loop_->task_runner();
39 }
40
41 void ProfilingGlobals::RunMainMessageLoop() {
42 // TODO(brettw) if we never add anything interesting on the main thread here,
43 // we can change this so the main thread *is* the I/O thread. This will save
44 // some resources.
45 base::MessageLoopForUI message_loop;
46 DCHECK(!main_message_loop_);
47 main_message_loop_ = &message_loop;
48
49 base::RunLoop run_loop;
50 run_loop.Run();
51
52 main_message_loop_ = nullptr;
53 }
54
55 void ProfilingGlobals::QuitWhenIdle() {
56 main_message_loop_->QuitWhenIdle();
57 }
58
59 } // namespace profiling
OLDNEW
« 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