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

Unified Diff: chrome/browser/media/router/media_route_factory.h

Issue 949293004: Add media router common classes and unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review feedback. Created 5 years, 10 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/browser/media/router/media_route_factory.h
diff --git a/chrome/browser/media/router/media_route_factory.h b/chrome/browser/media/router/media_route_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..7672a0ee61352eaa237406a99dd8dec352b9bcd7
--- /dev/null
+++ b/chrome/browser/media/router/media_route_factory.h
@@ -0,0 +1,54 @@
+// Copyright 2015 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_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_FACTORY_H_
+#define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_FACTORY_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
+#include "base/memory/singleton.h"
+#include "chrome/browser/media/router/media_sink.h"
+#include "chrome/browser/media/router/media_source.h"
+
+namespace media_router {
+
+class MediaRoute;
+
+// Shared singleton which coordinates the assignment of unique IDs to
+// MediaRoute objects.
mark a. foltz 2015/03/05 16:58:41 This is a static singleton that uses a non-threads
Kevin M 2015/03/05 18:34:18 Done.
+class MediaRouteFactory {
+ public:
+ static MediaRouteFactory* GetInstance();
+
+ // Returns a MediaRoute object with a unique ID.
+ // |type|: Type of media route.
+ // |media_source|: Description of source of the route.
+ // |sink_id|: ID of the MediaSink of the route.
+ // |description|: Description of the route to be displayed.
+ // |is_local|: true if the route was created from this browser.
+ MediaRoute Create(const MediaSource& media_source,
+ const MediaSinkId& sink_id,
+ const std::string& description,
+ bool is_local);
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(MediaRouteFactoryTest, Create);
+ friend struct DefaultSingletonTraits<MediaRouteFactory>;
+
+ MediaRouteFactory();
+
+ // Gets the next route ID.
+ std::string NextRouteId();
+
+ // Monotonically increasing ID number.
+ uint64 next_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaRouteFactory);
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698