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..fdc18978fec80c3a16b54bc549d19ab48cf6464e |
--- /dev/null |
+++ b/chrome/browser/media/router/media_route_factory.h |
@@ -0,0 +1,55 @@ |
+// 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 "base/threading/non_thread_safe.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. |
+class MediaRouteFactory : public base::NonThreadSafe { |
+ 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, |
xhwang
2015/03/05 22:28:49
Will it work if you have a static Create() functio
Kevin M
2015/03/06 23:12:44
The purpose of this class is more about enforcing
xhwang
2015/03/09 17:37:30
The static Create() function and static member of
Kevin M
2015/03/09 23:32:06
OK, I've turned this class into a "Route ID manage
|
+ 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_ |