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

Unified 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 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..3daf0cd3db00c8c3580a1e175d5db9692626da45
--- /dev/null
+++ b/chrome/renderer/media/chrome_key_systems_provider.h
@@ -0,0 +1,68 @@
+// 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/callback.h"
+#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 {
+
+typedef std::vector<std::unique_ptr<media::KeySystemProperties>>
+ KeySystemPropertiesVector;
+typedef base::Callback<void(KeySystemPropertiesVector*)>
+ KeySystemsProviderDelegate;
+
+class ChromeKeySystemsProvider {
+ public:
+ ChromeKeySystemsProvider();
+ ~ChromeKeySystemsProvider();
+
+ // Adds properties for supported key systems.
+ void AddSupportedKeySystems(KeySystemPropertiesVector* 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(
+ const KeySystemsProviderDelegate& 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.
+ KeySystemsProviderDelegate test_provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeKeySystemsProvider);
+};
+
+} // namespace chrome
+
+#endif // CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_PROVIDER_H_
« 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