| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_BASE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_BASE_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_BASE_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/common/media_router/discovery/media_sink_internal.h" | 13 #include "chrome/common/media_router/discovery/media_sink_internal.h" |
| 14 #include "chrome/common/media_router/discovery/media_sink_service.h" | 14 #include "chrome/common/media_router/discovery/media_sink_service.h" |
| 15 | 15 |
| 16 namespace media_router { | 16 namespace media_router { |
| 17 | 17 |
| 18 class MediaSinkServiceBase : public MediaSinkService { | 18 class MediaSinkServiceBase : public MediaSinkService { |
| 19 public: | 19 public: |
| 20 explicit MediaSinkServiceBase(const OnSinksDiscoveredCallback& callback); | 20 explicit MediaSinkServiceBase(const OnSinksDiscoveredCallback& callback); |
| 21 ~MediaSinkServiceBase() override; | 21 ~MediaSinkServiceBase() override; |
| 22 | 22 |
| 23 protected: | 23 protected: |
| 24 void SetTimerForTest(std::unique_ptr<base::Timer> timer); | 24 void SetTimerForTest(std::unique_ptr<base::Timer> timer); |
| 25 | 25 |
| 26 // Called when |finish_timer_| expires. | 26 // Called when |finish_timer_| expires. |
| 27 void OnFetchCompleted(); | 27 virtual void OnFetchCompleted(); |
| 28 | 28 |
| 29 // Helper function to start |finish_timer_|. Create a new timer if none | 29 // Helper function to start |finish_timer_|. Create a new timer if none |
| 30 // exists. | 30 // exists. |
| 31 void StartTimer(); | 31 void StartTimer(); |
| 32 | 32 |
| 33 // Helper function to stop |finish_timer_|. | 33 // Helper function to stop |finish_timer_|. |
| 34 void StopTimer(); | 34 void StopTimer(); |
| 35 | 35 |
| 36 // Helper function to restart |finish_timer|. No-op if timer does not exist or | 36 // Helper function to restart |finish_timer|. No-op if timer does not exist or |
| 37 // timer is currently running. | 37 // timer is currently running. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 54 FRIEND_TEST_ALL_PREFIXES(MediaSinkServiceBaseTest, | 54 FRIEND_TEST_ALL_PREFIXES(MediaSinkServiceBaseTest, |
| 55 TestFetchCompleted_SameSink); | 55 TestFetchCompleted_SameSink); |
| 56 | 56 |
| 57 // Timer for finishing fetching. | 57 // Timer for finishing fetching. |
| 58 std::unique_ptr<base::Timer> finish_timer_; | 58 std::unique_ptr<base::Timer> finish_timer_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace media_router | 61 } // namespace media_router |
| 62 | 62 |
| 63 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_BASE_H_ | 63 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_MEDIA_SINK_SERVICE_BASE_H_ |
| OLD | NEW |