Chromium Code Reviews| Index: chrome/browser/extensions/api/feedback_private/single_log_source_factory.cc |
| diff --git a/chrome/browser/extensions/api/feedback_private/single_log_source_factory.cc b/chrome/browser/extensions/api/feedback_private/single_log_source_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28bc461c2575f9ded2e029079ed22ae812697b2f |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/feedback_private/single_log_source_factory.cc |
| @@ -0,0 +1,33 @@ |
| +// Copyright 2017 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/extensions/api/feedback_private/single_log_source_factory.h" |
| + |
| +#include "base/memory/ptr_util.h" |
| + |
| +namespace extensions { |
| + |
| +namespace { |
| + |
| +using system_logs::SingleLogSource; |
| + |
| +const SingleLogSourceFactory::CreateCallback* g_callback = nullptr; |
| + |
| +} // namespace |
| + |
| +// static |
| +std::unique_ptr<SingleLogSource> SingleLogSourceFactory::CreateSingleLogSource( |
| + SingleLogSource::SupportedSource type) { |
| + if (g_callback) |
| + return std::unique_ptr<SingleLogSource>(g_callback->Run(type)); |
|
tbarzic
2017/06/06 20:27:26
Can't g_callback return unique_ptr directly?
Simon Que
2017/06/06 22:29:15
Done.
|
| + return base::MakeUnique<SingleLogSource>(type); |
| +} |
| + |
| +// static |
| +void SingleLogSourceFactory::SetForTesting( |
| + const SingleLogSourceFactory::CreateCallback* callback) { |
| + g_callback = callback; |
| +} |
| + |
| +} // namespace extensions |