summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-01 19:46:46 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-01 19:46:46 +0000
commitc279bff31d1c989b13adffad9e82a64bace4945a (patch)
treeabbd45bf4e9bdf57dde11b82e9209cac3f315aa3
parent8ef8d41fd3db72f5857d945055c1b629a1220b3e (diff)
downloadchromium_src-c279bff31d1c989b13adffad9e82a64bace4945a.zip
chromium_src-c279bff31d1c989b13adffad9e82a64bace4945a.tar.gz
chromium_src-c279bff31d1c989b13adffad9e82a64bace4945a.tar.bz2
Static initializers: Remove <iostream> include from GPU logging system.
GPU can't rely on base because of nacl so it has its own logger. The logger includes <iostream> in the header, so most gles2 and command buffer files have std::__ioinit static initializers. Create a common logging.cc which has a simple method that just returns std::cerr so all the __ioinits collapse down to one. BUG=94794 TEST=compiles R=apatrick TBR=noelallen Review URL: http://codereview.chromium.org/7821004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99229 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/command_buffer/common/logging.cc24
-rw-r--r--gpu/command_buffer/common/logging.h18
-rw-r--r--gpu/gpu.gyp1
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/nacl.scons2
4 files changed, 35 insertions, 10 deletions
diff --git a/gpu/command_buffer/common/logging.cc b/gpu/command_buffer/common/logging.cc
new file mode 100644
index 0000000..4bc3510
--- /dev/null
+++ b/gpu/command_buffer/common/logging.cc
@@ -0,0 +1,24 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/common/logging.h"
+
+#include <iostream>
+
+namespace gpu {
+
+std::ostream& Logger::stream() {
+ return std::cerr;
+}
+
+Logger::~Logger() {
+ if (!condition_) {
+ std::cerr << std::endl;
+ std::cerr.flush();
+ if (level_ == FATAL)
+ assert(false);
+ }
+}
+
+} // namespace gpu
diff --git a/gpu/command_buffer/common/logging.h b/gpu/command_buffer/common/logging.h
index 6f8c99e..47d0b4dc 100644
--- a/gpu/command_buffer/common/logging.h
+++ b/gpu/command_buffer/common/logging.h
@@ -7,7 +7,7 @@
#include <assert.h>
-#include <iostream>
+#include <ostream>
// Windows defines an ERROR macro.
#ifdef ERROR
@@ -132,19 +132,17 @@ class Logger {
<< y_name << "(" << y << ")) failed. ";
}
- ~Logger() {
- if (!condition_) {
- std::cerr << std::endl;
- std::cerr.flush();
- if (level_ == FATAL)
- assert(false);
- }
- }
+ // Retrieves the stream that we write to. This header cannot depend on
+ // <iostream> because that will add static initializers to all files that
+ // include this header.
+ std::ostream& stream();
+
+ ~Logger();
template <typename T>
Logger& operator<<(const T& value) {
if (!condition_)
- std::cerr << value;
+ stream() << value;
return *this;
}
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index 6acbc8a..436545b 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -59,6 +59,7 @@
'command_buffer/common/gles2_cmd_utils.h',
'command_buffer/common/id_allocator.cc',
'command_buffer/common/id_allocator.h',
+ 'command_buffer/common/logging.cc',
'command_buffer/common/logging.h',
'command_buffer/common/thread_local.h',
'command_buffer/common/types.h',
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons
index 4b7a433..ee1531b 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons
+++ b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons
@@ -88,6 +88,8 @@ command_buffer_common_srcs = [
'command_buffer/common/cmd_buffer_common.cc',
'command_buffer/common/gles2_cmd_format.cc',
'command_buffer/common/gles2_cmd_utils.cc',
+ 'command_buffer/common/logging.cc',
+ 'command_buffer/common/logging.h',
]
command_buffer_client_srcs = [