Compute can_use_lcd_text using property trees.
[chromium-blink-merge.git] / base / mac / scoped_launch_data.h
blobe4343b89399ecf87d3a16504b77294b5fc48f9c9
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
3 // found in the LICENSE file.
5 #ifndef BASE_MAC_SCOPED_LAUNCH_DATA_H_
6 #define BASE_MAC_SCOPED_LAUNCH_DATA_H_
8 #include <launch.h>
10 #include <algorithm>
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
15 namespace base {
16 namespace mac {
18 // Just like scoped_ptr<> but for launch_data_t.
19 class ScopedLaunchData {
20 public:
21 typedef launch_data_t element_type;
23 explicit ScopedLaunchData(launch_data_t object = NULL)
24 : object_(object) {
27 ~ScopedLaunchData() {
28 if (object_)
29 launch_data_free(object_);
32 void reset(launch_data_t object = NULL) {
33 if (object != object_) {
34 if (object_)
35 launch_data_free(object_);
36 object_ = object;
40 bool operator==(launch_data_t that) const {
41 return object_ == that;
44 bool operator!=(launch_data_t that) const {
45 return object_ != that;
48 operator launch_data_t() const {
49 return object_;
52 launch_data_t get() const {
53 return object_;
56 void swap(ScopedLaunchData& that) {
57 std::swap(object_, that.object_);
60 launch_data_t release() WARN_UNUSED_RESULT {
61 launch_data_t temp = object_;
62 object_ = NULL;
63 return temp;
66 private:
67 launch_data_t object_;
69 DISALLOW_COPY_AND_ASSIGN(ScopedLaunchData);
72 } // namespace mac
73 } // namespace base
75 #endif // BASE_MAC_SCOPED_LAUNCH_DATA_H_