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

Side by Side Diff: content/browser/browser_main_runner.cc

Issue 19957002: Run the later parts of startup as UI thread tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run the later parts of startup as UI thread tasks - patch for Yaron's comments Created 7 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/browser/browser_main_runner.h" 5 #include "content/public/browser/browser_main_runner.h"
6 6
7 #include "base/allocator/allocator_shim.h" 7 #include "base/allocator/allocator_shim.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 22 matching lines...) Expand all
33 : is_initialized_(false), 33 : is_initialized_(false),
34 is_shutdown_(false), 34 is_shutdown_(false),
35 created_threads_(false) { 35 created_threads_(false) {
36 } 36 }
37 37
38 virtual ~BrowserMainRunnerImpl() { 38 virtual ~BrowserMainRunnerImpl() {
39 if (is_initialized_ && !is_shutdown_) 39 if (is_initialized_ && !is_shutdown_)
40 Shutdown(); 40 Shutdown();
41 } 41 }
42 42
43 virtual int Initialize(const MainFunctionParams& parameters) 43 virtual int Initialize(
44 OVERRIDE { 44 const MainFunctionParams& parameters,
45 const scoped_refptr<StartupTaskRunner>& task_runner) OVERRIDE {
Yaron 2013/07/25 00:05:17 Does this need to be a refptr? Couldn't ownership
aberent 2013/07/26 20:36:54 This has gone away due a restructuring following J
45 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize") 46 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize")
46 is_initialized_ = true; 47 is_initialized_ = true;
47 48
48 #if !defined(OS_IOS) 49 #if !defined(OS_IOS)
49 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) 50 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger))
50 base::debug::WaitForDebugger(60, true); 51 base::debug::WaitForDebugger(60, true);
51 #endif 52 #endif
52 53
53 #if defined(OS_WIN) 54 #if defined(OS_WIN)
54 if (parameters.command_line.HasSwitch( 55 if (parameters.command_line.HasSwitch(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 #if defined(OS_WIN) && !defined(NO_TCMALLOC) 97 #if defined(OS_WIN) && !defined(NO_TCMALLOC)
97 // When linking shared libraries, NO_TCMALLOC is defined, and dynamic 98 // When linking shared libraries, NO_TCMALLOC is defined, and dynamic
98 // allocator selection is not supported. 99 // allocator selection is not supported.
99 100
100 // Make this call before going multithreaded, or spawning any subprocesses. 101 // Make this call before going multithreaded, or spawning any subprocesses.
101 base::allocator::SetupSubprocessAllocator(); 102 base::allocator::SetupSubprocessAllocator();
102 #endif 103 #endif
103 ui::InitializeInputMethod(); 104 ui::InitializeInputMethod();
104 105
105 main_loop_->CreateThreads(); 106 main_loop_->CreateStartupTasks(task_runner);
106 int result_code = main_loop_->GetResultCode(); 107 int result_code = main_loop_->GetResultCode();
107 if (result_code > 0) 108 if (result_code > 0)
108 return result_code; 109 return result_code;
109 created_threads_ = true; 110 created_threads_ = true;
110 111
111 // Return -1 to indicate no early termination. 112 // Return -1 to indicate no early termination.
112 return -1; 113 return -1;
113 } 114 }
114 115
115 virtual int Run() OVERRIDE { 116 virtual int Run() OVERRIDE {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 159 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
159 }; 160 };
160 161
161 // static 162 // static
162 BrowserMainRunner* BrowserMainRunner::Create() { 163 BrowserMainRunner* BrowserMainRunner::Create() {
163 return new BrowserMainRunnerImpl(); 164 return new BrowserMainRunnerImpl();
164 } 165 }
165 166
166 } // namespace content 167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698