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

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

Issue 2712983004: Simplify/Cleanup MediaClient (Closed)
Patch Set: Test fix. 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/threading/thread_checker.h"
12 #include "base/time/tick_clock.h"
13 #include "base/time/time.h"
14 #include "media/base/key_system_properties.h"
15
16 namespace chrome {
jochen (gone - plz use gerrit) 2017/04/06 13:00:05 it's not really common to use namespace chrome unl
chcunningham 2017/04/06 20:48:34 I noticed that in a number of files - whats the hi
17
18 class TestKeySystemsProviderDelegate {
jochen (gone - plz use gerrit) 2017/04/06 13:00:05 Is that a testing delegate? In that case, I'd expe
chcunningham 2017/04/06 20:48:34 I've replaced this interface with a simple callbac
19 public:
20 virtual ~TestKeySystemsProviderDelegate() = default;
21 virtual void AddTestKeySystems(
jochen (gone - plz use gerrit) 2017/04/06 13:00:05 please add comments what this is supposed to do
chcunningham 2017/04/06 20:48:34 N/A given new changes. I do have some comments abo
22 std::vector<std::unique_ptr<media::KeySystemProperties>>*
23 key_systems) = 0;
24 };
25
26 class ChromeKeySystemsProvider {
27 public:
28 ChromeKeySystemsProvider();
29 ~ChromeKeySystemsProvider();
30
31 // Adds properties for supported key systems.
32 void AddSupportedKeySystems(
33 std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems);
34
35 // Returns whether client key systems properties should be updated.
36 // TODO(chcunningham): Refactor this to a proper change "observer" API that is
37 // less fragile (don't assume AddSupportedKeySystems has just one caller).
38 bool IsKeySystemsUpdateNeeded();
39
40 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
41 void SetProviderDelegateForTesting(
42 std::unique_ptr<TestKeySystemsProviderDelegate> test_provider);
43
44 private:
45 // Whether AddSupportedKeySystems() has ever been called.
46 bool has_updated_;
47
48 // Whether a future update is needed. For example, when some potentially
49 // supported key systems are NOT supported yet. This could happen when the
50 // required component for a key system is not yet available.
51 bool is_update_needed_;
52
53 // Throttle how often we signal an update is needed to avoid unnecessary high
54 // frequency of expensive IPC calls.
55 base::TimeTicks last_update_time_ticks_;
56 std::unique_ptr<base::TickClock> tick_clock_;
57
58 // Ensure all methods are called from the same (Main) thread.
59 base::ThreadChecker thread_checker_;
60
61 // For unit tests to inject their own key systems. Will bypass adding default
62 // Chrome key systems when set.
63 std::unique_ptr<TestKeySystemsProviderDelegate> test_provider_;
64
65 DISALLOW_COPY_AND_ASSIGN(ChromeKeySystemsProvider);
66 };
67
68 } // namespace chrome
69
70 #endif // CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698