summaryrefslogtreecommitdiffstats
path: root/base/win/scoped_hdc.h
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-07 21:42:23 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-07 21:42:23 +0000
commit95f14bf54cbbca1a2dd77999149f595c14ca18a7 (patch)
tree831393a6b15c78dbe40df420df50eb0731502941 /base/win/scoped_hdc.h
parentde600ff6c6ff4ae5ea327d3f5ea3017acb2d77f7 (diff)
downloadchromium_src-95f14bf54cbbca1a2dd77999149f595c14ca18a7.zip
chromium_src-95f14bf54cbbca1a2dd77999149f595c14ca18a7.tar.gz
chromium_src-95f14bf54cbbca1a2dd77999149f595c14ca18a7.tar.bz2
Make ScopedGetDC() CHECK fail if GetDC(NULL) returns NULL.
Use scoping objects more in the omnibox code. BUG=110105 TEST=none Review URL: https://chromiumcodereview.appspot.com/10545045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win/scoped_hdc.h')
-rw-r--r--base/win/scoped_hdc.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/base/win/scoped_hdc.h b/base/win/scoped_hdc.h
index 9e2ea62..070c656 100644
--- a/base/win/scoped_hdc.h
+++ b/base/win/scoped_hdc.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -21,8 +21,15 @@ class ScopedGetDC {
explicit ScopedGetDC(HWND hwnd)
: hwnd_(hwnd),
hdc_(GetDC(hwnd)) {
- DCHECK(!hwnd_ || IsWindow(hwnd_));
- DCHECK(hdc_);
+ if (hwnd_) {
+ DCHECK(IsWindow(hwnd_));
+ DCHECK(hdc_);
+ } else {
+ // If GetDC(NULL) returns NULL, something really bad has happened, like
+ // GDI handle exhaustion. In this case Chrome is going to behave badly no
+ // matter what, so we may as well just force a crash now.
+ CHECK(hdc_);
+ }
}
~ScopedGetDC() {