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

Side by Side Diff: webkit/plugins/ppapi/callbacks_unittest.cc

Issue 8344025: Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/plugins/ppapi/host_globals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mergeinfo
Reverse-merged /branches/chrome_webkit_merge_branch/src/webkit/plugins/ppapi/callbacks_unittest.cc:r3734-4217,4606-5108,5177-5263
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 "webkit/plugins/ppapi/ppapi_unittest.h" 5 #include "webkit/plugins/ppapi/ppapi_unittest.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "webkit/plugins/ppapi/callbacks.h" 11 #include "webkit/plugins/ppapi/callbacks.h"
12 #include "webkit/plugins/ppapi/host_globals.h"
12 #include "webkit/plugins/ppapi/mock_resource.h" 13 #include "webkit/plugins/ppapi/mock_resource.h"
13 #include "webkit/plugins/ppapi/plugin_module.h" 14 #include "webkit/plugins/ppapi/plugin_module.h"
14 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
15 #include "webkit/plugins/ppapi/resource_helper.h" 16 #include "webkit/plugins/ppapi/resource_helper.h"
16 #include "webkit/plugins/ppapi/resource_tracker.h" 17 #include "webkit/plugins/ppapi/resource_tracker.h"
17 18
18 namespace webkit { 19 namespace webkit {
19 namespace ppapi { 20 namespace ppapi {
20 21
21 struct CallbackRunInfo { 22 struct CallbackRunInfo {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 } // namespace 179 } // namespace
179 180
180 class CallbackResourceTest : public PpapiUnittest { 181 class CallbackResourceTest : public PpapiUnittest {
181 public: 182 public:
182 CallbackResourceTest() {} 183 CallbackResourceTest() {}
183 }; 184 };
184 185
185 // Test that callbacks get aborted on the last resource unref. 186 // Test that callbacks get aborted on the last resource unref.
186 TEST_F(CallbackResourceTest, AbortOnNoRef) { 187 TEST_F(CallbackResourceTest, AbortOnNoRef) {
187 ResourceTracker* resource_tracker = ResourceTracker::Get(); 188 ResourceTracker* resource_tracker =
189 HostGlobals::Get()->host_resource_tracker();
188 190
189 // Test several things: Unref-ing a resource (to zero refs) with callbacks 191 // Test several things: Unref-ing a resource (to zero refs) with callbacks
190 // which (1) have been run, (2) have been aborted, (3) haven't been completed. 192 // which (1) have been run, (2) have been aborted, (3) haven't been completed.
191 // Check that the uncompleted one gets aborted, and that the others don't get 193 // Check that the uncompleted one gets aborted, and that the others don't get
192 // called again. 194 // called again.
193 scoped_refptr<CallbackMockResource> resource_1( 195 scoped_refptr<CallbackMockResource> resource_1(
194 new CallbackMockResource(instance()->pp_instance())); 196 new CallbackMockResource(instance()->pp_instance()));
195 PP_Resource resource_1_id = resource_1->SetupForTest(); 197 PP_Resource resource_1_id = resource_1->SetupForTest();
196 198
197 // Also do the same for a second resource, and make sure that unref-ing the 199 // Also do the same for a second resource, and make sure that unref-ing the
(...skipping 18 matching lines...) Expand all
216 resource_1->CheckFinalState(); 218 resource_1->CheckFinalState();
217 resource_2->CheckFinalState(); 219 resource_2->CheckFinalState();
218 220
219 // This shouldn't be needed, but make sure there are no stranded tasks. 221 // This shouldn't be needed, but make sure there are no stranded tasks.
220 MessageLoop::current()->RunAllPending(); 222 MessageLoop::current()->RunAllPending();
221 } 223 }
222 224
223 // Test that "resurrecting" a resource (getting a new ID for a |Resource|) 225 // Test that "resurrecting" a resource (getting a new ID for a |Resource|)
224 // doesn't resurrect callbacks. 226 // doesn't resurrect callbacks.
225 TEST_F(CallbackResourceTest, Resurrection) { 227 TEST_F(CallbackResourceTest, Resurrection) {
226 ResourceTracker* resource_tracker = ResourceTracker::Get(); 228 ResourceTracker* resource_tracker =
229 HostGlobals::Get()->host_resource_tracker();
227 230
228 scoped_refptr<CallbackMockResource> resource( 231 scoped_refptr<CallbackMockResource> resource(
229 new CallbackMockResource(instance()->pp_instance())); 232 new CallbackMockResource(instance()->pp_instance()));
230 PP_Resource resource_id = resource->SetupForTest(); 233 PP_Resource resource_id = resource->SetupForTest();
231 234
232 // Unref it, spin the message loop to run posted calls, and check that things 235 // Unref it, spin the message loop to run posted calls, and check that things
233 // are in the expected states. 236 // are in the expected states.
234 resource_tracker->ReleaseResource(resource_id); 237 resource_tracker->ReleaseResource(resource_id);
235 MessageLoop::current()->RunAllPending(); 238 MessageLoop::current()->RunAllPending();
236 resource->CheckFinalState(); 239 resource->CheckFinalState();
237 240
238 // "Resurrect" it and check that the callbacks are still dead. 241 // "Resurrect" it and check that the callbacks are still dead.
239 PP_Resource new_resource_id = resource->GetReference(); 242 PP_Resource new_resource_id = resource->GetReference();
240 MessageLoop::current()->RunAllPending(); 243 MessageLoop::current()->RunAllPending();
241 resource->CheckFinalState(); 244 resource->CheckFinalState();
242 245
243 // Unref it again and do the same. 246 // Unref it again and do the same.
244 resource_tracker->ReleaseResource(new_resource_id); 247 resource_tracker->ReleaseResource(new_resource_id);
245 MessageLoop::current()->RunAllPending(); 248 MessageLoop::current()->RunAllPending();
246 resource->CheckFinalState(); 249 resource->CheckFinalState();
247 250
248 // This shouldn't be needed, but make sure there are no stranded tasks. 251 // This shouldn't be needed, but make sure there are no stranded tasks.
249 MessageLoop::current()->RunAllPending(); 252 MessageLoop::current()->RunAllPending();
250 } 253 }
251 254
252 } // namespace ppapi 255 } // namespace ppapi
253 } // namespace webkit 256 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/plugins/ppapi/host_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698