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

Side by Side Diff: chrome_frame/vtable_patch_manager_unittest.cc

Issue 6336010: Add missing base::lock usage. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « chrome_frame/protocol_sink_wrap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome_frame/vtable_patch_manager.h" 5 #include "chrome_frame/vtable_patch_manager.h"
6 6
7 #include <unknwn.h> 7 #include <unknwn.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Patch it again, this should be idempotent. 193 // Patch it again, this should be idempotent.
194 EXPECT_HRESULT_SUCCEEDED( 194 EXPECT_HRESULT_SUCCEEDED(
195 PatchInterfaceMethods(&factory_, IClassFactory_PatchInfo)); 195 PatchInterfaceMethods(&factory_, IClassFactory_PatchInfo));
196 196
197 // Should not have changed the VTable on second call. 197 // Should not have changed the VTable on second call.
198 EXPECT_EQ(0, memcmp(vtable, GetVtable(&factory_), sizeof(vtable))); 198 EXPECT_EQ(0, memcmp(vtable, GetVtable(&factory_), sizeof(vtable)));
199 } 199 }
200 200
201 namespace vtable_patch { 201 namespace vtable_patch {
202 // Expose internal implementation detail, purely for testing. 202 // Expose internal implementation detail, purely for testing.
203 extern Lock patch_lock_; 203 extern base::Lock patch_lock_;
204 204
205 } // namespace vtable_patch 205 } // namespace vtable_patch
206 206
207 TEST_F(VtablePatchManagerTest, ThreadSafePatching) { 207 TEST_F(VtablePatchManagerTest, ThreadSafePatching) {
208 // It's difficult to test for threadsafe patching, but as a close proxy, 208 // It's difficult to test for threadsafe patching, but as a close proxy,
209 // test for no patching happening from a background thread while the patch 209 // test for no patching happening from a background thread while the patch
210 // lock is held. 210 // lock is held.
211 base::Thread background("Background Test Thread"); 211 base::Thread background("Background Test Thread");
212 212
213 EXPECT_TRUE(background.Start()); 213 EXPECT_TRUE(background.Start());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 // Release the patch lock and wait on the event. 282 // Release the patch lock and wait on the event.
283 vtable_patch::patch_lock_.Release(); 283 vtable_patch::patch_lock_.Release();
284 EXPECT_EQ(WAIT_OBJECT_0, ::WaitForSingleObject(event.Get(), INFINITE)); 284 EXPECT_EQ(WAIT_OBJECT_0, ::WaitForSingleObject(event.Get(), INFINITE));
285 285
286 // Verify that unpatching took place. 286 // Verify that unpatching took place.
287 EXPECT_CALL(factory_, LockServer(TRUE)) 287 EXPECT_CALL(factory_, LockServer(TRUE))
288 .WillOnce(Return(S_FALSE)); 288 .WillOnce(Return(S_FALSE));
289 EXPECT_EQ(S_FALSE, factory_.LockServer(TRUE)); 289 EXPECT_EQ(S_FALSE, factory_.LockServer(TRUE));
290 } 290 }
OLDNEW
« no previous file with comments | « chrome_frame/protocol_sink_wrap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698