Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/media/router/media_route_factory.h" | |
| 6 | |
| 7 #include "base/memory/singleton.h" | |
| 8 #include "base/strings/string_number_conversions.h" | |
| 9 #include "chrome/browser/media/router/media_route.h" | |
| 10 | |
| 11 namespace media_router { | |
| 12 namespace { | |
| 13 const char kRoutePrefix[] = "route-"; | |
| 14 } // namespace | |
| 15 | |
| 16 MediaRouteFactory::MediaRouteFactory() { | |
| 17 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.
| |
| 18 } | |
| 19 | |
| 20 std::string MediaRouteFactory::NextRouteId() { | |
| 21 std::string output = kRoutePrefix + base::Uint64ToString(next_id_); | |
| 22 next_id_++; | |
| 23 return output; | |
| 24 } | |
| 25 | |
| 26 // static | |
| 27 MediaRouteFactory* MediaRouteFactory::GetInstance() { | |
| 28 return Singleton<MediaRouteFactory>::get(); | |
| 29 } | |
| 30 | |
| 31 MediaRoute* MediaRouteFactory::Create(const MediaSource& media_source, | |
| 32 const MediaSinkId& sink_id, | |
| 33 const std::string& description, | |
| 34 bool is_local) { | |
| 35 return new MediaRoute(NextRouteId(), | |
| 36 media_source, | |
| 37 sink_id, | |
| 38 description, | |
| 39 is_local); | |
| 40 } | |
| 41 | |
| 42 } // namespace media_router | |
| OLD | NEW |