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

Unified Diff: services/media/factory_service/mojo_publisher.h

Issue 1986303002: Motown: Use new TimelineTransform and related definitions (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixes per feedback. Created 4 years, 7 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
« no previous file with comments | « services/media/factory_service/media_source_impl.h ('k') | services/media/framework_mojo/mojo_formatting.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/media/factory_service/mojo_publisher.h
diff --git a/services/media/factory_service/mojo_publisher.h b/services/media/factory_service/mojo_publisher.h
deleted file mode 100644
index 0fb4e885e763f49f71438428484d173977ee4bf7..0000000000000000000000000000000000000000
--- a/services/media/factory_service/mojo_publisher.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2016 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 SERVICES_MEDIA_FRAMEWORK_MOJO_PUBLISHER_H_
-#define SERVICES_MEDIA_FRAMEWORK_MOJO_PUBLISHER_H_
-
-#include <functional>
-#include <vector>
-
-namespace mojo {
-namespace media {
-
-// Implements pull mode publishing (e.g. MediaPlayer::GetStatus).
-template <typename TCallback>
-class MojoPublisher {
- public:
- using CallbackRunner = std::function<void(const TCallback&, uint64_t)>;
-
- // Sets the callback runner. This method must be called before calling Get
- // or Updated. The callback runner calls a single callback using current
- // information.
- void SetCallbackRunner(const CallbackRunner& callback_runner) {
- DCHECK(callback_runner);
- callback_runner_ = callback_runner;
- }
-
- // Handles a get request from the client. This method should be called from
- // the mojo 'get' method (e.g. MediaPlayer::GetStatus).
- void Get(uint64_t version_last_seen, const TCallback& callback) {
- DCHECK(callback_runner_);
-
- if (version_last_seen < version_) {
- callback_runner_(callback, version_);
- } else {
- pending_callbacks_.push_back(callback);
- }
- }
-
- // Increments the version number and runs pending callbacks. This method
- // should be called whenever the published information should be sent to
- // subscribing clients.
- void SendUpdates() {
- DCHECK(callback_runner_);
-
- ++version_;
-
- std::vector<TCallback> pending_callbacks;
- pending_callbacks_.swap(pending_callbacks);
-
- for (const TCallback& pending_callback : pending_callbacks) {
- callback_runner_(pending_callback, version_);
- }
- }
-
- private:
- uint64_t version_ = 1u;
- std::vector<TCallback> pending_callbacks_;
- CallbackRunner callback_runner_;
-};
-
-} // namespace media
-} // namespace mojo
-
-#endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_ALLOCATOR_H_
« no previous file with comments | « services/media/factory_service/media_source_impl.h ('k') | services/media/framework_mojo/mojo_formatting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698