Commit db04bc30 authored by sadrul's avatar sadrul Committed by Commit bot

gpu: Maintain the deferred log messages separately from the IPC messages.

Instead of keeping a queue of IPC messages in GpuChildThread for the
deferred log messages that are sent to the browser, maintain a queue of
structs describing the log messages. This makes it easier to follow the
code, and easier to replace the chrome IPC with mojo IPC in subsequent
patches.

BUG=643746

Review-Url: https://codereview.chromium.org/2599203003
Cr-Commit-Position: refs/heads/master@{#441318}
parent 7a1a53c1
...@@ -187,10 +187,6 @@ GpuChildThread::GpuChildThread( ...@@ -187,10 +187,6 @@ GpuChildThread::GpuChildThread(
} }
GpuChildThread::~GpuChildThread() { GpuChildThread::~GpuChildThread() {
while (!deferred_messages_.empty()) {
delete deferred_messages_.front();
deferred_messages_.pop();
}
} }
void GpuChildThread::Shutdown() { void GpuChildThread::Shutdown() {
...@@ -320,7 +316,8 @@ void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { ...@@ -320,7 +316,8 @@ void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
gpu_info_.initialization_time = base::Time::Now() - process_start_time_; gpu_info_.initialization_time = base::Time::Now() - process_start_time_;
Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_));
while (!deferred_messages_.empty()) { while (!deferred_messages_.empty()) {
Send(deferred_messages_.front()); const LogMessage& log = deferred_messages_.front();
Send(new GpuHostMsg_OnLogMessage(log.severity, log.header, log.message));
deferred_messages_.pop(); deferred_messages_.pop();
} }
......
...@@ -56,7 +56,12 @@ class GpuChildThread : public ChildThreadImpl, ...@@ -56,7 +56,12 @@ class GpuChildThread : public ChildThreadImpl,
public gpu::GpuChannelManagerDelegate, public gpu::GpuChannelManagerDelegate,
public base::FieldTrialList::Observer { public base::FieldTrialList::Observer {
public: public:
typedef std::queue<IPC::Message*> DeferredMessages; struct LogMessage {
int severity;
std::string header;
std::string message;
};
typedef std::queue<LogMessage> DeferredMessages;
GpuChildThread(std::unique_ptr<gpu::GpuWatchdogThread> gpu_watchdog_thread, GpuChildThread(std::unique_ptr<gpu::GpuWatchdogThread> gpu_watchdog_thread,
bool dead_on_arrival, bool dead_on_arrival,
......
...@@ -106,10 +106,11 @@ bool GpuProcessLogMessageHandler(int severity, ...@@ -106,10 +106,11 @@ bool GpuProcessLogMessageHandler(int severity,
const char* file, int line, const char* file, int line,
size_t message_start, size_t message_start,
const std::string& str) { const std::string& str) {
std::string header = str.substr(0, message_start); GpuChildThread::LogMessage log;
std::string message = str.substr(message_start); log.severity = severity;
deferred_messages.Get().push( log.header = str.substr(0, message_start);
new GpuHostMsg_OnLogMessage(severity, header, message)); log.message = str.substr(message_start);
deferred_messages.Get().push(std::move(log));
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment