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

Side by Side Diff: cc/test/test_context_support.cc

Issue 120913004: aura: Ensure OwnedMailbox not used with invalid or destroyed GLHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ownedmailbox: expectfalse Created 6 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 | « no previous file | content/browser/aura/owned_mailbox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/test/test_context_support.h" 5 #include "cc/test/test_context_support.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 TestContextSupport::TestContextSupport() 12 TestContextSupport::TestContextSupport()
13 : last_swap_type_(NO_SWAP), 13 : last_swap_type_(NO_SWAP),
14 weak_ptr_factory_(this) { 14 weak_ptr_factory_(this) {
15 } 15 }
16 16
17 TestContextSupport::~TestContextSupport() {} 17 TestContextSupport::~TestContextSupport() {}
18 18
19 void TestContextSupport::SignalSyncPoint(uint32 sync_point, 19 void TestContextSupport::SignalSyncPoint(uint32 sync_point,
20 const base::Closure& callback) { 20 const base::Closure& callback) {
21 sync_point_callbacks_.push_back(callback); 21 sync_point_callbacks_.push_back(callback);
22 base::MessageLoop::current()->PostTask(
23 FROM_HERE,
24 base::Bind(&TestContextSupport::CallAllSyncPointCallbacks,
25 weak_ptr_factory_.GetWeakPtr()));
22 } 26 }
23 27
24 void TestContextSupport::SignalQuery(uint32 query, 28 void TestContextSupport::SignalQuery(uint32 query,
25 const base::Closure& callback) { 29 const base::Closure& callback) {
26 sync_point_callbacks_.push_back(callback); 30 sync_point_callbacks_.push_back(callback);
31 base::MessageLoop::current()->PostTask(
32 FROM_HERE,
33 base::Bind(&TestContextSupport::CallAllSyncPointCallbacks,
34 weak_ptr_factory_.GetWeakPtr()));
27 } 35 }
28 36
29 void TestContextSupport::SetSurfaceVisible(bool visible) { 37 void TestContextSupport::SetSurfaceVisible(bool visible) {
30 if (!set_visible_callback_.is_null()) { 38 if (!set_visible_callback_.is_null()) {
31 set_visible_callback_.Run(visible); 39 set_visible_callback_.Run(visible);
32 } 40 }
33 } 41 }
34 42
35 void TestContextSupport::SendManagedMemoryStats( 43 void TestContextSupport::SendManagedMemoryStats(
36 const gpu::ManagedMemoryStats& stats) {} 44 const gpu::ManagedMemoryStats& stats) {}
37 45
38 void TestContextSupport::CallAllSyncPointCallbacks() { 46 void TestContextSupport::CallAllSyncPointCallbacks() {
39 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { 47 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) {
40 base::MessageLoop::current()->PostTask( 48 base::MessageLoop::current()->PostTask(
41 FROM_HERE, sync_point_callbacks_[i]); 49 FROM_HERE, sync_point_callbacks_[i]);
42 } 50 }
43 sync_point_callbacks_.clear(); 51 sync_point_callbacks_.clear();
44 } 52 }
45 53
46 void TestContextSupport::SetSurfaceVisibleCallback( 54 void TestContextSupport::SetSurfaceVisibleCallback(
47 const SurfaceVisibleCallback& set_visible_callback) { 55 const SurfaceVisibleCallback& set_visible_callback) {
48 set_visible_callback_ = set_visible_callback; 56 set_visible_callback_ = set_visible_callback;
49 } 57 }
50 58
51 void TestContextSupport::Swap() { 59 void TestContextSupport::Swap() {
52 last_swap_type_ = SWAP; 60 last_swap_type_ = SWAP;
53 base::MessageLoop::current()->PostTask( 61 base::MessageLoop::current()->PostTask(
54 FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete, 62 FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete,
55 weak_ptr_factory_.GetWeakPtr())); 63 weak_ptr_factory_.GetWeakPtr()));
56 CallAllSyncPointCallbacks();
57 } 64 }
58 65
59 void TestContextSupport::PartialSwapBuffers(gfx::Rect sub_buffer) { 66 void TestContextSupport::PartialSwapBuffers(gfx::Rect sub_buffer) {
60 last_swap_type_ = PARTIAL_SWAP; 67 last_swap_type_ = PARTIAL_SWAP;
61 last_partial_swap_rect_ = sub_buffer; 68 last_partial_swap_rect_ = sub_buffer;
62 base::MessageLoop::current()->PostTask( 69 base::MessageLoop::current()->PostTask(
63 FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete, 70 FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete,
64 weak_ptr_factory_.GetWeakPtr())); 71 weak_ptr_factory_.GetWeakPtr()));
65 CallAllSyncPointCallbacks();
66 } 72 }
67 73
68 void TestContextSupport::SetSwapBuffersCompleteCallback( 74 void TestContextSupport::SetSwapBuffersCompleteCallback(
69 const base::Closure& callback) { 75 const base::Closure& callback) {
70 swap_buffers_complete_callback_ = callback; 76 swap_buffers_complete_callback_ = callback;
71 } 77 }
72 78
73 void TestContextSupport::OnSwapBuffersComplete() { 79 void TestContextSupport::OnSwapBuffersComplete() {
74 if (!swap_buffers_complete_callback_.is_null()) 80 if (!swap_buffers_complete_callback_.is_null())
75 swap_buffers_complete_callback_.Run(); 81 swap_buffers_complete_callback_.Run();
76 } 82 }
77 83
78 } // namespace cc 84 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | content/browser/aura/owned_mailbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698