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

Side by Side Diff: content/gpu/gpu_main.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert slow, try adding back handlers Created 3 years, 11 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 #if defined(OS_LINUX) 96 #if defined(OS_LINUX)
97 bool StartSandboxLinux(gpu::GpuWatchdogThread*); 97 bool StartSandboxLinux(gpu::GpuWatchdogThread*);
98 #elif defined(OS_WIN) 98 #elif defined(OS_WIN)
99 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); 99 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*);
100 #endif 100 #endif
101 101
102 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = 102 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages =
103 LAZY_INSTANCE_INITIALIZER; 103 LAZY_INSTANCE_INITIALIZER;
104 104
105 bool GpuProcessLogMessageHandler(int severity, 105 class GpuMainLogMessageListener : logging::LogMessageListener {
106 const char* file, int line, 106 public:
107 size_t message_start, 107 void OnMessage(int severity,
108 const std::string& str) { 108 const char* file,
109 int line,
110 size_t message_start,
111 const std::string& str) override;
112 };
113
114 void GpuMainLogMessageListener::OnMessage(int severity,
115 const char* file,
116 int line,
117 size_t message_start,
118 const std::string& str) {
109 std::string header = str.substr(0, message_start); 119 std::string header = str.substr(0, message_start);
110 std::string message = str.substr(message_start); 120 std::string message = str.substr(message_start);
111 deferred_messages.Get().push( 121 deferred_messages.Get().push(
112 new GpuHostMsg_OnLogMessage(severity, header, message)); 122 new GpuHostMsg_OnLogMessage(severity, header, message));
113 return false;
114 } 123 }
115 124
116 class ContentSandboxHelper : public gpu::GpuSandboxHelper { 125 class ContentSandboxHelper : public gpu::GpuSandboxHelper {
117 public: 126 public:
118 ContentSandboxHelper() {} 127 ContentSandboxHelper() {}
119 ~ContentSandboxHelper() override {} 128 ~ContentSandboxHelper() override {}
120 129
121 #if defined(OS_WIN) 130 #if defined(OS_WIN)
122 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { 131 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) {
123 sandbox_info_ = info; 132 sandbox_info_ = info;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // able to load a DLL. 194 // able to load a DLL.
186 SetErrorMode( 195 SetErrorMode(
187 SEM_FAILCRITICALERRORS | 196 SEM_FAILCRITICALERRORS |
188 SEM_NOGPFAULTERRORBOX | 197 SEM_NOGPFAULTERRORBOX |
189 SEM_NOOPENFILEERRORBOX); 198 SEM_NOOPENFILEERRORBOX);
190 #elif defined(USE_X11) 199 #elif defined(USE_X11)
191 ui::SetDefaultX11ErrorHandlers(); 200 ui::SetDefaultX11ErrorHandlers();
192 201
193 #endif 202 #endif
194 203
195 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); 204 auto log_listener = base::MakeUnique<GpuMainLogMessageListener>();
196 205
197 // We are experiencing what appear to be memory-stomp issues in the GPU 206 // We are experiencing what appear to be memory-stomp issues in the GPU
198 // process. These issues seem to be impacting the message loop and listeners 207 // process. These issues seem to be impacting the message loop and listeners
199 // registered to it. Create the message loop on the heap to guard against 208 // registered to it. Create the message loop on the heap to guard against
200 // this. 209 // this.
201 // TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802 210 // TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802
202 // and crbug.com/609252. 211 // and crbug.com/609252.
203 std::unique_ptr<base::MessageLoop> main_message_loop; 212 std::unique_ptr<base::MessageLoop> main_message_loop;
204 std::unique_ptr<ui::PlatformEventSource> event_source; 213 std::unique_ptr<ui::PlatformEventSource> event_source;
205 if (command_line.HasSwitch(switches::kHeadless)) { 214 if (command_line.HasSwitch(switches::kHeadless)) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // to tear down this process. However, we can not do so safely until the IPC 267 // to tear down this process. However, we can not do so safely until the IPC
259 // channel is set up, because the detection of early return of a child process 268 // channel is set up, because the detection of early return of a child process
260 // is implemented using an IPC channel error. If the IPC channel is not fully 269 // is implemented using an IPC channel error. If the IPC channel is not fully
261 // set up between the browser and GPU process, and the GPU process crashes or 270 // set up between the browser and GPU process, and the GPU process crashes or
262 // exits early, the browser process will never detect it. For this reason we 271 // exits early, the browser process will never detect it. For this reason we
263 // defer tearing down the GPU process until receiving the GpuMsg_Initialize 272 // defer tearing down the GPU process until receiving the GpuMsg_Initialize
264 // message from the browser. 273 // message from the browser.
265 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); 274 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line);
266 const bool dead_on_arrival = !init_success; 275 const bool dead_on_arrival = !init_success;
267 276
268 logging::SetLogMessageHandler(NULL); 277 log_listener.reset();
269 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); 278 GetContentClient()->SetGpuInfo(gpu_init.gpu_info());
270 279
271 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; 280 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory;
272 if (init_success && 281 if (init_success &&
273 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) 282 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER)
274 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); 283 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType();
275 284
276 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; 285 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL;
277 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 286 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
278 io_thread_priority = base::ThreadPriority::DISPLAY; 287 io_thread_priority = base::ThreadPriority::DISPLAY;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return true; 365 return true;
357 } 366 }
358 367
359 return false; 368 return false;
360 } 369 }
361 #endif // defined(OS_WIN) 370 #endif // defined(OS_WIN)
362 371
363 } // namespace. 372 } // namespace.
364 373
365 } // namespace content 374 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698