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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/media/chrome_key_systems_provider.h
diff --git a/chrome/renderer/media/chrome_key_systems_provider.h b/chrome/renderer/media/chrome_key_systems_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..f272213dde6caac43e314d1dcfd3b823658d099c
--- /dev/null
+++ b/chrome/renderer/media/chrome_key_systems_provider.h
@@ -0,0 +1,70 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
+#define CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/threading/thread_checker.h"
+#include "base/time/tick_clock.h"
+#include "base/time/time.h"
+#include "media/base/key_system_properties.h"
+
+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
+
+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
+ public:
+ virtual ~TestKeySystemsProviderDelegate() = default;
+ 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
+ std::vector<std::unique_ptr<media::KeySystemProperties>>*
+ key_systems) = 0;
+};
+
+class ChromeKeySystemsProvider {
+ public:
+ ChromeKeySystemsProvider();
+ ~ChromeKeySystemsProvider();
+
+ // Adds properties for supported key systems.
+ void AddSupportedKeySystems(
+ std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems);
+
+ // Returns whether client key systems properties should be updated.
+ // TODO(chcunningham): Refactor this to a proper change "observer" API that is
+ // less fragile (don't assume AddSupportedKeySystems has just one caller).
+ bool IsKeySystemsUpdateNeeded();
+
+ void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
+ void SetProviderDelegateForTesting(
+ std::unique_ptr<TestKeySystemsProviderDelegate> test_provider);
+
+ private:
+ // Whether AddSupportedKeySystems() has ever been called.
+ bool has_updated_;
+
+ // Whether a future update is needed. For example, when some potentially
+ // supported key systems are NOT supported yet. This could happen when the
+ // required component for a key system is not yet available.
+ bool is_update_needed_;
+
+ // Throttle how often we signal an update is needed to avoid unnecessary high
+ // frequency of expensive IPC calls.
+ base::TimeTicks last_update_time_ticks_;
+ std::unique_ptr<base::TickClock> tick_clock_;
+
+ // Ensure all methods are called from the same (Main) thread.
+ base::ThreadChecker thread_checker_;
+
+ // For unit tests to inject their own key systems. Will bypass adding default
+ // Chrome key systems when set.
+ std::unique_ptr<TestKeySystemsProviderDelegate> test_provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeKeySystemsProvider);
+};
+
+} // namespace chrome
+
+#endif // CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698