Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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. | |
| 4 | |
| 5 #ifndef CHROMEOS_DBUS_TEST_UPSTART_CLIENT_H_ | |
| 6 #define CHROMEOS_DBUS_TEST_UPSTART_CLIENT_H_ | |
| 7 | |
| 8 #include <queue> | |
| 9 | |
| 10 #include "chromeos/dbus/fake_upstart_client.h" | |
|
tbarzic
2017/05/18 21:39:15
can you make this class private to the test that u
Luke Sorenson
2017/05/19 00:56:43
Done.
| |
| 11 | |
| 12 namespace chromeos { | |
| 13 | |
| 14 class CHROMEOS_EXPORT TestUpstartClient : public FakeUpstartClient { | |
| 15 public: | |
| 16 TestUpstartClient(); | |
| 17 ~TestUpstartClient() override; | |
| 18 | |
| 19 // Overrides behavior to queue start requests. | |
| 20 void StartMediaAnalytics(const UpstartCallback& callback) override; | |
| 21 | |
| 22 // Triggers the next queue'd start request to succeed or fail. | |
| 23 bool HandleNextUpstartRequest(bool should_succeed) { | |
| 24 if (pending_upstart_request_callbacks_.empty()) | |
| 25 return false; | |
| 26 | |
| 27 UpstartCallback callback = pending_upstart_request_callbacks_.front(); | |
| 28 pending_upstart_request_callbacks_.pop(); | |
| 29 | |
| 30 if (!should_succeed) { | |
| 31 callback.Run(false); | |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 FakeUpstartClient::StartMediaAnalytics(callback); | |
| 36 return true; | |
| 37 } | |
| 38 | |
| 39 private: | |
| 40 std::queue<UpstartCallback> pending_upstart_request_callbacks_; | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(TestUpstartClient); | |
| 43 }; | |
| 44 | |
| 45 TestUpstartClient::TestUpstartClient() {} | |
| 46 TestUpstartClient::~TestUpstartClient() {} | |
| 47 | |
| 48 void TestUpstartClient::StartMediaAnalytics(const UpstartCallback& callback) { | |
| 49 pending_upstart_request_callbacks_.push(callback); | |
| 50 } | |
| 51 | |
| 52 } // namespace chromeos | |
| 53 | |
| 54 #endif // CHROMEOS_DBUS_TEST_UPSTART_CLIENT_H_ | |
| OLD | NEW |