PageLanguageDetectionTest has the failure rate of 5 - 6% on XP/Vista. Mark it
[chromium-blink-merge.git] / app / scoped_handle_gtk.h
blobd501f913d8221e8eabdf3c5e08b0e9b65b53610c
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef APP_SCOPED_HANDLE_GTK_H_
6 #define APP_SCOPED_HANDLE_GTK_H_
8 #include <gdk/gdk.h>
10 // Wraps a GdkRegion. This class provides the same methods as ScopedGDIObject in
11 // scoped_handle_win.
12 class ScopedRegion {
13 public:
14 ScopedRegion() : region_(NULL) {}
15 explicit ScopedRegion(GdkRegion* region) : region_(region) {}
17 ~ScopedRegion() {
18 Close();
21 void Set(GdkRegion* region) {
22 Close();
24 region_ = region;
27 GdkRegion* Get() {
28 return region_;
31 GdkRegion* release() {
32 GdkRegion* region = region_;
33 region_ = NULL;
34 return region;
37 private:
38 void Close() {
39 if (region_) {
40 gdk_region_destroy(region_);
41 region_ = NULL;
45 GdkRegion* region_;
47 DISALLOW_COPY_AND_ASSIGN(ScopedRegion);
50 #endif // APP_SCOPED_HANDLE_GTK_H_