OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 // NOT DEAD CODE! | |
6 // This code isn't dead, even if it isn't currently being used. Please refer to: | |
7 // https://www.chromium.org/developers/how-tos/compact-language-detector-cld-dat
a-source-configuration | |
8 | |
9 #include "components/translate/content/renderer/renderer_cld_data_provider_facto
ry.h" | |
10 | |
11 #include "base/lazy_instance.h" | |
12 #include "base/memory/ptr_util.h" | |
13 #include "components/translate/content/renderer/renderer_cld_data_provider.h" | |
14 #include "content/public/renderer/render_frame_observer.h" | |
15 | |
16 namespace { | |
17 | |
18 // The global instance, alive for the entire lifetime of the process. | |
19 translate::RendererCldDataProviderFactory* g_instance = NULL; | |
20 | |
21 // The default factory, which produces no-op instances of | |
22 // RendererCldDataProvider suitable for use when CLD data is statically-linked. | |
23 base::LazyInstance<translate::RendererCldDataProviderFactory>::Leaky | |
24 g_wrapped_default = LAZY_INSTANCE_INITIALIZER; | |
25 | |
26 } // namespace | |
27 | |
28 | |
29 namespace translate { | |
30 | |
31 std::unique_ptr<RendererCldDataProvider> | |
32 RendererCldDataProviderFactory::CreateRendererCldDataProvider( | |
33 content::RenderFrameObserver* render_frame_observer) { | |
34 return base::WrapUnique(new RendererCldDataProvider()); | |
35 } | |
36 | |
37 // static | |
38 bool RendererCldDataProviderFactory::IsInitialized() { | |
39 return g_instance != nullptr; | |
40 } | |
41 | |
42 // static | |
43 void RendererCldDataProviderFactory::SetDefault( | |
44 RendererCldDataProviderFactory* instance) { | |
45 if (!IsInitialized()) Set(instance); | |
46 } | |
47 | |
48 // static | |
49 void RendererCldDataProviderFactory::Set( | |
50 RendererCldDataProviderFactory* instance) { | |
51 g_instance = instance; | |
52 } | |
53 | |
54 // static | |
55 RendererCldDataProviderFactory* RendererCldDataProviderFactory::Get() { | |
56 if (IsInitialized()) return g_instance; | |
57 return &g_wrapped_default.Get(); | |
58 } | |
59 | |
60 } // namespace translate | |
OLD | NEW |