summaryrefslogtreecommitdiffstats
path: root/base/base_drop_target.cc
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-30 20:50:51 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-30 20:50:51 +0000
commitc7f4b627c4dde3c801649e28eea82e581797590c (patch)
treeb1044b55a28089f8eaaa529355413fa02e0494a2 /base/base_drop_target.cc
parent777c7bff9d40214069752a8ca91ade106a60536b (diff)
downloadchromium_src-c7f4b627c4dde3c801649e28eea82e581797590c.zip
chromium_src-c7f4b627c4dde3c801649e28eea82e581797590c.tar.gz
chromium_src-c7f4b627c4dde3c801649e28eea82e581797590c.tar.bz2
Fix some issues found looking at the code.
Patch from Gaetano Mendola <mendola@gmail.com> Original review: http://codereview.chromium.org/4273 I added some additions on my part and two unit test fix due to the added DCHECK. Reduced atl header inclusion. Review URL: http://codereview.chromium.org/5009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/base_drop_target.cc')
-rw-r--r--base/base_drop_target.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/base/base_drop_target.cc b/base/base_drop_target.cc
index 7c1790e..9809255 100644
--- a/base/base_drop_target.cc
+++ b/base/base_drop_target.cc
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <windows.h>
-#include <shlobj.h>
-
#include "base/base_drop_target.h"
+#include <shlobj.h>
+
#include "base/logging.h"
///////////////////////////////////////////////////////////////////////////////
@@ -14,11 +13,12 @@
IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL;
BaseDropTarget::BaseDropTarget(HWND hwnd)
- : suspend_(false),
- ref_count_(0),
- hwnd_(hwnd) {
+ : hwnd_(hwnd),
+ suspend_(false),
+ ref_count_(0) {
DCHECK(hwnd);
HRESULT result = RegisterDragDrop(hwnd, this);
+ DCHECK(SUCCEEDED(result));
}
BaseDropTarget::~BaseDropTarget() {
@@ -125,14 +125,13 @@ HRESULT BaseDropTarget::QueryInterface(const IID& iid, void** object) {
}
ULONG BaseDropTarget::AddRef() {
- return InterlockedIncrement(&ref_count_);
+ return ++ref_count_;
}
ULONG BaseDropTarget::Release() {
- if (InterlockedDecrement(&ref_count_) == 0) {
- ULONG copied_refcnt = ref_count_;
+ if (--ref_count_ == 0) {
delete this;
- return copied_refcnt;
+ return 0U;
}
return ref_count_;
}