| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "app/win/scoped_prop.h" | 5 #include "app/win/scoped_prop.h" |
| 6 | 6 |
| 7 #include "base/win_util.h" | 7 #include "base/win_util.h" |
| 8 | 8 |
| 9 namespace app { | 9 namespace app { |
| 10 | 10 |
| 11 namespace win { | 11 namespace win { |
| 12 | 12 |
| 13 ScopedProp::ScopedProp(HWND hwnd, const std::wstring& key, HANDLE data) | 13 ScopedProp::ScopedProp(HWND hwnd, const std::wstring& key, HANDLE data) |
| 14 : hwnd_(hwnd), | 14 : hwnd_(hwnd), |
| 15 key_(key) { | 15 key_(key) { |
| 16 BOOL result = SetProp(hwnd, key.c_str(), data); | 16 BOOL result = SetProp(hwnd, key.c_str(), data); |
| 17 // Failure to set a propery on a window is typically fatal. It means someone | 17 // Failure to set a propery on a window is typically fatal. It means someone |
| 18 // is going to ask for the property and get NULL. So, rather than crash later | 18 // is going to ask for the property and get NULL. So, rather than crash later |
| 19 // on when someone expects a non-NULL value we crash here in hopes of | 19 // on when someone expects a non-NULL value we crash here in hopes of |
| 20 // diagnosing the failure. | 20 // diagnosing the failure. |
| 21 CHECK(result) << win_util::FormatLastWin32Error(); | 21 CHECK(result) << ::GetLastError(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 ScopedProp::~ScopedProp() { | 24 ScopedProp::~ScopedProp() { |
| 25 DCHECK(IsWindow(hwnd_)); | 25 DCHECK(IsWindow(hwnd_)); |
| 26 RemoveProp(hwnd_, key_.c_str()); | 26 RemoveProp(hwnd_, key_.c_str()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 } // namespace win | 30 } // namespace win |
| 31 | 31 |
| 32 } // namespace app | 32 } // namespace app |
| OLD | NEW |