Chromium Code Reviews| Index: chrome/browser/extensions/api/feedback_private/log_source_resource.cc |
| diff --git a/chrome/browser/extensions/api/feedback_private/log_source_resource.cc b/chrome/browser/extensions/api/feedback_private/log_source_resource.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b7e59e1f5560d1c43689c267610d19d5fc34ce63 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/feedback_private/log_source_resource.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/log_source_resource.h" |
| + |
| +#include "base/lazy_instance.h" |
| + |
| +namespace extensions { |
| + |
| +// For managing API resources of type LogSourceResource. |
| +static base::LazyInstance<BrowserContextKeyedAPIFactory< |
| + ApiResourceManager<LogSourceResource>>>::DestructorAtExit |
|
tbarzic
2017/06/06 20:27:26
Can this be leaky instead?
(see https://cs.chromiu
Simon Que
2017/06/06 22:29:15
It doesn't work, results in a crash.
DestructorAt
|
| + g_log_source_resource_factory = LAZY_INSTANCE_INITIALIZER; |
| + |
| +// static |
| +template <> |
| +BrowserContextKeyedAPIFactory<ApiResourceManager<LogSourceResource>>* |
| +ApiResourceManager<LogSourceResource>::GetFactoryInstance() { |
| + return g_log_source_resource_factory.Pointer(); |
| +} |
| + |
| +LogSourceResource::LogSourceResource( |
| + const std::string& extension_id, |
| + std::unique_ptr<system_logs::SingleLogSource> source, |
| + base::Closure unregister_callback) |
| + : ApiResource(extension_id), |
| + source_(source.release()), |
| + unregister_runner_(unregister_callback) {} |
| + |
| +LogSourceResource::~LogSourceResource() {} |
| + |
| +} // namespace extensions |