Chromium Code Reviews| 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 |