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

Side by Side Diff: chrome/renderer/media/chrome_key_systems_provider.h

Issue 2712983004: Simplify/Cleanup MediaClient (Closed)
Patch Set: Fix test leak Created 3 years, 8 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
OLDNEW
(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 CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
6 #define CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/threading/thread_checker.h"
13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h"
15 #include "media/base/key_system_properties.h"
16
17 namespace chrome {
18
19 typedef std::vector<std::unique_ptr<media::KeySystemProperties>>
20 KeySystemPropertiesVector;
21 typedef base::Callback<void(KeySystemPropertiesVector*)>
22 KeySystemsProviderDelegate;
23
24 class ChromeKeySystemsProvider {
25 public:
26 ChromeKeySystemsProvider();
27 ~ChromeKeySystemsProvider();
28
29 // Adds properties for supported key systems.
30 void AddSupportedKeySystems(KeySystemPropertiesVector* key_systems);
31
32 // Returns whether client key systems properties should be updated.
33 // TODO(chcunningham): Refactor this to a proper change "observer" API that is
34 // less fragile (don't assume AddSupportedKeySystems has just one caller).
35 bool IsKeySystemsUpdateNeeded();
36
37 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
38
39 void SetProviderDelegateForTesting(
40 const KeySystemsProviderDelegate& test_provider);
41
42 private:
43 // Whether AddSupportedKeySystems() has ever been called.
44 bool has_updated_;
45
46 // Whether a future update is needed. For example, when some potentially
47 // supported key systems are NOT supported yet. This could happen when the
48 // required component for a key system is not yet available.
49 bool is_update_needed_;
50
51 // Throttle how often we signal an update is needed to avoid unnecessary high
52 // frequency of expensive IPC calls.
53 base::TimeTicks last_update_time_ticks_;
54 std::unique_ptr<base::TickClock> tick_clock_;
55
56 // Ensure all methods are called from the same (Main) thread.
57 base::ThreadChecker thread_checker_;
58
59 // For unit tests to inject their own key systems. Will bypass adding default
60 // Chrome key systems when set.
61 KeySystemsProviderDelegate test_provider_;
62
63 DISALLOW_COPY_AND_ASSIGN(ChromeKeySystemsProvider);
64 };
65
66 } // namespace chrome
67
68 #endif // CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | chrome/renderer/media/chrome_key_systems_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698