Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: base/base_drop_target.cc

Issue 5009: Fix some issues found looking at the code.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 5 #include "base/base_drop_target.h"
6
6 #include <shlobj.h> 7 #include <shlobj.h>
7 8
8 #include "base/base_drop_target.h"
9
10 #include "base/logging.h" 9 #include "base/logging.h"
11 10
12 /////////////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////////////
13 12
14 IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL; 13 IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL;
15 14
16 BaseDropTarget::BaseDropTarget(HWND hwnd) 15 BaseDropTarget::BaseDropTarget(HWND hwnd)
17 : suspend_(false), 16 : hwnd_(hwnd),
18 ref_count_(0), 17 suspend_(false),
19 hwnd_(hwnd) { 18 ref_count_(0) {
20 DCHECK(hwnd); 19 DCHECK(hwnd);
21 HRESULT result = RegisterDragDrop(hwnd, this); 20 HRESULT result = RegisterDragDrop(hwnd, this);
21 DCHECK(SUCCEEDED(result));
22 } 22 }
23 23
24 BaseDropTarget::~BaseDropTarget() { 24 BaseDropTarget::~BaseDropTarget() {
Dean McNamee 2008/09/30 20:47:26 Maybe just put this on one line
cpu_(ooo_6.6-7.5) 2008/09/30 23:35:05 I rather have a way to put a breakpoint in the dto
25
25 } 26 }
26 27
27 // static 28 // static
28 IDropTargetHelper* BaseDropTarget::DropHelper() { 29 IDropTargetHelper* BaseDropTarget::DropHelper() {
29 if (!cached_drop_target_helper_) { 30 if (!cached_drop_target_helper_) {
30 CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, 31 CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
31 IID_IDropTargetHelper, 32 IID_IDropTargetHelper,
32 reinterpret_cast<void**>(&cached_drop_target_helper_)); 33 reinterpret_cast<void**>(&cached_drop_target_helper_));
33 } 34 }
34 return cached_drop_target_helper_; 35 return cached_drop_target_helper_;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropTarget)) { 119 if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropTarget)) {
119 *object = this; 120 *object = this;
120 } else { 121 } else {
121 return E_NOINTERFACE; 122 return E_NOINTERFACE;
122 } 123 }
123 AddRef(); 124 AddRef();
124 return S_OK; 125 return S_OK;
125 } 126 }
126 127
127 ULONG BaseDropTarget::AddRef() { 128 ULONG BaseDropTarget::AddRef() {
128 return InterlockedIncrement(&ref_count_); 129 return ++ref_count_;
129 } 130 }
130 131
131 ULONG BaseDropTarget::Release() { 132 ULONG BaseDropTarget::Release() {
132 if (InterlockedDecrement(&ref_count_) == 0) { 133 if (--ref_count_ == 0) {
133 ULONG copied_refcnt = ref_count_;
134 delete this; 134 delete this;
135 return copied_refcnt; 135 return 0U;
136 } 136 }
137 return ref_count_; 137 return ref_count_;
138 } 138 }
139 139
140 DWORD BaseDropTarget::OnDragEnter(IDataObject* data_object, 140 DWORD BaseDropTarget::OnDragEnter(IDataObject* data_object,
141 DWORD key_state, 141 DWORD key_state,
142 POINT cursor_position, 142 POINT cursor_position,
143 DWORD effect) { 143 DWORD effect) {
144 return DROPEFFECT_NONE; 144 return DROPEFFECT_NONE;
145 } 145 }
146 146
147 DWORD BaseDropTarget::OnDragOver(IDataObject* data_object, 147 DWORD BaseDropTarget::OnDragOver(IDataObject* data_object,
148 DWORD key_state, 148 DWORD key_state,
149 POINT cursor_position, 149 POINT cursor_position,
150 DWORD effect) { 150 DWORD effect) {
151 return DROPEFFECT_NONE; 151 return DROPEFFECT_NONE;
152 } 152 }
153 153
154 void BaseDropTarget::OnDragLeave(IDataObject* data_object) { 154 void BaseDropTarget::OnDragLeave(IDataObject* data_object) {
155 } 155 }
156 156
157 DWORD BaseDropTarget::OnDrop(IDataObject* data_object, 157 DWORD BaseDropTarget::OnDrop(IDataObject* data_object,
158 DWORD key_state, 158 DWORD key_state,
159 POINT cursor_position, 159 POINT cursor_position,
160 DWORD effect) { 160 DWORD effect) {
161 return DROPEFFECT_NONE; 161 return DROPEFFECT_NONE;
162 } 162 }
163 163
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698