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..08634136ad482f59db7c845a069f28613aa29580 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/media_route_factory.cc |
| @@ -0,0 +1,42 @@ |
| +// 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-"; |
| +} // namespace |
| + |
| +MediaRouteFactory::MediaRouteFactory() { |
| + next_id_ = 0; |
|
imcheng
2015/03/03 22:53:09
this can be initialized using the member initializ
Kevin M
2015/03/03 23:28:05
Done.
|
| +} |
| + |
| +std::string MediaRouteFactory::NextRouteId() { |
| + std::string output = kRoutePrefix + base::Uint64ToString(next_id_); |
| + next_id_++; |
| + return output; |
| +} |
| + |
| +// 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 new MediaRoute(NextRouteId(), |
| + media_source, |
| + sink_id, |
| + description, |
| + is_local); |
| +} |
| + |
| +} // namespace media_router |