Make a copy of HttpResponseHeaders in StreamHandleImpl.
[chromium-blink-merge.git] / cc / test / test_context_support.cc
bloba2bedc0835219e3f6193d8bda6087e5b83d11a3a
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
3 // found in the LICENSE file.
5 #include "cc/test/test_context_support.h"
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
10 namespace cc {
12 TestContextSupport::TestContextSupport()
13 : last_swap_type_(NO_SWAP),
14 weak_ptr_factory_(this) {
17 TestContextSupport::~TestContextSupport() {}
19 void TestContextSupport::SignalSyncPoint(uint32 sync_point,
20 const base::Closure& 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()));
28 void TestContextSupport::SignalQuery(uint32 query,
29 const base::Closure& 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()));
37 void TestContextSupport::SetSurfaceVisible(bool visible) {
38 if (!set_visible_callback_.is_null()) {
39 set_visible_callback_.Run(visible);
43 void TestContextSupport::CallAllSyncPointCallbacks() {
44 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) {
45 base::MessageLoop::current()->PostTask(
46 FROM_HERE, sync_point_callbacks_[i]);
48 sync_point_callbacks_.clear();
51 void TestContextSupport::SetSurfaceVisibleCallback(
52 const SurfaceVisibleCallback& set_visible_callback) {
53 set_visible_callback_ = set_visible_callback;
56 void TestContextSupport::SetScheduleOverlayPlaneCallback(
57 const ScheduleOverlayPlaneCallback& schedule_overlay_plane_callback) {
58 schedule_overlay_plane_callback_ = schedule_overlay_plane_callback;
61 void TestContextSupport::Swap() {
62 last_swap_type_ = SWAP;
63 base::MessageLoop::current()->PostTask(
64 FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete,
65 weak_ptr_factory_.GetWeakPtr()));
68 uint32 TestContextSupport::InsertFutureSyncPointCHROMIUM() {
69 NOTIMPLEMENTED();
70 return 0;
73 void TestContextSupport::RetireSyncPointCHROMIUM(uint32 sync_point) {
74 NOTIMPLEMENTED();
77 void TestContextSupport::PartialSwapBuffers(const gfx::Rect& sub_buffer) {
78 last_swap_type_ = PARTIAL_SWAP;
79 last_partial_swap_rect_ = sub_buffer;
80 base::MessageLoop::current()->PostTask(
81 FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete,
82 weak_ptr_factory_.GetWeakPtr()));
85 void TestContextSupport::ScheduleOverlayPlane(
86 int plane_z_order,
87 gfx::OverlayTransform plane_transform,
88 unsigned overlay_texture_id,
89 const gfx::Rect& display_bounds,
90 const gfx::RectF& uv_rect) {
91 if (!schedule_overlay_plane_callback_.is_null()) {
92 schedule_overlay_plane_callback_.Run(plane_z_order,
93 plane_transform,
94 overlay_texture_id,
95 display_bounds,
96 uv_rect);
100 void TestContextSupport::SetSwapBuffersCompleteCallback(
101 const base::Closure& callback) {
102 swap_buffers_complete_callback_ = callback;
105 void TestContextSupport::OnSwapBuffersComplete() {
106 if (!swap_buffers_complete_callback_.is_null())
107 swap_buffers_complete_callback_.Run();
110 } // namespace cc