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

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

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.cc
diff --git a/chrome/browser/media/router/media_route_factory.cc b/chrome/browser/media/router/media_route_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1a4cdc1582b4ff35f642c0be3e6f19c19401f440
--- /dev/null
+++ b/chrome/browser/media/router/media_route_factory.cc
@@ -0,0 +1,37 @@
+// 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.
+
+#include "chrome/browser/media/router/media_route_factory.h"
+
+#include "base/memory/singleton.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/media/router/media_route.h"
+
+namespace media_router {
+namespace {
+const char kRoutePrefix[] = "route-";
mark a. foltz 2015/03/05 16:58:41 Per our conversation yesterday, route-local- so we
Kevin M 2015/03/05 18:34:18 Done.
+} // namespace
+
+MediaRouteFactory::MediaRouteFactory() : next_id_(0) {}
+
+std::string MediaRouteFactory::NextRouteId() {
+ std::string output = kRoutePrefix + base::Uint64ToString(next_id_);
+ next_id_++;
+ return output;
mark a. foltz 2015/03/05 16:58:41 Can this function be a one-liner?
Kevin M 2015/03/05 18:34:18 Sure, if you're comfortable with an inline postinc
+}
+
+// static
+MediaRouteFactory* MediaRouteFactory::GetInstance() {
+ return Singleton<MediaRouteFactory>::get();
+}
+
+MediaRoute MediaRouteFactory::Create(const MediaSource& media_source,
+ const MediaSinkId& sink_id,
+ const std::string& description,
+ bool is_local) {
+ return MediaRoute(NextRouteId(), media_source, sink_id, description,
+ is_local);
+}
+
+} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698