| OLD | NEW | 
|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/profiling/profiling_globals.h" | 5 #include "chrome/profiling/profiling_globals.h" | 
| 6 | 6 | 
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" | 
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" | 
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" | 
| 10 | 10 | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25 // static | 25 // static | 
| 26 ProfilingGlobals* ProfilingGlobals::Get() { | 26 ProfilingGlobals* ProfilingGlobals::Get() { | 
| 27   static ProfilingGlobals singleton; | 27   static ProfilingGlobals singleton; | 
| 28   return &singleton; | 28   return &singleton; | 
| 29 } | 29 } | 
| 30 | 30 | 
| 31 base::TaskRunner* ProfilingGlobals::GetIORunner() { | 31 base::TaskRunner* ProfilingGlobals::GetIORunner() { | 
| 32   return io_thread_.task_runner().get(); | 32   return io_thread_.task_runner().get(); | 
| 33 } | 33 } | 
| 34 | 34 | 
|  | 35 MemlogConnectionManager* ProfilingGlobals::GetMemlogConnectionManager() { | 
|  | 36   return &memlog_connection_manager_; | 
|  | 37 } | 
|  | 38 | 
|  | 39 BacktraceStorage* ProfilingGlobals::GetBacktraceStorage() { | 
|  | 40   return &backtrace_storage_; | 
|  | 41 } | 
|  | 42 | 
| 35 scoped_refptr<base::SingleThreadTaskRunner> ProfilingGlobals::GetMainThread() | 43 scoped_refptr<base::SingleThreadTaskRunner> ProfilingGlobals::GetMainThread() | 
| 36     const { | 44     const { | 
| 37   CHECK(base::MessageLoop::current() == main_message_loop_); | 45   CHECK(base::MessageLoop::current() == main_message_loop_); | 
| 38   return main_message_loop_->task_runner(); | 46   return main_message_loop_->task_runner(); | 
| 39 } | 47 } | 
| 40 | 48 | 
| 41 void ProfilingGlobals::RunMainMessageLoop() { | 49 void ProfilingGlobals::RunMainMessageLoop() { | 
| 42   // TODO(brettw) if we never add anything interesting on the main thread here, | 50   // 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 | 51   // we can change this so the main thread *is* the I/O thread. This will save | 
| 44   // some resources. | 52   // some resources. | 
| 45   base::MessageLoopForUI message_loop; | 53   base::MessageLoopForUI message_loop; | 
| 46   DCHECK(!main_message_loop_); | 54   DCHECK(!main_message_loop_); | 
| 47   main_message_loop_ = &message_loop; | 55   main_message_loop_ = &message_loop; | 
| 48 | 56 | 
| 49   base::RunLoop run_loop; | 57   base::RunLoop run_loop; | 
| 50   run_loop.Run(); | 58   run_loop.Run(); | 
| 51 | 59 | 
| 52   main_message_loop_ = nullptr; | 60   main_message_loop_ = nullptr; | 
| 53 } | 61 } | 
| 54 | 62 | 
| 55 void ProfilingGlobals::QuitWhenIdle() { | 63 void ProfilingGlobals::QuitWhenIdle() { | 
| 56   main_message_loop_->QuitWhenIdle(); | 64   main_message_loop_->QuitWhenIdle(); | 
| 57 } | 65 } | 
| 58 | 66 | 
| 59 }  // namespace profiling | 67 }  // namespace profiling | 
| OLD | NEW | 
|---|