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

Side by Side Diff: cc/test/fake_external_begin_frame_source.h

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ 5 #ifndef CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_
6 #define CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ 6 #define CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "cc/output/begin_frame_args.h"
13 #include "cc/scheduler/begin_frame_source.h" 14 #include "cc/scheduler/begin_frame_source.h"
14 15
15 namespace cc { 16 namespace cc {
16 17
17 class FakeExternalBeginFrameSource 18 class FakeExternalBeginFrameSource
18 : public BeginFrameSource, 19 : public BeginFrameSource,
19 public NON_EXPORTED_BASE(base::NonThreadSafe) { 20 public NON_EXPORTED_BASE(base::NonThreadSafe) {
20 public: 21 public:
21 class Client { 22 class Client {
22 public: 23 public:
23 virtual void OnAddObserver(BeginFrameObserver* obs) = 0; 24 virtual void OnAddObserver(BeginFrameObserver* obs) = 0;
24 virtual void OnRemoveObserver(BeginFrameObserver* obs) = 0; 25 virtual void OnRemoveObserver(BeginFrameObserver* obs) = 0;
25 }; 26 };
26 27
27 explicit FakeExternalBeginFrameSource(double refresh_rate, 28 explicit FakeExternalBeginFrameSource(double refresh_rate,
28 bool tick_automatically); 29 bool tick_automatically);
29 ~FakeExternalBeginFrameSource() override; 30 ~FakeExternalBeginFrameSource() override;
30 31
31 void SetClient(Client* client) { client_ = client; } 32 void SetClient(Client* client) { client_ = client; }
32 void SetPaused(bool paused); 33 void SetPaused(bool paused);
33 34
34 // BeginFrameSource implementation. 35 // BeginFrameSource implementation.
35 void AddObserver(BeginFrameObserver* obs) override; 36 void AddObserver(BeginFrameObserver* obs) override;
36 void RemoveObserver(BeginFrameObserver* obs) override; 37 void RemoveObserver(BeginFrameObserver* obs) override;
37 void DidFinishFrame(BeginFrameObserver* obs, 38 void DidFinishFrame(BeginFrameObserver* obs,
38 size_t remaining_frames) override {} 39 const BeginFrameAck& ack) override {}
39 bool IsThrottled() const override; 40 bool IsThrottled() const override;
40 41
41 void TestOnBeginFrame(const BeginFrameArgs& args); 42 void TestOnBeginFrame(const BeginFrameArgs& args);
42 43
43 size_t num_observers() const { return observers_.size(); } 44 size_t num_observers() const { return observers_.size(); }
44 45
45 private: 46 private:
46 void PostTestOnBeginFrame(); 47 void PostTestOnBeginFrame();
47 48
48 const bool tick_automatically_; 49 const bool tick_automatically_;
49 const double milliseconds_per_frame_; 50 const double milliseconds_per_frame_;
50 Client* client_ = nullptr; 51 Client* client_ = nullptr;
51 bool paused_ = false; 52 bool paused_ = false;
53 uint64_t next_begin_frame_number_ = BeginFrameArgs::kStartingFrameNumber;
52 std::set<BeginFrameObserver*> observers_; 54 std::set<BeginFrameObserver*> observers_;
53 base::CancelableCallback<void(const BeginFrameArgs&)> begin_frame_task_; 55 base::CancelableCallback<void(const BeginFrameArgs&)> begin_frame_task_;
54 base::WeakPtrFactory<FakeExternalBeginFrameSource> weak_ptr_factory_; 56 base::WeakPtrFactory<FakeExternalBeginFrameSource> weak_ptr_factory_;
55 }; 57 };
56 58
57 } // namespace cc 59 } // namespace cc
58 60
59 #endif // CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ 61 #endif // CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/test/begin_frame_source_test_unittest.cc ('k') | cc/test/fake_external_begin_frame_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698